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

[Privatization] Fix crash on assign inside Arg on ChangeReadOnlyVariableWithDefaultValueToConstantRector #3423

Merged
merged 3 commits into from
Feb 28, 2023

Conversation

samsonasik
Copy link
Member

Given the following code:

final class SkipAssignInsideArg
{
    public function run()
    {
        $c = base64_decode(str_replace(['--', '_'], ['+', '/'], $key));

        $ivlen = openssl_cipher_iv_length($cipher = "AES-128-CFB");
        $hmac = substr($c, $ivlen, $sha2len = 32);
        $ciphertext_raw = substr($c, $ivlen + $sha2len);
    }
}

cause crash:

Time: 00:00.882, Memory: 78.50 MB

There was 1 error:

1) Rector\Tests\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector\ChangeReadOnlyVariableWithDefaultValueToConstantRectorTest::test with data set #6
LogicException: leaveNode() returned invalid value of type integer

/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:168
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:223

Ref https://getrector.com/demo/d7728f83-a22f-4e08-8e76-e10e4b433c5e
Fixes rectorphp/rector#7805

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @jbcr

@samsonasik
Copy link
Member Author

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

@TomasVotruba TomasVotruba merged commit fe3c6ff into main Feb 28, 2023
@TomasVotruba TomasVotruba deleted the skip-crash-on-assign-inside-arg branch February 28, 2023 15:21
@TomasVotruba
Copy link
Member

Thank you

samsonasik added a commit that referenced this pull request May 8, 2023
…bleWithDefaultValueToConstantRector (#3423)

* [Privatization] Skip crash on assign inside Arg on ChangeReadOnlyVariableWithDefaultValueToConstantRector

* Fixed 🎉

* use Expression to cover other use case
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