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] Handle crash on negation class const fetch with static:: and parent:: on RemoveDeadZeroAndOneOperationRector #2714

Merged
merged 8 commits into from Jul 26, 2022

Conversation

samsonasik
Copy link
Member

Given the following code:

final class SkipNegationClassConstFetch
{
    protected const CSRF_HASH_BYTES      = 16;

    protected function derandomize(string $token): int
    {
        echo -static::CSRF_HASH_BYTES * 2;
    }
}

It currently produce error:

There was 1 error:

1) Rector\Tests\DeadCode\Rector\Plus\RemoveDeadZeroAndOneOperationRector\RemoveDeadZeroAndOneOperationRectorTest::test with data set #6 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
TypeError: Unsupported operand types: string * int

Fixes rectorphp/rector#7321

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik samsonasik changed the title [DeadCode] Handle crash on negation class const fetch with static:: on RemoveDeadZeroAndOneOperationRector [DeadCode] Handle crash on negation class const fetch with static:: and parent:: on RemoveDeadZeroAndOneOperationRector Jul 26, 2022
@samsonasik
Copy link
Member Author

Also handle parent:: usage

@samsonasik
Copy link
Member Author

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

@TomasVotruba TomasVotruba merged commit 32834d0 into main Jul 26, 2022
@TomasVotruba TomasVotruba deleted the crash-static branch July 26, 2022 14:45
@TomasVotruba
Copy link
Member

Thanks 👍

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