rspec/rules/S1854/php/rule.adoc
2023-10-13 12:26:37 +02:00

52 lines
971 B
Plaintext

include::../why.adoc[]
=== Exceptions
This rule ignores initializations to `-1`, `0`, `1`, `null`, `true`, `false`, `""`, `[]` and `array()`.
include::../howtofixit.adoc[]
=== Code examples
==== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
$i = $a + $b; // Noncompliant - calculation result is not used before value is overwritten
$i = compute();
----
==== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
$i = $a + $b;
$i += compute();
----
include::../see.adoc[]
=== Related rules
* S1763 - All code should be reachable
* S3626 - Jump statements should not be redundant
* S1763 detects unreachable code
* S3626 identifies redundant jump statements
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]