rspec/rules/S1226/php/rule.adoc

14 lines
447 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
While it is technically correct to assign to parameters from within function bodies, doing so before the parameter value is read is likely a bug. Instead, initial values of parameters should be, if not treated as read-only, then at least read before reassignment.
== Noncompliant Code Example
----
function foo($str, $array) {
$str = "name; // Noncompliant
foreach ($array as $item) {
$item = "hello world"; // Noncompliant
}
}
----