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
Squiz/MemberVarSpacing: bug fix - handling of blank lines in pre-amble
The `Squiz.WhiteSpace.MemberVarSpacing` sniff intends to flag blank lines between a property docblock and the property declaration.
However, as things are, there are - IMO - two bugs in the logic for this:
Given a code block which looks like this:
```php
class MultipleBlankLinesInPreAmble {
/**
* Docblock.
*/
#[MyAttribute]
#[MyOtherAttribute]
public $prop;
}
```
There will be only one error and it will read:
```
[x] Expected 0 blank lines after member var comment; 6 found (Squiz.WhiteSpace.MemberVarSpacing.AfterComment)
```
This is confusing as there are not 6 blank lines between the end of the docblock and the property, but four blank lines and two attribute lines.
What I would expect would be for the sniff to:
a) Throw a separate error for each (set of) blank lines found.
b) For the error message to correctly reflect the number of blank lines found for each error.
> Note: while in PHPCS this gets confusing, the fixer already fixes this correctly.
This commit changes the `AfterComment` error to comply with the above expectations
Includes test, though there are also some pre-existing tests which show this issue and for which the behaviour is changed (error lines: 342 and 353).
_Note: while it will still be messy, it may be easier to review this PR while ignoring whitespace changes._
Fixes squizlabs/PHP_CodeSniffer 3594
0 commit comments