Skip to content

[Php73] Handle crash Type Error on JsonThrowOnErrorRector#4626

Merged
samsonasik merged 3 commits intomainfrom
crash-type-error
Aug 1, 2023
Merged

[Php73] Handle crash Type Error on JsonThrowOnErrorRector#4626
samsonasik merged 3 commits intomainfrom
crash-type-error

Conversation

@samsonasik
Copy link
Copy Markdown
Member

Given the following code:

class SkipWithConstant
{
    private const MIN_DELAY = 1000;

    private const MAX_DELAY = self::MIN_DELAY * 60 * 10;

    public function getWaitingTime(): int
    {
        return min(self::MAX_DELAY, 0);
    }
}

It currently produce error:

There was 1 error:

1) Rector\Tests\Php73\Rector\FuncCall\JsonThrowOnErrorRector\JsonThrowOnErrorRectorTest::test with data set #7
TypeError: Unsupported operand types: string * int

/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php:131
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php:204
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php:131
/Users/samsonasik/www/rector-src/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php:101

This PR try to fix it.
Fixes rectorphp/rector#8102

@samsonasik
Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @buffcode

@samsonasik
Copy link
Copy Markdown
Member Author

Github seems down, pending show new commit

@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 0cb3fd0 into main Aug 1, 2023
@samsonasik samsonasik deleted the crash-type-error branch August 1, 2023 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

JsonThrowOnErrorRector fails to parse file

1 participant