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

Reply via email to