diff --git a/src/Support/ClassLoader.php b/src/Support/ClassLoader.php index 1a7673813..f46a98aa4 100644 --- a/src/Support/ClassLoader.php +++ b/src/Support/ClassLoader.php @@ -33,6 +33,11 @@ class ClassLoader */ public $manifest = []; + /** + * @var array unknownClasses cache + */ + protected $unknownClasses = []; + /** * @var bool manifestDirty if manifest needs to be written */ @@ -68,6 +73,10 @@ public function __construct(Filesystem $files, string $basePath) */ public function load($class): bool { + if (!str_contains($class, '\\')) { + return false; + } + if ( isset($this->manifest[$class]) && is_file($fullPath = $this->basePath.DIRECTORY_SEPARATOR.$this->manifest[$class]) @@ -76,6 +85,10 @@ public function load($class): bool return true; } + if (isset($this->unknownClasses[$class])) { + return false; + } + [$lowerClass, $upperClass] = $this->normalizeClass($class); // Load namespaces @@ -94,6 +107,8 @@ public function load($class): bool } } + $this->unknownClasses[$class] = true; + return false; } @@ -150,7 +165,7 @@ public function register(): void $this->registered = spl_autoload_register(function($class) { $this->load($class); - }, true, true); + }); } /**