Skip to content

Conversation

IMSoP
Copy link
Contributor

@IMSoP IMSoP commented Apr 23, 2023

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant