Closed dmason30 closed 2 years ago
Running any one of these commands:
php artisan tinker --execute="optional('foo', fn($v) => dump($v));" php artisan tinker --execute="transform('foo', fn($v) => dump($v));" php artisan tinker --execute="tap('foo', fn($v) => dump($v));" php artisan tinker --execute="with('foo', fn($v) => dump($v));" php artisan tinker --execute="optional('foo', function ($v) { dump($v); });" php artisan tinker --execute="transform('foo', function ($v) { dump($v); });" php artisan tinker --execute="tap('foo', function ($v) { dump($v); });" php artisan tinker --execute="with('foo', function ($v) { dump($v); });"
Produces this error
TypeError: Too few arguments to function dump(), 0 passed in /Users/danmason/PhpstormProjects/xxxeval()'d code on line 2 and exactly 1 expected
Running the same functions in PsySh works as expected
$ php artisan tinker Psy Shell v0.11.2 (PHP 8.1.4 — cli) by Justin Hileman >>> optional('foo', fn($v) => dump($v)); "foo" => "foo" >>> transform('foo', fn($v) => dump($v)); "foo" => "foo" >>> tap('foo', fn($v) => dump($v)); "foo" => "foo" >>> with('foo', fn($v) => dump($v)) "foo" => "foo"
You need to escape the $ sign when running this in the CLI:
$
$ php artisan tinker --execute="optional('foo', fn(\$v) => dump(\$v));" "foo"
Steps To Reproduce:
Running any one of these commands:
Produces this error
TypeError: Too few arguments to function dump(), 0 passed in /Users/danmason/PhpstormProjects/xxxeval()'d code on line 2 and exactly 1 expected
Running the same functions in PsySh works as expected