[php-src] PR #11123: [RFC] Implement Property Capture for Anonymous Classes

From: Date: Sun, 23 Apr 2023 20:06:43 +0000
Subject: [php-src] PR #11123: [RFC] Implement Property Capture for Anonymous Classes
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-22372@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/11123 Author: IMSoP RFC: https://wiki.php.net/rfc/property-capture Adds a "use" clause to anonymous class declarations, which allows capturing local variables by declaring them as properties in the class definition, and passing them into the constructor of each instance. A new AST kind is used to track the list of properties to add and their modifiers (visibility, type, readonly, reference). This is then transformed into a constructor during compilation, piggy-backing on the implementation of Constructor Property Promotion, but using custom error messages and reflectable flags, so that a future implementation could work differently if necessary.

« previous php.git-pulls (#22372) next »