Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #19926 PSR2 - Incorrect sniff inherited from PEAR
Submitted: 2013-05-01 03:47 UTC
From: danizord Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.5)
PHP Version: 5.4.14 OS: Ubuntu 12.10 Quantal Quetzal
Roadmaps: (Not assigned)    
Subscription  


 [2013-05-01 03:47 UTC] danizord (Daniel Gimenes)
Description: ------------ 1) Opening parenthesis of a multi-line function call must be the last content on the line. 2) Closing parenthesis of a multi-line function call must be on a line by itself These 2 sniffs are not in the PSR2 standard and were inherited from PEAR

Comments

 [2013-05-01 06:38 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Bogus -Assigned To: +Assigned To: squiz
The sniff was not inherited from the PEAR standard; it was specifically selected so that it could implement part of the PSR2 standard. See the ruleset here: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/ PSR2/ruleset.xml#L133 Standards grab sniffs from other standards so they don't duplicate code. It's a core feature of PHP_CodeSniffer's standard implementation. The code may refer to PEAR, but that is only to allow you to see where the sniff exists and to let you override the error messages globally. If you want to see where all the sniffs are coming from to generate the PSR2 standard, run: phpcs -e --standard=PSR2 Only 9 of the 40 sniffs are actually PSR2-specific.
 [2013-05-01 07:09 UTC] danizord (Daniel Gimenes)
I got it, but this rule is not part of PSR-2 Standard. So this sniff need to be removed.
 [2013-05-01 10:06 UTC] squiz (Greg Sherwood)
Yes, it is part of the PSR-2 standard. https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style- guide.md#46-method-and-function-calls "Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line." Also look at the example code under that text.
 [2013-05-02 03:12 UTC] danizord (Daniel Gimenes)
I'm not talking about method declaration, but function call. See: $this->myFunction(array( 'test1', 'test2', )); OR throw new InvalidArgumentException(sprintf( '%s is invalid', $param )); This is valid in PSR-2
 [2013-05-02 04:23 UTC] squiz (Greg Sherwood)
If you visited the link I provided, you'll see that it points to section 4.6. Method and Function Calls of the PSR-2 standard. We're talking about the same thing. What you have is not valid as per that part of the standard. It clearly states that you MAY split your call over multiple lines (obviously when you arg list makes it necessary) and that if you do, you MUST start the first item on the next line. Please note that there is a section in the standard about method declarations which defines the exact same rule. These are different rules, but use almost the same text.
 [2013-05-02 20:19 UTC] danizord (Daniel Gimenes)
Oh! Now I got it, thanks!
 [2013-05-02 20:20 UTC] danizord (Daniel Gimenes)
-Status: Bogus +Status: Closed
 [2013-05-02 23:01 UTC] danizord (Daniel Gimenes)
-Status: Closed +Status: Open
See https://github.com/zendframework/zf2/issues/4390
 [2013-05-03 05:10 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
I've commented on the issue you submitted. There is no need to reopen this report. If the standard is clarified, I will make the changes to PHP_CodeSniffer without prompting. Thanks for linking the issue. It gave me a chance to comment somewhere it might be discussed more widely.