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

Bug #18274 Multi-line IF and function call indent rules conflict
Submitted: 2011-02-14 21:27 UTC
From: djuarez Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.2.2)
PHP Version: 5.3.1 OS: Ubuntu 10.04
Roadmaps: (Not assigned)    
Subscription  


 [2011-02-14 21:27 UTC] djuarez (djuarez djuarez)
Description: ------------ When I put the line 12 indented 24 spaces tells me "12 | ERROR | Multi-line IF statement indented Not Correctly, expectations 20 | | But spaces found 24 " When I put the line 12 indented 20 spaces tells me "12 | ERROR | Each line in a multi-line IF statement Must begin with a boolean | | operator 12 | BUG | Multi-line function call indented Not Correctly, expectations 24 | | But spaces found 20 " Test script: --------------- function test() { if ($b == 1) { if ($b == 1) { if (isset ($aChecked[$service->sev_id])) { if (array_key_exists($service->sev_id, $aChecked) && array_key_exists( $service->ssv_id, $aChecked[$service->sev_id] ) ) { //more } } } } } Expected result: ---------------- I hope to validate when I have the line 12 indented 24 spaces Actual result: -------------- 12 | ERROR | Multi-line IF statement not indented correctly; expected 20 | | spaces but found 24 12 | ERROR | Each line in a multi-line IF statement must begin with a boolean | | operator

Comments

 [2011-02-15 10:22 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
The problem here is that two sniffs are competing. Multi-line IF statements must be aligned the same for each line, but you happen to have a multi-line function call inside a multi-line IF statement. In this case, the indent should be 24 spaces and the IF statement sniff needs to know to ignore lines that are inside nested function calls. I will make the required changes.
 [2011-02-15 10:44 UTC] squiz (Greg Sherwood)
-Summary: Indentation error +Summary: Multi-line IF and function call indent rules conflict
 [2011-02-15 10:45 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.