-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Labels
Progress: good first issueIssues is easy to get started withIssues is easy to get started withacceptedNew rule is acceptedNew rule is acceptednew ruleNew feature implementationNew feature implementationproposalNew rule proposalNew rule proposal
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
.
buskamuza, wahidnory, mzeis, navarr and novikor
Metadata
Metadata
Assignees
Labels
Progress: good first issueIssues is easy to get started withIssues is easy to get started withacceptedNew rule is acceptedNew rule is acceptednew ruleNew feature implementationNew feature implementationproposalNew rule proposalNew rule proposal