From c3c63e24779f612c0c50c08cd9e995b55032a52e Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Tue, 1 Oct 2024 16:40:34 +0100 Subject: [PATCH] [5.x] Prevent autoloading of abstract classes and interfaces (#10882) --- src/Providers/AddonServiceProvider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Providers/AddonServiceProvider.php b/src/Providers/AddonServiceProvider.php index 9fba9bae33..af4d04c6bb 100644 --- a/src/Providers/AddonServiceProvider.php +++ b/src/Providers/AddonServiceProvider.php @@ -740,6 +740,11 @@ protected function autoloadFilesFromFolder($folder, $requiredClass) foreach ($this->app['files']->files($path) as $file) { $class = $file->getBasename('.php'); $fqcn = $this->namespace().'\\'.str_replace('/', '\\', $folder).'\\'.$class; + + if ((new \ReflectionClass($fqcn))->isAbstract() || (new \ReflectionClass($fqcn))->isInterface()) { + continue; + } + if (is_subclass_of($fqcn, $requiredClass)) { $autoloadable[] = $fqcn; }