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  


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