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

[EarlyReturn][Php73] Handle JsonThrowOnErrorRector + ChangeAndIfToEarlyReturnRector #1272

Merged
merged 3 commits into from
Nov 19, 2021

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Nov 19, 2021

Given the following code:

function f()
{
    if (true && true) {
        json_decode($a);
    }
}

It produce error:

There was 1 failure:

1) Rector\Core\Tests\Issues\JsonThrowWithChangeAndIf\JsonThrowWithChangeAndIfTest::test with data set #0 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
assert($itemStartPos >= 0 && $itemEndPos >= 0) in /Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php:865

applied rules:

Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;

Fixes rectorphp/rector#6812

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

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

@TomasVotruba TomasVotruba merged commit 7143376 into main Nov 19, 2021
@TomasVotruba
Copy link
Member

Thank you 👍

@TomasVotruba TomasVotruba deleted the json-crash branch November 19, 2021 08:50
@TomasVotruba
Copy link
Member

Thank you 👍

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