Re: [VOTE] Support Closures in constant expressions
| From: | Juliette Reinders Folmer | Date: | Wed, 27 Nov 2024 22:05:18 +0000 |
| Subject: | Re: [VOTE] Support Closures in constant expressions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126076@lists.php.net to get a copy of this message | ||
On 27-11-2024 22:58, Tim Düsterhus wrote:
Hi On 11/27/24 22:50, Juliette Reinders Folmer wrote:Thanks for the clarification. Might be good to mention this in the documentation eventually.One thing I'm wondering about - and of which I saw no mention in the RFC nor in the preceding discussion - knowing that function names are case-insensitive, how is ambiguity handled when _calling_ a callback stored in a (class) constant ?Nothing changed about the grammar or the way a PHP program is parsed into Opcodes. As mentioned in the RFC it does not include any backwards incompatible changes, except for making some illegal PHP programs legal. In fact you are already able to store Closures in dynamic constants defined with thedefine()function (https://3v4l.org/u7ZJ1). In any case that means that all your examples are interpreted as function calls. You need parentheses around the constant name to "dereference" the value stored in the constant. This is consistent with $obj->foo() always being a method call to the foo() method, not a call to a Closure stored in a property called $foo. Best regards Tim Düsterhus