Re: RFC: Support Closures in constant expressions

From: Date: Mon, 04 Nov 2024 11:48:49 +0000
Subject: Re: RFC: Support Closures in constant expressions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-125898@lists.php.net to get a copy of this message
Hi Am 2024-10-30 13:06, schrieb Rob Landers:
This looks interesting, but I notice it says that the closure can access “private properties”:
This means that Closures in property default values may access private properties, methods, and class constants of the class where they are defined
I assume this means private *static* properties since it couldn’t be attached/bound to a specific instance? (Must be static?)
No: All properties. An object of the class could be passed as a parameter to the Closure and then the Closure would be able to access private properties of that object. See Zend/tests/closure_const_expr/property_initializer_scope_001.phpt in the PR for an example. Best regards Tim Düsterhus

« previous php.internals (#125898) next »