Skip to content

Indentation in fallthrough CASE that contains a closure #1478

Closed
@fixpunkt

Description

@fixpunkt

Given this example of a fallthrough case:

<?php
namespace Test;

class Test
{
    public function m($a)
    {
        switch ($a) {
            case 0:
                function () {
                };
            case 1:
                break;
        }
    }
}

The line containing the second case statement is highlighted with the message Line indented incorrectly; expected 16 spaces, found 12. We spent some time debugging and narrowed it down to this special case handling, which skips the opening curly which would cause a scope to be created for the closure . However, the closing curly is processed and causes the outer scope to be popped by mistake. This, in turn, causes these checks to fail, leading to the observed error.

I'm not sure how to fix this, so unfortunately cannot provide a PR right now. Any ideas how to fix this without breaking other cases?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions