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

Bug #19687 Anonymous functions inside arrays marked as indented incorrectly in PSR2
Submitted: 2012-10-31 23:48 UTC
From: valorin Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.4.6 OS: Ubuntu 12.10
Roadmaps: (Not assigned)    
Subscription  


 [2012-10-31 23:48 UTC] valorin (Stephen Rees-Carter)
Description: ------------ Anonymous functions that are nested within an Array within a Function are incorrectly marked as having the wrong indentation in the PSR2 standard. I've tested with the latest commit from GitHub (2b1adc7). Test script: --------------- <?php namespace Testing; class AnonymousFn { public function getAnonFn() { return array( 'functions' => Array( 'function1' => function ($a, $b, $c) { $a = $b + $c; $b = $c / 2; return Array($a, $b, $c); }, ), ); } } Expected result: ---------------- There should be no coding violations reported for this code. Actual result: -------------- valorin@gandalf:~/workspace/$ php ./vendor/PHP_CodeSniffer/scripts/phpcs -- standard=PSR2 ./AnonymousFn.php FILE: /home/valorin/workspace/AnonymousFn.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 10 | ERROR | Line indented incorrectly; expected 8 spaces, found 16 --------------------------------------------------------------------------------

Comments

 [2012-11-01 01:59 UTC] squiz (Greg Sherwood)
-Summary: Anonymous functions marked as indented incorrectly in PSR2 +Summary: Anonymous functions inside arrays marked as indented incorrectly in PSR2 -Assigned To: +Assigned To: squiz
 [2012-11-01 02:01 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fixed in github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/20ea734e1a1689a8ea581068 12af6e1719db8308