bobthecow/psysh

Illegal [,] is allowed in psysh

Closed this issue · 5 comments

Hi, the following sentence is allowed in psysh but disallowed in php -a:

$a = [,];

In php 7.3.0, it will give an error that

php > $a = [,];
PHP Fatal error:  Cannot use empty array elements in arrays in php shell code on line 1

Fatal error: Cannot use empty array elements in arrays in php shell code on line 1

Is this supported in PHP 7.3?

Sorry, I meant 7.2.

Same error in PHP 7.2.

I think the underlying issue is likely with PHP-Parser. It parses $a = [,]; without complaint, which means, after we write the AST back to PHP, we don't have an invalid array anymore:

screen shot 2018-12-20 at 7 10 29 pm

I see. Perhaps there are also similar trialing comma problems in PHP-Parser and tolerant-PHP-Parser php/php-langspec#229

I will submit PRs about that to PHP-parser before Christmas, then we can see whether the problem is fixed by a simple update.

Since this is an issue in PHP-Parser, closing this one in favor of nikic/PHP-Parser#561 :)