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

Bug #19675 Improper indent of nested anonymous function bodies in a call
Submitted: 2012-10-25 21:49 UTC
From: arlaneenalra Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.0)
PHP Version: 5.3.17 OS: Gentoo
Roadmaps: (Not assigned)    
Subscription  


 [2012-10-25 21:49 UTC] arlaneenalra (Chris Salch)
Description: ------------ The Generic WhiteSpace Indent sniffer is giving some very strange results for the body of a nested anonymous function declared as an argument to a function call. Test script: --------------- <?php $var = call_user_func( function () { $a = 1; $new_var = function () use (&$a) { if ($a > 0 ) { return $a++; } else { return $a--; } } return $new_var } ); Expected result: ---------------- No errors Actual result: -------------- -------------------------------------------------------------------------------- FOUND 4 ERROR(S) AFFECTING 4 LINE(S) -------------------------------------------------------------------------------- 7 | ERROR | Line indented incorrectly; expected 23 spaces, found 12 8 | ERROR | Line indented incorrectly; expected at least 27 spaces, found 16 9 | ERROR | Line indented incorrectly; expected 23 spaces, found 12 10 | ERROR | Line indented incorrectly; expected at least 27 spaces, found 16 --------------------------------------------------------------------------------

Comments

 [2012-10-25 21:53 UTC] arlaneenalra (Chris Salch)
Config used to cause the odd behavior: <?xml version="1.0"?> <ruleset name="Scope Indent issue"> <description>Scope Indent issue</description> <rule ref="Generic.WhiteSpace.ScopeIndent" /> </ruleset>
 [2012-10-29 09:07 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/920b8a6a3b1845a8e8d60325f 553d7d70a69672e Really clear bug report. Thanks a lot.