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

Bug #20213 Invalid error, Inline IF must be declared on single line.
Submitted: 2014-03-05 20:03 UTC
From: adrian_crepaz Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.2)
PHP Version: 5.5.3 OS: Mac OS X - MAMP
Roadmaps: (Not assigned)    

 [2014-03-05 20:03 UTC] adrian_crepaz (Adrian Crepaz)
Description: ------------ When running a CodeSniffer test on the Test Script below, I'm getting the error.. "Inline shorthand IF statement must be declared on a single line". As you can see, the inline IF on line 7 is valid and is contained on one line. Surrounding the whole IF statement in brackets skips the error. I've tried the same statement but assigned to a variable, this is fine. CodeSniffer doesn't report any errors. This seems to only happen when in arrays, as far as I've found. When using print_r() on the Token, it seems to be referring to the bracket ( on line 5. Test script: --------------- <?php $test = 1; $array = array( 'one' => 'one', 'two' => ($test == 1) ? true : false, 'three' => 'three' ); var_dump($array); $array = array( 'one' => 'one', 'two' => (($test == 1) ? true : false), 'three' => 'three' ); var_dump($array); ?> Expected result: ---------------- No errors/warnings. Actual result: -------------- -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 7 | ERROR | Inline shorthand IF statement must be declared on a single line --------------------------------------------------------------------------------


 [2014-03-05 20:05 UTC] adrian_crepaz (Adrian Crepaz)
Using the Squiz Standard.
 [2014-03-06 11:30 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: dfa2a884e8f2a2