rspec/rules/S2651/php/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

71 lines
1.1 KiB
Plaintext

== Why is this an issue?
In PHP 5.4, ``++break++`` and ``++continue++`` no longer accept arguments that require computation. Static arguments are still okay except for zero (``++0++``).
=== Noncompliant code example
[source,php]
----
$i = 0;
$break = 1;
while (++$i) {
switch ($i) {
case 5:
// ...
break $break; // Noncompliant
case 10:
// ...
break $break + 1; // Noncompliant
default:
break $break; // Noncompliant
}
}
----
=== Compliant solution
[source,php]
----
$i = 0;
while (++$i) {
switch ($i) {
case 5:
// ...
break 1;
case 10:
// ...
break 2;
default:
break;
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Remove the variable argument to "xxx".
* "0" is not a valid argument to "xxx"
'''
== Comments And Links
(visible only on this page)
=== on 27 Feb 2015, 17:09:12 Ann Campbell wrote:
source: https://twitter.com/declaassen/status/571237732548087808[twitter]
=== on 19 May 2015, 15:55:05 Linda Martin wrote:
OK!
endif::env-github,rspecator-view[]