Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81047 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67568 invoked from network); 23 Jan 2015 17:58:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2015 17:58:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:36581] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/1F-25368-8AB82C45 for ; Fri, 23 Jan 2015 12:58:00 -0500 Received: by mail-wi0-f177.google.com with SMTP id r20so4532094wiv.4 for ; Fri, 23 Jan 2015 09:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=rQr3lCaPvn0KAprW2fEazpH4Bi8BeKkwZ9cr424pWTw=; b=XQm8cxKLyXSw/4heTIcs3bZ60YUjgieV4REYulT4ePaZ7KC3CWP6VUIJ8j/vMpt8pn tukhp8M4h6r2pPQcHraDQeOeDUTOpvzNSqumW3bt6wlwRIuo8WWFjWGKMjlFRdYC72eM i3dechfGNGJqJ9MrHi5rmyNOwN+vvnW45tX2qoi7moR/pbyrqPZSVm635ER5Kqln/D76 iljp/y5ooYY7f3GqOs/hbMDEm/rfDw0WV8d2KhPOQ7JNSYZuZGP6a0DR9/j4wx5dOhH5 Qety3ttgZAfv6U4EkHz+9vdEiexr5uulO1EJNig2sonaRK8lschC9Yh44ttYNouxcvDD VdRg== X-Received: by 10.180.198.240 with SMTP id jf16mr5909420wic.27.1422035876432; Fri, 23 Jan 2015 09:57:56 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id h2sm2760266wix.5.2015.01.23.09.57.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 09:57:55 -0800 (PST) Message-ID: <54C28B63.1040506@gmail.com> Date: Fri, 23 Jan 2015 17:56:51 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <54BEC072.5000507@mabe.berlin> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Inconsistencies in callable, call_user_func and direct variable calls From: rowan.collins@gmail.com (Rowan Collins) Andrea Faulds wrote on 23/01/2015 14:37: > Hey Nikita, > >> On 20 Jan 2015, at 21:46, Nikita Popov wrote: >> >> On Tue, Jan 20, 2015 at 9:54 PM, Marc Bennewitz wrote: >> >>> valid for call_user_func[_array] and callable type-hint but invalid for >>> for direct variable calls: >>> - string "MyClass::staticFunc" >>> - string "self::staticFunc" >>> - string "static::staticFunc" >>> - string "parent::func" >>> - string "parent::staticFunc" >>> >>> see http://3v4l.org/1oSO3 >>> >>> Thoughts ? >>> >> I would prefer deprecating this alternative notation instead of adding more >> support for it. The [$class, $method] form is the canonical form we support >> everywhere and which is consistent with the [$obj, $method] callbacks. >> There's no point supporting another alternative notation, especially if it >> was effectively unusable for a while now already. > By the way, this notation is also used by constant() and defined(): > > $ php -r 'class Foo { const FOO = 3; } var_dump(constant("Foo::FOO"), defined("Foo::FOO"));' > int(3) > bool(true) > > It’s also very intuitive compared to the function syntax. I see no reason we shouldn’t support it more widely. +1 on this being more intuitive syntax, although the array syntax is convenient for dynamically selecting each part separately, and obviously for calling non-static methods. It actually feels kind of weird that as of PHP 7, an array is more callable than a string: class Foo { static function bar() { echo 'Hello'; } } Foo::bar(); // OK ['Foo', 'bar'](); // OK 'Foo::bar'(); // FATAL ERROR http://3v4l.org/f7rvc Regards, -- Rowan Collins [IMSoP]