Closed rtucek closed 8 years ago
phpcs
run?phpcbf
run?Hi @aik099
stripping spaces and linebreaks in the body between the parenthesis and the first/last occurrence of a code block/comment
plus providing an example.
2 & 3. I'm just referring to the bold/italic formatted text.
There are no warnings/errors returned by phpcs
and no fixes done by phpcbf
in context of the emphasized sentence above. I believe there is no implementation (this is what I meant by 'not fully honoring').
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:
2 | ERROR | [x] Expected 0 spaces between opening bracket and argument "$foo"; 1 found
2 | ERROR | [x] Expected 0 spaces between argument "$bar" and closing bracket; 1 found
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).