On Sat, Sep 21, 2019 at 11:56 AM Kosit Supanyo <webdevxp....@gmail.com> wrote:
> Hi Internals > > I'm working on my new proposals and I've found weirdness of global variable > declaration in zend_language_parser.y. > > global_var: > simple_variable > { $$ = zend_ast_create(ZEND_AST_GLOBAL, > zend_ast_create(ZEND_AST_VAR, $1)); } > ; > > Above grammer allows something like this... > > global $$x; > global $$$y; > global $$$$z; > global ${'abc'}; > global $$$$$$$$$${random_int(0, PHP_INT_MAX)}; > > What's the propose of allowing this? And is there anyone out there knowing > and using it? If not, should this be changed to allow only T_VARIABLE to > make it consistent with `static` variable declaration? > > Regards > Some grep results: sources/adodb/adodb-php/session/adodb-session.php 676: global $$var; 697: global $$var; sources/adodb/adodb-php/session/adodb-session2.php 719: global $$var; 740: global $$var; sources/adodb/adodb-php/session/old/adodb-cryptsession.php 189: global $$var; sources/adodb/adodb-php/session/old/adodb-session.php 300: global $$var; sources/adodb/adodb-php/session/old/adodb-session-clob.php 269: global $$var; sources/wp-cli/wp-cli/php/WP_CLI/Runner.php 1177: global ${$key}; sources/apache/log4php/src/main/php/pattern/LoggerPatternConverterSuperglobal.php 71: global ${$this->name}; We could deprecate this in favor of $GLOBALS, though as Dan said, the motivation is not quite clear right now. Nikita