Skip to content

Squiz Arrays.ArrayDeclaration and Strings.ConcatenationSpacing fixers causing parse errors with here/nowdocs #1522

@jrfnl

Description

@jrfnl

Came across these little gems when trying to isolate a fixer conflict elsewhere (WordPress/WordPress-Coding-Standards#986 - still working on that one).

The issue exists in both PHPCS 2.x as well as 3.x when using the Squiz standard.

When given this code:

get_current_screen()->add_help_tab( array(
'id'		=> <<<EOD
Here comes some text.
EOD
. '</hr>',
) );

It will be fixed like this with the .'</hr>', having been moved up causing parse errors (quite apart from the fixed spacing not being correct):

get_current_screen()->add_help_tab(
     array(
                                         'id'        => <<<EOD
Here comes some text.
EOD    .'</hr>',
                                    ) 
    );

And when given this code:

get_current_screen()->add_help_tab( array(
		'id'		=> <<<EOD
Here comes some text.
EOD
,
) );

It will be fixed like this with the comma being added in this bit => ,<<<EOD causing parse errors:

get_current_screen()->add_help_tab(
    [
     'id' => ,<<<EOD
Here comes some text.
EOD
    ,
    ]
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions