Error Identifier: parameter.notFound
Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.
Code example #
<?php declare(strict_types = 1);
/**
* @param string $name
* @param int $age
* @param string $email
*/
function createUser(string $name, int $age): void
{
}
Why is it reported? #
A PHPDoc tag (@param, @param-out, @param-closure-this, @phpstan-assert, or a conditional return type) references a parameter name that does not exist in the function or method signature.
In the example above, the @param string $email tag references parameter $email, which does not exist in the function’s parameter list.
This typically happens after renaming or removing a parameter without updating the PHPDoc, or from a typo in the parameter name.
How to fix it #
Remove PHPDoc tags for parameters that no longer exist:
/**
* @param string $name
* @param int $age
- * @param string $email
*/
function createUser(string $name, int $age): void
{
}
Or fix the parameter name in the PHPDoc to match the actual parameter:
/**
* @param string $name
* @param int $age
- * @param string $email
+ * @param string $address
*/
-function createUser(string $name, int $age): void
+function createUser(string $name, int $age, string $address): void
{
}
How to ignore this error #
You can use the identifier parameter.notFound to ignore this error using a comment:
// @phpstan-ignore parameter.notFound
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: parameter.notFound
Rules that report this error #
- PHPStan\Rules\PhpDoc\FunctionAssertRule [1]
- PHPStan\Rules\PhpDoc\FunctionConditionalReturnTypeRule [1]
- PHPStan\Rules\PhpDoc\IncompatibleParamImmediatelyInvokedCallableRule [1]
- PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule [1]
- PHPStan\Rules\PhpDoc\IncompatiblePropertyHookPhpDocTypeRule [1]
- PHPStan\Rules\PhpDoc\MethodAssertRule [1]
- PHPStan\Rules\PhpDoc\MethodConditionalReturnTypeRule [1]