laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.32k stars 130 forks source link

Tinker close with error after using [] #93

Closed cozilic closed 4 years ago

cozilic commented 4 years ago

Description:

Getting "Symfony\Component\ErrorHandler\Error\FatalError" when using only one command.

Steps To Reproduce:

open tinker, write

$user[] press enter

$user[]

Symfony\Component\ErrorHandler\Error\FatalError

Cannot use [] for reading

at C:\laragon\www\Woodchuck\vendor\psy\psysh\src\ExecutionLoopClosure.php:55 51| // Convert all errors to exceptions 52| \set_error_handler([$psysh, 'handleError']); 53| 54| // Evaluate the current code buffer

55| $_ = eval($psysh->onExecute($psysh->flushCode() ?: ExecutionClosure::NOOP_INPUT)); 56| } catch (\Throwable $_e) { 57| // Clean up on our way out. 58| \restore_error_handler(); 59| if (\ob_get_level() > 0) {

Whoops\Exception\ErrorException

Cannot use [] for reading

at C:\laragon\www\Woodchuck\vendor\psy\psysh\src\ExecutionLoopClosure.php:55 51| // Convert all errors to exceptions 52| \set_error_handler([$psysh, 'handleError']); 53| 54| // Evaluate the current code buffer

55| $_ = eval($psysh->onExecute($psysh->flushCode() ?: ExecutionClosure::NOOP_INPUT)); 56| } catch (\Throwable $_e) { 57| // Clean up on our way out. 58| \restore_error_handler(); 59| if (\ob_get_level() > 0) {

1 C:\laragon\www\Woodchuck\vendor\filp\whoops\src\Whoops\Run.php:408 Whoops\Run::handleError("Cannot use [] for reading", "C:\laragon\www\Woodchuck\vendor\psy\psysh\src\ExecutionLoopClosure.php(55) : eval()'d code")

2 [internal]:0 Whoops\Run::handleShutdown()

bobthecow commented 4 years ago

The error message is right. You can't use [] for reading. If you call $foo[] outside of the left hand side of an assignment, it's a fatal error.

In this case, PsySH (the underlying library in Tinker) should have caught this and prevented it from closing though. This is now fixed in https://github.com/bobthecow/psysh/commit/ba7e315cf26389e8c111b6179aa814c3feb7e833 🙂

GrahamCampbell commented 4 years ago

Thanks @bobthecow. Can we expect the stuff on the develop branch to be released soon? Anything I can do to help?

bobthecow commented 4 years ago

https://github.com/bobthecow/psysh/releases/tag/v0.10.0 👀