diff --git a/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php b/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php index 7f82281aa6a..ea9b00eda73 100644 --- a/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php +++ b/src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php @@ -90,7 +90,7 @@ public function provide(): SourceLocator $aggregateSourceLocator = $this->aggregateSourceLocator = new AggregateSourceLocator($sourceLocators); - $this->collectClasses($sourceLocators, $isPHPUnitRun); + $this->collectClasses($aggregateSourceLocator, $sourceLocators, $isPHPUnitRun); return $aggregateSourceLocator; } @@ -113,7 +113,7 @@ public function reset(): void /** * @param OptimizedSingleFileSourceLocator[]|NewOptimizedDirectorySourceLocator[] $sourceLocators */ - private function collectClasses(array $sourceLocators, bool $isPHPUnitRun): void + private function collectClasses(AggregateSourceLocator $aggregateSourceLocator, array $sourceLocators, bool $isPHPUnitRun): void { if ($sourceLocators === []) { return; @@ -129,9 +129,7 @@ private function collectClasses(array $sourceLocators, bool $isPHPUnitRun): void return; } - // use AggregateSourceLocator from property fetch, otherwise, it will cause infinite loop - // checked at https://github.com/samsonasik/ci4-album/pull/16 - $reflector = new DefaultReflector($this->aggregateSourceLocator); + $reflector = new DefaultReflector($aggregateSourceLocator); foreach ($sourceLocators as $sourceLocator) { // trigger collect "classes" on get class on locate identifier