Closed (won't fix)
Project:
Drupal Code Sniffer
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jun 2012 at 14:50 UTC
Updated:
22 Jun 2012 at 16:16 UTC
As of PHP 5.3, the ternary operator can be shortened to just ?:, as documented at http://us2.php.net/ternary#language.operators.comparison.ternary:
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.
However, the code sniffer returns two errors when this operator is used:
ERROR: An operator statement must be followed by a single space
ERROR: There must be a single space before an operator statement
Comments
Comment #1
klausiI would still say that there should be a space between "?" and ":", which works fine, too.