From d567978ebe21cc027d92b6c7f6308bc30f9b119d Mon Sep 17 00:00:00 2001 From: Pieter Willekens Date: Thu, 27 Feb 2025 20:19:11 +0100 Subject: [PATCH] chore(meta): ignore abstracts in the autoloader (Fixes #1671) (#1686) --- src/Console/MetaCommand.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index 92f781d..02c8341 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -192,10 +192,19 @@ class MetaCommand extends Command */ protected function registerClassAutoloadExceptions(): callable { - $autoloader = function ($class) { + $aliases = array_filter([...$this->getAbstracts(), 'config'], fn ($abstract) => !str_contains($abstract, '\\')); + + $autoloader = function ($class) use ($aliases) { + // ignore aliases as they're meant to be resolved elsewhere + if (in_array($class, $aliases, true)) { + return; + } + throw new \ReflectionException("Class '$class' not found."); }; + spl_autoload_register($autoloader); + return $autoloader; }