[2.x] Handle all eval() failures from Laravel Tinker #829
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With Laravel Telescope and Laravel Tinker enabled in a project,
php artisan tinker
and attempt an expression that fatally fails PHP parsing.Instead of:
Try typing:
The desired output would be the below exception about the
foo
symbol missing$
.Instead the developer is shown an unrelated Laravel Telescope-related stacktrace:
because the watched
$exception->getFile()
is a human readable string instead of an actual PHP script file path.This change will show better output by looking for the
eval()
message string: https://github.com/php/php-src/blob/ac0853eb265784c4238af652de9c54c883ffa99f/Zend/zend_execute.c#L4157Trying the above example in an automated test won't work since the PHPUnit script exits immediately from the
eval()
failure. So I've added a case that best mimics how Laravel Tinker / PsySH treateval()
raisingParseError
. https://github.com/bobthecow/psysh/blob/29670a13ff363aa83df889d297fc23527a75cfe4/src/ExecutionLoopClosure.php#L95