1.2.1273. Unknown Parameter Name¶
The name of the parameter doesn’t belong to the method signature. Named arguments were introduced in PHP 8.0.
Named arguments errors will also arise when spreading a hash array with arbitrary number of arguments. For example, with array_merge(), the array should not use named keys.
<?php
// All good
foo(a:1, b:2, c:3);
foo(...['a':1, 'b':2, 'c':3]);
// A is not a parameter name, it should be a : names are case sensitive
foo(A:1, b:2, c:3);
foo(...['A':1, 'b':2, 'c':3]);
function foo($a, $b, $c) {}
array_merge(['a' => [1], 'b' => [2]]);
?>
See also Named Arguments and Wrong Argument Name With PHP Function.
1.2.1273.2. Connex PHP features¶
1.2.1273.2.1. Suggestions¶
Fix the name of the parameter and use a valid one
Remove the parameter name, and revert to positional notation
1.2.1273.2.2. Specs¶
Short name |
Functions/UnknownParameterName |
Rulesets |
|
Exakat since |
2.1.6 |
PHP Version |
With PHP 8.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |