-
Notifications
You must be signed in to change notification settings - Fork 26
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
Require attributes be placed below docblocks #8
Comments
I've run into this parser issue as well. At its root it's a PHP-Parser bug, but even that aside it's the sort of arbitrary thing worth trying to standardize. |
I came across similar issue few times too. /** ... */
public $property;
/** ... */
#[Attribute] Also, maybe we could help to automate it with @rectorphp :) rectorphp/rector#7225 |
Just linking these together: |
Also it seems that the guide is not really clear how many lines of code are allowed between the attribute and the class. #[Attribute]
class Test
or
#[Attribute]
class Test |
The PR in #26 makes it clear that no blank line is permitted. |
To the best of my recollection in all of the code I've encountered, despite functioning correctly in either order, attributes are placed between any docblock and the target they apply to (class, method, etc). If you were to instead place attributes above the docblock, you'd encounter a nasty bug in any static analyser that relies on nikic's parser (eg phpstan): nikic/PHP-Parser#762. In my opinion, this PER should require a consistent order of docblock first, then attributes and finally the node.
The text was updated successfully, but these errors were encountered: