Skip to content

PSR12.ControlStructures.ControlStructureSpacing not ignoring indentation inside multi-line string arguments #2623

@dereuromark

Description

@dereuromark
if (preg_match(
            '(
                \*\s+[{}A-Z0-9\-]+.*\s+
                \*?\s*
                \*\s+@api
            )xi',
            $comment
        )) {
            return;
        }

reports

 86 | ERROR | [x] Each line in a multi-line control structure must be indented at least once; expected at least 12 spaces, but found 0
    |       |     (PSR12.ControlStructures.ControlStructureSpacing.LineIndent)
 88 | ERROR | [x] Each line in a multi-line control structure must be indented at least once; expected at least 12 spaces, but found 8
    |       |     (PSR12.ControlStructures.ControlStructureSpacing.LineIndent)
 88 | ERROR | [x] The closing parenthesis of a multi-line control structure must be on the line after the last expression
    |       |     (PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine)

but when running it

FAILED TO FIX

Using -vvv it seems that this is what it fixes it too, breaking other rules:

if (preg_match(
 82|            '(
 83|                \*\s+[{}A-Z0-9\-]+.*\s+
 84|                \*?\s*
 85|                \*\s+@api
 86|                                                                                                                                                                                                )xi',
 87|            $comment
 88|            )
 89|        ) {
 90|            return;
 91|        }

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