Skip to content

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

Merged
TomasVotruba merged 3 commits intomainfrom
skip-crash-on-assign-inside-arg
Feb 28, 2023
Merged

[Privatization] Fix crash on assign inside Arg on ChangeReadOnlyVariableWithDefaultValueToConstantRector#3423
TomasVotruba merged 3 commits intomainfrom
skip-crash-on-assign-inside-arg

Conversation

@samsonasik
Copy link
Copy Markdown
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
Copy Markdown
Member Author

Fixed 🎉 /cc @jbcr

@samsonasik
Copy link
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

Variable argument affectation in function argument crash rector with ChangeReadOnlyVariableWithDefaultValueToConstantRector rule

2 participants