Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeadCode] Register more Stmt Nodes on RemoveUnreachableStatementRector #2140

Merged
merged 4 commits into from
Apr 23, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Apr 23, 2022

since RemoveUnreachableStatementRector check exactly previous stmt on loop, it can be applied to more Nodes which has stmt property:

            For_::class,
            Foreach_::class,
            Do_::class,
            While_::class,
            ClassMethod::class,
            Function_::class,
            Closure::class,
            If_::class,
            ElseIf_::class,
            Else_::class,
            Case_::class,
            TryCatch::class,
            Catch_::class,
            Finally_::class,

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@samsonasik
Copy link
Member Author

I found a bug when it applied to ArrowFunction_ on code:

class sss
{
    public function test()
    {
        return fn(): bool => true;
    }
}

it previously produce:

There was 1 error:

1) Rector\Tests\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector\RemoveUnreachableStatementRectorTest::test with data set #12 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
Undefined property: PhpParser\Node\Expr\ArrowFunction::$stmts

so exclude ArrowFunction_ by define at ClassMethod, Function_, and Closure 34eb21a

I am merging it ;)

@samsonasik samsonasik merged commit 469f0ee into main Apr 23, 2022
@samsonasik samsonasik deleted the add-more-stmts-unreachable branch April 23, 2022 18:51
@TomasVotruba
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants