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

[Php72] Handle crash on PreInc usage on CreateFunctionToAnonymousFunctionRector #2456

Merged
merged 4 commits into from
Jun 9, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Jun 8, 2022

Given the following code:

class UseIncrement
{
    private array $_quoteIdentifierCallbacks = array();
    private int $_qiCallbacksCount = 0;

    public function getQuoteIdentifierCallback($adapter)
    {
         $callback = create_function('$v', 'return Mage::helper(\'customgrid/collection\')->callQuoteIdentifier($v, '.++$this->_qiCallbacksCount.');');
    }

}

It currently make crash:

There was 1 error:

1) Rector\Tests\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\CreateFunctionToAnonymousFunctionRectorTest::test with data set #3 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
Rector\Core\Exception\ShouldNotHappenException: PhpParser\Node\Expr\PreInc Rector\Core\PhpParser\Parser\InlineCodeParser::stringify

This PR try to fix it .

Fixes rectorphp/rector#7216

@samsonasik samsonasik requested a review from TomasVotruba as a code owner June 8, 2022 22:31
@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @ThibaultAndreis

@samsonasik
Copy link
Member Author

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

@samsonasik
Copy link
Member Author

rebased.

@samsonasik
Copy link
Member Author

rebased.

@TomasVotruba TomasVotruba enabled auto-merge (squash) June 9, 2022 07:48
@TomasVotruba
Copy link
Member

Thank you 👏

@TomasVotruba TomasVotruba merged commit f2300ba into main Jun 9, 2022
@TomasVotruba TomasVotruba deleted the crash-increment branch June 9, 2022 07:52
@ThibaultAndreis
Copy link
Contributor

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
Development

Successfully merging this pull request may close these issues.

Error refactoring create_function into Anonymous Function
4 participants