-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PSR2 standard is not checking that closing brace is on line following the body #908
Comments
|
Hi @aik099
plus providing an example. 2 & 3. I'm just referring to the bold/italic formatted text. |
I think you are half right here. The bold text refers to the parenthesis, not the braces. It is trying to ban code like this: <?php
public function some_function( $foo, $bar )
{
} With that code, you get these errors:
So the rules inside the bold text are already checked, but by a different sniff. There is also nothing in that rule that says that the body of the method must go on the line directly after the opening brace. In PSR2, you can have as much whitespace at the top of your functions as you'd like. Yes, I think this is crazy. No, I didn't make the rules. But where I think you are very right is that the rule says that you can't have empty lines at the end of a function because the closing brace must go on the next line after the body. I think that is pretty clear and I should add both a check and an auto-fix for that. Thanks for reporting it. |
I finally got around to adding a sniff to check and fix extra blank lines at the end of functions/methods/closures. |
From php-fig
So based on the definition above a function/method like this:
should be converted to this (e.g. stripping spaces and linebreaks in the body between the parenthesis and the first/last occurrence of a code block/comment).
The text was updated successfully, but these errors were encountered: