Re: [Vote] New in initializers
| From: | Nicolas Grekas | Date: | Tue, 06 Jul 2021 07:30:52 +0000 |
| Subject: | Re: [Vote] New in initializers | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115309@lists.php.net to get a copy of this message | ||
Hi NIkita,
I've opened voting on https://wiki.php.net/rfc/new_in_initializers.
Voting
> will close on 2021-07-14.
>
> Note that relative to the original RFC, new support is limited to parameter
> default values, attribute arguments, static variable initializers and
> global constant initializers, and not supported in property initializers
> and class constant initializers. The discussion thread
> https://externals.io/message/113347 has some extensive
> information on how
> we got here.
>
I voted yes and I'm happy this will come to PHP.
I realized I still have one concern that I want to share here, related to
attributes:
The RFC breaks the possibility to parse the arguments of an attribute in a
generic and safe way.
What I mean is that right now, attributes can be inspected while the
corresponding classes are not installed, due eg to a missing optional
dependency.
This behavior is what makes attributes truly declarative: one can ignore
what they don't care about. Extra semantics can be carried out by classes
without making the related attributes a mandatory dependency.
I think there is a way to preserve this behavior and that we should look
for it.
If I may propose one: we might add a new
ReflectionAttribute::getUninitializedArguments() method, that would return
the same as ReflectionAttribute::getArguments(), except that it would put a
ReflectionAttribute (or similar) instance in place of objects in the data
structure. As a corollary, we might also want to enforce that only child
classes of the Attribute class can be nested inside another Attribute (at
least if we want to reuse ReflectionAttribute as a placeholder.)
WDYT?
Nicolas