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

Bug #19290 Generic indent sniffer fails for anonymous functions
Submitted: 2012-02-13 16:44 UTC
From: ashutosh108 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.2)
PHP Version: 5.3.3 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2012-02-13 16:44 UTC] ashutosh108 (Anton Voloshin)
Description: ------------ When I run phpcs --standard=Generic -- sniffs=Generic.WhiteSpace.ScopeIndent.Incorrect phpcs- test.php (with phpcs-test.php being the file from "Test script") I see error message about indent inside anonymous function: Line indented incorrectly; expected 4 spaces, found 8 Basically, phpcs suggests me to indent $a = 403; at 8 chars (I agree here) but indent the next line if ($a === 404) { at 4 chars. I think it's a bug. Note: Originally I came upon this using PEAR coding standard, but traced it towards the "Generic". When using Zend coding standard, this file gives no errors. I found similar closed bug https://pear.php.net/bugs/bug.php? id=18657 but this one is still reproducible in 1.3.2. Test script: --------------- <?php // test with e.g. phpcs --standard=Generic --sniffs=Generic.WhiteSpace.ScopeIndent.Incorrect phpcs-test.php some_function( function() { $a = 403; if ($a === 404) { } } ); Expected result: ---------------- I expect no errors reported, whitespace indenting in this file looks fine to me. Actual result: -------------- FILE: /home/HarekrRu/tmp-www/phpcs-test.php ------------------------------------------------------------------------ -------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) ------------------------------------------------------------------------ -------- 5 | ERROR | Line indented incorrectly; expected 4 spaces, found 8 ------------------------------------------------------------------------ -------- Time: 1 second, Memory: 2.50Mb

Comments

 [2012-02-22 05:55 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed in Git repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/53ec9ec0157c749bf92a566a8 8d1ffca4fc1e283