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
Since version 3.12.0 PHP CodeSniffer complains about missing blank lines before a function.
You can see the minimalized code example below. There are clearly blank lines before the function.
Additionally it is the first function and due to the rule it also shouldn't complain. Also see discussion
Code sample
<?php/** * Description of file * * @package foo *//** * Description of function */functionfoo($x)
{
}
First of all thank you very much for this quick fix!
I can confirm that it is solved as reported...
but...
I've modified the code a bit and believe that there are still two wrong cases:
First:
<?php/** */functionfoo()
{
}
Second:
<?php/** */functionfoo()
{
}
In both cases PHPCodeSniffer complains about missing blank lines...
In the first case version 3.11.3 was fine with it!
For the second case version 3.11.3 also complains missing blank lines!
Which is wrong from my point of view because it is the first function in the file... See the rules...
@ahtux I think these last two are based on a misunderstanding of the spacingBeforeFirst and spacingAfterLast properties.
As per the documentation (emphasis mine):
The spacingBeforeFirst property is used to determine how many blank lines are required before a function when it is the first block of code inside a statement group or control structure. This property is ignored when the function is outside one of these scopes, or if the function is preceded by member vars. If this property has not been set, the sniff will use whatever value has been set for the spacing property.
The spacingAfterLast property is used to determine how many blank lines are required after a function when it is the last block of code inside a statement group or control structure. This property is ignored when the function is outside one of these scopes, or if any member vars are placed after the function. If this property has not been set, the sniff will use whatever value has been set for the spacing property.
Describe the bug
Since version 3.12.0 PHP CodeSniffer complains about missing blank lines before a function.
You can see the minimalized code example below. There are clearly blank lines before the function.
Additionally it is the first function and due to the rule it also shouldn't complain.
Also see discussion
Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
Expected behavior
With the code example CodeSniffer should not complain about missing blank lines.
Versions (please complete the following information)
Additional context
This behaviour ist since version 3.12.0!
With version 3.11.3 this was not an issue.
Please confirm
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: