Hey,

 

> if you are not going to call ReflectionAttribute::newInstance(), then you 
> don't
> really need to mark the trait/interface/enum/abstract class as an attribute.

 

Personally I never knew the `#[\Attribute]` is only required to do 
`->newInstance()`.

 

The docs make it seem like it’s a boilerplate to have an attribute at all: 
https://www.php.net/manual/en/language.attributes.overview.php

And the documented example does not call `newInstance` although the attribute 
is defined with `#[Attribute]`.

 

I’m also confused as the example created by Ilija 
https://3v4l.org/8Lih3#v8.4.10 that would supposedly break does not include 
`#[Attribute]` at all. But it includes an enum being used as attribute without 
it using the label itself. So what would actually break? Using enums as 
attributes or declaring them as such?

 

Btw while reviewing the docs 
https://www.php.net/manual/en/language.attributes.classes.php 

I noticed that

 

> It is recommended to define a separate class for each attribute.

 

Recommended as opposed to what other options? I don’t think I can use a random 
string as an attribute without defining it, right? So what is this 
recommendation steering me away from?

 

BR,

Juris

Reply via email to