Skip to content

Commit 9985b91

Browse files
authored
Revert "[Testing] Use fresh single-file source locator under PHPUnit" (#8464) (#8465)
1 parent 8b1c4e2 commit 9985b91

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

‎src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
88
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
99
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocatorFactory;
10-
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocatorFactory;
1110
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocatorRepository;
1211
use Rector\Contract\DependencyInjection\ResettableInterface;
1312
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
@@ -31,8 +30,7 @@ final class DynamicSourceLocatorProvider implements ResettableInterface
3130

3231
public function __construct(
3332
private readonly OptimizedDirectorySourceLocatorFactory $optimizedDirectorySourceLocatorFactory,
34-
private readonly OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository,
35-
private readonly OptimizedSingleFileSourceLocatorFactory $optimizedSingleFileSourceLocatorFactory
33+
private readonly OptimizedSingleFileSourceLocatorRepository $optimizedSingleFileSourceLocatorRepository
3634
) {
3735
}
3836

@@ -69,12 +67,7 @@ public function provide(): SourceLocator
6967
$sourceLocators = [];
7068

7169
foreach ($this->filePaths as $file) {
72-
// under PHPUnit each fixture is a throwaway temp file that is deleted after the test;
73-
// the shared repository caches locators by path forever, so a stale locator for a since-deleted
74-
// file can leak into a later test. build a fresh locator per run there, keep caching in production
75-
$sourceLocators[] = $isPHPUnitRun
76-
? $this->optimizedSingleFileSourceLocatorFactory->create($file)
77-
: $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($file);
70+
$sourceLocators[] = $this->optimizedSingleFileSourceLocatorRepository->getOrCreate($file);
7871
}
7972

8073
foreach ($this->directories as $directory) {

0 commit comments

Comments
 (0)