Closed
Description
Rule
The use of literal logical operators (and
, or
) is discouraged. &&
and ||
should be used instead.
Reason
Operator precedence is different for and
vs. &&
and or
vs. ||
.
It may cause unexpected behaviour:
$x = false || true; // is ($x = (false || true)) => true
$x = false or true; // is (($x = false) or true) => false
$x = true && false; // is ($x = (true && false)) => false
$x = true and false; // is (($x = true) and false) => true
Please use the official documentation for more details.
Implementation
Add Squiz.Operators.ValidLogicalOperators
to the ruleset.xml
.