You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attribute classsynopsis: simplified #[\Attribute] vs full targets #5849
All attribute class pages show #[\Attribute] in their classsynopsis (added in #5067). This is the shorthand form, which in PHP compiles to #[\Attribute(Attribute::TARGET_ALL)], meaning the attribute can be applied anywhere.
The actual declarations in the PHP stubs are more restrictive:
A reader who treats the classsynopsis as valid PHP will conclude that #[Override] can be placed on a class or function, which is wrong.
Suggested improvement
Two options:
Full form: replace #[\Attribute] with the accurate target list from the stubs in each classsynopsis. Mirrors the source exactly, but requires updating doc-en each time PHP adds a target (e.g. Override gained TARGET_PROPERTY in PHP 8.5).
Prose note: keep #[\Attribute] in the classsynopsis and add a sentence in the description listing the valid targets. Lower maintenance, same accuracy.
Additional context
Related: #3897 (superseded by #5067, which adopted the simplified form without discussion of this tradeoff).
Activity
jordikroon commentedon Sep 11, 2026
This has been completed by #5631