laravel/tinker

Tinker close with error after using []

cozilic opened this issue · 3 comments

  • Tinker Version: 0.9.12
  • Laravel Version: 7.0.4
  • PHP Version: 7.2.19
  • Database Driver & Version:

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()

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 bobthecow/psysh@ba7e315 🙂

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