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

Bug #20026 Check for multi-line arrays that should be single-line is slightly wrong
Submitted: 2013-08-01 19:20 UTC
From: konafets Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.6)
PHP Version: 5.4.17 OS: OSX 10.8.4
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 : 49 + 22 = ?

 
 [2013-08-01 19:20 UTC] konafets (Stefano Kowalke)
Description: ------------ The ArrayDeclarationSniff checks to proper declaration of arrays. There is a check which suppose detect arrays with just one element which are written as a multi-line array. The follow multi-line array: $c = array( 'a' => 1, ); could be written in a single line: $c = array('a' => 1,); The problem here is that the sniff takes the trailing comma as the proof for a single line array and mark even the obviously single line array as a violation until you remove the comma - then it passes the test.

Comments

 [2013-08-08 07:45 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fixed in github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/cdbf8faa5b8a65e7f371d820ad2 759d51d20ad2f A new error message has been added for this case. There should not be a comma at the end of a single-line array. It is only required at the end of a multi-line array.