CakePHP.WhiteSpace.FunctionSpacing should recognize comments
1 public function foo(): void {
2 //blah
3 }
4
5 // here's a comment
6 public function bar(): void {
7 //blah
8 }
The above produces an error:
6 | ERROR | [x] Every function/method needs a newline before (CakePHP.WhiteSpace.FunctionSpacing.Concrete)
Line 4 is a newline, which, IMO, satisfies the sniff requirement. The sniff is not paying attention to the fact that just above is a comment, and above that comment is a new line.
Changing line 5 to this /** here's a comment */ passes the sniff. Why does one comment style pass and the other does not? Both are perfectly valid php comments.
I have this rule disabled but am encountering a similar issue with CakePHP.Formatting.BlankLineBeforeReturn.BlankLineBeforeReturn. It is not recognizing comments if they are enabling / disabling / ignoring a specific phpcs rule.
/* No issues */
public function getFoo(): string
{
// something
return 'foo';
}
/* No issues */
public function getBar(): string
{
// phpcs:ignore
return 'bar';
}
/* Missing blank line before return statement */
public function getFoobar(): string
{
// phpcs:ignore Generic.Files.LineLength.TooLong
return 'foobar';
}