Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.6.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)    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 33 + 11 = ?

 [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 --------------------------------------------------------------------------------


 [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: 12af6e1719db8308