Skip to content

Commit

Permalink
Merge pull request #8776 from kenjis/fix-findQualifiedNameFromPath-Ca…
Browse files Browse the repository at this point in the history
…nnot-declare-class-v3

fix: Cannot declare class CodeIgniter\Config\Services, because the name is already in use
  • Loading branch information
kenjis authored Apr 13, 2024
2 parents 189e109 + 9f850f7 commit 898965a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,15 @@ protected static function buildServicesCache(): void
$locator = static::locator();
$files = $locator->search('Config/Services');

$systemPath = static::autoloader()->getNamespace('CodeIgniter')[0];

// Get instances of all service classes and cache them locally.
foreach ($files as $file) {
// Does not search `CodeIgniter` namespace to prevent from loading twice.
if (str_starts_with($file, $systemPath)) {
continue;
}

$classname = $locator->findQualifiedNameFromPath($file);

if ($classname === false) {
Expand Down

0 comments on commit 898965a

Please sign in to comment.