-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: add a page about zend_attribute #18122
base: master
Are you sure you want to change the base?
Conversation
Work towards php#15954
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
name
field stores the name used, and thezval
value
field 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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