On Sat, May 2, 2020 at 5:57 PM Niklas Keller <m...@kelunik.com> wrote:

> Hey Benas,
>
> a question has come up whether we even need the PhpAttribute /
> Attribute attribute at all. We could prevent any conflict if we just
> delete it.
>
> Best,
> Niklas
>

We need Attribute so static analysis tooling and IDEs can check whether a
class is intended to be used as an attribute. I believe there are also
plans to extend this functionality to allow specifying more constraints,
such as which elements the attribute may target and whether it can appear
multiple times.

All of these things can be implemented in code, but having them encoded as
(attribute) metadata makes the information accessible to introspection and
tooling.

Nikita


> Am Di., 28. Apr. 2020 um 17:37 Uhr schrieb Benas IML
> <benas.molis....@gmail.com>:
> >
> > Hey internals,
> >
> > Since it's safe to say that the Attributes v2 RFC has passed, I wanted to
> > make a separate thread based on the comment by Rowan Tommins in the PHP
> > namespace policy thread. This is a quote from his comment:
> >
> > > One prefix doesn't make a trend. "PhpToken" is a different case - it's
> a
> > > token of PHP source code, so the prefix isn't anything to do with
> > > avoiding name collisions, it's a natural clarification.
> > >
> > > To be honest, I'd be perfectly happy with the attributes RFC using the
> > > class name "Attribute", just as we use "Iterator", "Closure",
> > > "Exception", etc, etc. At which point the whole thing's a non-issue.
> >
> > I do strongly agree with him and I believe we should rename
> `\PhpAttribute`
> > to simply `\Attribute` before the PHP 8 release in order to improve
> > consistency with other classes and interfaces e. g. Iterator,
> ArrayAccess,
> > Countable. It would also make the attribute class definition look more
> > aesthetically pleasing:
> >
> > ```
> > <?php
> > <<Attribute>>
> > class Test {}
> > ```
> >
> > I am ready to make an RFC for this if the replies are mostly positive, so
> > please, express your opinions!
> >
> > Best regards,
> > Benas Seliuginas
> > P.S: this is my second email account so hopefully it won't get marked as
> > spam.
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to