rspec/rules/S1121/php/rule.adoc

35 lines
544 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
if ($val = value() && check()) { // Noncompliant
}
----
== Compliant Solution
----
$val = value();
if ($val && check()) {
}
----
or
2020-06-30 12:47:33 +02:00
----
2021-01-17 04:03:57 +00:00
if ($val == value() && check()) { // Perhaps in fact the equality operator was expected
2020-06-30 12:47:33 +02:00
}
----
== Exceptions
2020-12-23 14:59:06 +01:00
Assignments in ``while`` statement conditions, and assignments enclosed in relational expressions are allowed.
2020-06-30 12:47:33 +02:00
----
while (($line = next_line()) != NULL) {...}
while ($line = next_line()) {...}
----
include::../see.adoc[]