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

Bug #19655 Closures reporting as multi-line when they are not
Submitted: 2012-10-17 18:32 UTC
From: gnutix Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.0)
PHP Version: Irrelevant OS: Archlinux
Roadmaps: (Not assigned)    
Subscription  
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:
MUST BE VALID
Solve the problem : 46 - 31 = ?

 
 [2012-10-17 18:32 UTC] gnutix (Dorian Villet)
Description: ------------ When using for example a callback function with multiple parameters in a "function call on multiple lines", the comma used to separate the callback function parameters is interpreted as a "main function parameter separator". This produce the error "Commas in multi-line function declarations must be the last content on a line", even though it should not. Test script: --------------- <?php // foo.php $data = array('foo', 'bar', 'baz'); usort( $data, function ($a, $b) { // body } ); Expected result: ---------------- $ phpcs foo.php --standard=PSR2 Time: 0 seconds, Memory: 4.25Mb Actual result: -------------- $ phpcs foo.php --standard=PSR2 FILE: /home/lamp/foo.php ------------------------------------------------------------------------ -------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) ------------------------------------------------------------------------ -------- 5 | ERROR | Commas in multi-line function declarations must be the last content on a line ------------------------------------------------------------------------ -------- Time: 0 seconds, Memory: 4.25Mb

Comments

 [2012-10-23 09:39 UTC] triplepoint (Jonathan Hanson)
I've got a fix prepared for this bug: https://github.com/squizlabs/PHP_CodeSniffer/pull/64 Not sure how this project is managing pull requests (github vs pear). Feel free to offer guidance.
 [2012-10-26 08:02 UTC] squiz (Greg Sherwood)
-Summary: [PSR2] "Commas in multi-line function declaration..." error that should not be +Summary: Closures reporting as multi-line when they are not -Assigned To: +Assigned To: squiz
 [2012-10-26 08:17 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Fixed in github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/53696950ac850628d90c217a0 5ba2565dd380b0f
 [2012-10-26 11:40 UTC] gnutix (Dorian Villet)
Thanks a lot for your hard work guys ! :)