rspec/rules/S1121/php/rule.adoc

55 lines
880 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
include::../description.adoc[]
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,php]
2020-06-30 12:47:33 +02:00
----
if (($val = value()) && check()) { // Noncompliant
2020-06-30 12:47:33 +02:00
}
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,php]
2020-06-30 12:47:33 +02:00
----
$val = value();
if ($val && check()) {
}
----
or
2022-02-04 17:28:24 +01:00
[source,php]
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
2021-01-27 13:42:22 +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[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]