You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Beware of nested ternaries.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: