Error Identifier: function.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);
echo undefinedFunction();
Why is it reported? #
The code calls a function that PHPStan cannot find. This usually means the function does not exist, is misspelled, or is defined in a file that PHPStan does not scan (such as a conditionally loaded file or an extension stub).
How to fix it #
If the function name is a typo, correct it:
<?php declare(strict_types = 1);
-echo aray_merge([1], [2]);
+echo array_merge([1], [2]);
If the function is defined elsewhere, make sure PHPStan can discover it by including the file in scanFiles or scanDirectories:
parameters:
scanFiles:
- functions.php
If the function comes from a PHP extension, make sure PHPStan knows about it by adding the appropriate extension stubs.
How to ignore this error #
You can use the identifier function.notFound to ignore this error using a comment:
// @phpstan-ignore function.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: function.notFound