PHP 5.6 / 8.0: NewConstantDereferencing: add support for constant array / object dereferencing by elazar · Pull Request #1263 · PHPCompatibility/PHPCompatibility

@elazar

…ay / object dereferencing

> This RFC brings static scalar expressions to the parser. This allows places that only take static values (const declarations, ... etc) to also be able to take static expressions.

> Constants... are currently special cased and only dereferencable under the `[]` operator (and do not even support the nominally equivalent `{}` operator).
>
> This RFC proposes to make constants (and class constants) fully array and object dereferencable, i.e. to allow both `FOO{0}` and `FOO->length()` (the latter only being relevant in conjunction with scalar objects).

Ref:
* https://wiki.php.net/rfc/const_scalar_exprs
* php/php-src@d5ddd2d
* https://wiki.php.net/rfc/variable_syntax_tweaks#constant_dereferencability

Includes unit tests.

Relates to PHPCompatibility#809.

@jrfnl mentioned this pull request

Jan 28, 2021

@elazar

@jrfnl jrfnl mentioned this pull request

Mar 3, 2021

40 tasks

@elazar