Skip to content

Commit

Permalink
[5.x] Prevent autoloading of abstract classes and interfaces (#10882)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Oct 1, 2024
1 parent 6faf9f5 commit c3c63e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Providers/AddonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c3c63e2

Please sign in to comment.