Menu
Error Identifier: include.fileNotFound
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);
include 'non-existent-file.php';
Why is it reported? #
The file path passed to include does not point to an existing file. PHPStan checks whether the file exists in the current working directory, the PHP include path, and the directory of the analysed file.
How to fix it #
Fix the file path to point to an existing file:
<?php declare(strict_types = 1);
-include 'non-existent-file.php';
+include 'existing-file.php';
How to ignore this error #
You can use the identifier include.fileNotFound to ignore this error using a comment:
// @phpstan-ignore include.fileNotFound
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: include.fileNotFound
Rules that report this error #
- PHPStan\Rules\Keywords\RequireFileExistsRule [1]