Skip to content

Generic.WhiteSpace.ScopeIndent.Incorrect issue after NOWDOC #2883

@JeroenBakker

Description

@JeroenBakker

Hi there,

I'm having an issue where phpcs is complaining about my indentation level in a nested array.
It seems to be caused by a NOWDOC or HEREDOC and then the issue crops up somewhere after a multi-line array

This is using phpcs version 3.5.4

The following array reproduces this issue:

return [
    'lor' =>
        // Without this NOWDOC everything works fine
        <<<'INTRO'
        lorem ipsum
        INTRO,
    'em' => [
        // Without this multiline array everything works fine
        [
            '',
        ],
    ],
    // Every toplevel array key from here is being flagged as being incorrectly indented
    'abc' => [
        'a' => 'wop wop',
        'b' => 'ola ola.',
    ],
];

The full error is:

 Line indented incorrectly; expected at least 8 spaces, found 4 (Generic.WhiteSpace.ScopeIndent.Incorrect)

If I were to attempt to fix this with phpcbf it adds the indentation and throws the next error:

Array key not indented correctly; expected 4 spaces but found 8 (Generic.Arrays.ArrayIndent.KeyIncorrect)

Any further attempts to fix this just go back and forth between the two.

If you need any further details please let me know!

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