website/errors/class.notFound.md
<?php declare(strict_types = 1);
class Foo extends NonexistentClass
{
}
The code references a class that PHPStan cannot find. This can happen when extending, implementing, instantiating, or type-hinting a class that does not exist. Common causes include:
use import statementAt runtime, referencing a non-existent class will cause a fatal error.
Make sure the class exists and is properly autoloaded:
<?php declare(strict_types = 1);
+use App\Models\BaseClass;
+
-class Foo extends NonexistentClass
+class Foo extends BaseClass
{
}
If the class comes from an external package, make sure the package is installed:
composer require vendor/package
If PHPStan cannot find a class that does exist at runtime, configure the autoloader or scanFiles/scanDirectories in your PHPStan configuration.
Learn more: Discovering Symbols