Skip to content
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

PHP 8.0 | PEAR/FunctionComment: prevent false positives with attributes #3396

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Jul 23, 2021

PHP 8.0+ attributes can be placed between a docblock and the function declaration it applies to.

The PEAR.Commenting.FunctionComment sniff - and by extension the Squiz.Commenting.FunctionComment sniff - did not yet take this into account.

This would result in a false positive Missing doc comment for function ... error.

Resolving that error though, would result in a new There must be no blank lines after the function comment error, so the blank line check also needed to be fixed.

With the current fix, blank lines between the docblock and the function declaration are still not allowed, but non-blank lines between the two (i.e. lines containing attributes) will be ignored.

Only one "no blank lines between" error will be thrown per function declaration.

PHP 8.0+ attributes can be placed between a docblock and the function declaration it applies to.

The `PEAR.Commenting.FunctionComment` sniff - and by extension the `Squiz.Commenting.FunctionComment` sniff - did not yet take this into account.

This would result in a false positive `Missing doc comment for function ... ` error.

Resolving that error though, would result in a new `There must be no blank lines after the function comment` error, so the blank line check also needed to be fixed.

With the current fix, blank lines between the docblock and the function declaration are still not allowed, but non-blank lines between the two (i.e. lines containing attributes) will be ignored.

Only one "no blank lines between" error will be thrown per function declaration.
@jrfnl jrfnl changed the title PEAR/FunctionComment: prevent false positives with attributes PHP 8.0 | PEAR/FunctionComment: prevent false positives with attributes Jul 23, 2021
@gsherwood gsherwood added this to the 3.6.1 milestone Jul 28, 2021
@gsherwood gsherwood merged commit 6c0437b into squizlabs:master Jul 29, 2021
@gsherwood
Copy link
Member

Thanks for fixing this

@jrfnl jrfnl deleted the php-8.0/pear-functioncomment-support-attributes branch July 29, 2021 08:53
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants