Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107277 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77460 invoked from network); 21 Sep 2019 13:20:14 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 21 Sep 2019 13:20:14 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id AE20F2D201A for ; Sat, 21 Sep 2019 03:58:22 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Sat, 21 Sep 2019 03:58:22 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id k32so8344424otc.4 for ; Sat, 21 Sep 2019 03:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eVWRtgWkWWc8A2wasbhi8qTg/0teD4yEfgQNlfrdDc0=; b=oh+GaDVY9Hx+pGQFMWusMV06dXRlz0Dsf9AhQ8FoffU1RnB9JlHXFxQNHGf47ZBkBE six1eryAuwO49EtBQ5x59FsW1gSP3lFQkiVJaQEm07Modw1q1AQ3i6Vs1sKgmcK8b2lP vgx+ja9dcT9FNYTmJ2i58TUBNv9gCOqFznL7us8BVQ71mmovAStZ5DBo0qTBJgjfvjI+ ED/O55m73yF4bAJgZPzMTYYejyf3sZeqQ/z6eKQcLmTgyXGgFHgHz1+zfZY6v2n+xJws 0OENGSXu2bFpX47YLvpNsvLI98lDC0e0iaAZwm83BBNnK0XSrpUQ7OT9d0rAX7WV8hik nTDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eVWRtgWkWWc8A2wasbhi8qTg/0teD4yEfgQNlfrdDc0=; b=AyJQLnHdy8GNLFWZZ9FOkW4gNIlEujxySxkS5E3FLEfkMBGNlHs/MGE+RZt5pXfD3G j/atkk6LwD/aKFnJtL5tN+HWSK7hjs8tIFAmTifAckzUHeGIr67Hk796ynaDRs4Xnezw nFudaF4xqAPlzIoyBpRLZ7CYJouYAsN5iuNDtqSu8/xz6UL5Wa6eLJ1M5zjngSiaZYSg 7LLH7XkRputIJup1W69kfE0wz079idMBqJ6N2kk24dwy6a3tdPyWIVRGKt4RPF1XI8SO jpQqoVC93iEch2Z4/cGrcnL0EP7bwvivxN1aOXG4ayeYDPCghT92jpAuDBceFk2WOc+q krTA== X-Gm-Message-State: APjAAAXjJGJp3HpfdSVWZ3AAQQwNpQGJy//BDdUaHH5W6M3y1K6/Ac/8 qT8e1oUiM3gDJ49z9MsqChXFfGP3vNoLCCRy9mw= X-Google-Smtp-Source: APXvYqzUpW05InXHcx0AAMI+QTJYSuMMifJ2v/pbE1E7NkRclOb+28OBwHhxI5SAz9/5knL64JA4ns4sVp6CJN5bKp0= X-Received: by 2002:a9d:3a5:: with SMTP id f34mr15485081otf.4.1569063501925; Sat, 21 Sep 2019 03:58:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 21 Sep 2019 17:58:10 +0700 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000a9939305930e1050" X-Envelope-From: Subject: Re: [PHP-DEV] Question about `global` variable declaration From: webdevxp.com@gmail.com (Kosit Supanyo) --000000000000a9939305930e1050 Content-Type: text/plain; charset="UTF-8" Hi Dan and Internals Sorry Dan, I forgot to include @Internals in previous reply so let me resend this again. Thank you for your reply. I see, but in that case it can be done with `$GLOBALS['abc']` right? So I don't see any benefits of allowing those forms, they're just another inconsistency that should not exist from the beginning. Yes, it does no harms but if nobody is really using it at all, is it good to remove this inconsistency? Or to make it really useful, why not just allow assignment like: global ${'abc'} = $someValue; Just my 2 cents. Regards On Sat, Sep 21, 2019 at 5:52 PM Nikita Popov wrote: > On Sat, Sep 21, 2019 at 11:56 AM Kosit Supanyo > 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 > --000000000000a9939305930e1050--