PHP 5.3 introduced shorthand ternaries where the middle part can be left out.
Related PHPCompatibility sniff(s):
TernaryOperators
PHP manual references:
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.
Basically the sniff would need to verify that the part between the ? and the : is the same as the condition or true where the condition can only evaluate to a boolean.
Short description
PHP 5.3 introduced shorthand ternaries where the middle part can be left out.
Related PHPCompatibility sniff(s):
TernaryOperators
PHP manual references:
http://php.net/manual/en/language.operators.comparison.php
Example code:
Detect the following code pattern(s):
And fix these to:
Notes for implementation of the sniff:
?
and the:
is the same as the condition ortrue
where the condition can only evaluate to a boolean.