Docs: add a page about zend_attribute#18122
Docs: add a page about zend_attribute#18122DanielEScherzer wants to merge 1 commit intophp:masterfrom
Conversation
Work towards php#15954
iluuu1994
left a comment
There was a problem hiding this comment.
Thanks for working on this.
IMO, it would be useful to describe that zend_attribute is a compile-time concept. I.e. it refers to the lexical, static attribute in your source code, rather than an instance returned from reflection.
I also wonder whether it's necessary to describe each field. They are pretty self-explanatory with the exception of some, like offset.
Specifically, such explanations are not useful.
Where the
namefield stores the name used, and thezvalvaluefield stores the value.
Instead, it's likely possible to auto-link all references of zval in source code to the zval page.
| And are *not* the same as the flags in ``Attribute::$flags``. | ||
|
|
||
| ********** | ||
| metadata |
There was a problem hiding this comment.
The metadata and filename titles look wrong.
| The ``lineno`` field holds the line number that the attribute is used on, for use in error messages. | ||
|
|
||
| The ``offset`` field is only used for attributes on parameters, and indicates *which* parameter the | ||
| attribute is applied to (since the attributes for a function's parameters are all stored together). |
There was a problem hiding this comment.
Maybe mention that function attributes have offset 0, while args have offset 1+.
|
|
||
| The number of arguments that are passed to the attribute is stored in the ``argc`` field. But, since | ||
| attributes support the use of named parameters, storing just the parameters that were used is not | ||
| enough, the parameter names need to be stored too. |
There was a problem hiding this comment.
Maybe mention that value may contain constant expressions that are evaluated when creating an instance of the attribute. Meaning if you have #[MyAttr(new Foo)], new Foo will be performed for every $reflectionAttr->newInstance().
Work towards #15954