ReflectionNamedArgumentMismatch
error native on by default PHP ≥ 8.0Group: Probable bugs
Use a declared reflection parameter name.
Example
Finding:
php
<?php
function welcome($name) {} $r = new ReflectionFunction("welcome"); $r->invokeArgs(["nickname" => "Kai"]);Reported:
- line 2: Use a declared reflection parameter name.
Detection
- Resolve ReflectionFunction or ReflectionMethod constructed from a known declaration. For invokeArgs, inspect literal string keys against resolved parameter names; report an unknown key only when the target is nonvariadic. Numeric keys remain positional. Account for inherited methods and named constructor arguments.
- Emit one finding per violating operation. Flow facts require a reachable path with no intervening mutation, escaped alias, unknown call involving the tracked value or analysis-budget exhaustion. Uncertain facts cannot prove a violation.
Exceptions (no report)
- Unknown reflected targets, unknown argument arrays and variadic targets accepting extra named arguments are excluded. Do not extend the named-key behavior to PHP 7.
- Exclude shadowed builtin symbols, unresolved required types, incomplete syntax and unsupported PHP versions.
Fix
No automatic fix. Choosing a repair requires runtime information, error-handling policy or a semantic decision.
All edits use exact byte ranges, preserve comments and evaluation order, and require syntax supported by the target PHP version. A fix must never add an evaluation or silently change unrelated arguments.
PHP versions
Minimum PHP 8.0.
Configure
In custos.json:
json
{
"rules": {
"ReflectionNamedArgumentMismatch": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore ReflectionNamedArgumentMismatch