|
5 | 5 | use Bug4288\MyClass; |
6 | 6 | use Bug4713\Service; |
7 | 7 | use ExtendingKnownClassWithCheck\Foo; |
| 8 | +use PHPStan\DependencyInjection\Container; |
| 9 | +use PHPStan\DependencyInjection\ContainerFactory; |
| 10 | +use PHPStan\File\FileHelper; |
8 | 11 | use PHPStan\Reflection\InitializerExprContext; |
9 | 12 | use PHPStan\Reflection\InitializerExprTypeResolver; |
10 | 13 | use PHPStan\Reflection\SignatureMap\SignatureMapProvider; |
|
19 | 22 | use function count; |
20 | 23 | use function extension_loaded; |
21 | 24 | use function sprintf; |
| 25 | +use function sys_get_temp_dir; |
22 | 26 | use const PHP_VERSION_ID; |
23 | 27 |
|
24 | 28 | #[CoversNothing] |
@@ -1834,16 +1838,32 @@ public function testBug15520(): void |
1834 | 1838 | } |
1835 | 1839 | } |
1836 | 1840 |
|
| 1841 | + public function testBug15380(): void |
| 1842 | + { |
| 1843 | + $containerFactory = new ContainerFactory(__DIR__); |
| 1844 | + $container = $containerFactory->create(sys_get_temp_dir() . '/phpstan-tests', [ |
| 1845 | + __DIR__ . '/data/bug-15380.neon', |
| 1846 | + ], []); |
| 1847 | + |
| 1848 | + try { |
| 1849 | + $errors = $this->runAnalyse(__DIR__ . '/data/bug-15380.php', null, $container); |
| 1850 | + $this->assertNoErrors($errors); |
| 1851 | + } finally { |
| 1852 | + self::getContainer(); |
| 1853 | + } |
| 1854 | + } |
| 1855 | + |
1837 | 1856 | /** |
1838 | 1857 | * @param string[]|null $allAnalysedFiles |
1839 | 1858 | * @return list<Error> |
1840 | 1859 | */ |
1841 | | - private function runAnalyse(string $file, ?array $allAnalysedFiles = null): array |
| 1860 | + private function runAnalyse(string $file, ?array $allAnalysedFiles = null, ?Container $container = null): array |
1842 | 1861 | { |
1843 | | - $file = $this->getFileHelper()->normalizePath($file); |
| 1862 | + $container ??= self::getContainer(); |
| 1863 | + $file = $container->getByType(FileHelper::class)->normalizePath($file); |
1844 | 1864 |
|
1845 | | - $analyser = self::getContainer()->getByType(Analyser::class); |
1846 | | - $finalizer = self::getContainer()->getByType(AnalyserResultFinalizer::class); |
| 1865 | + $analyser = $container->getByType(Analyser::class); |
| 1866 | + $finalizer = $container->getByType(AnalyserResultFinalizer::class); |
1847 | 1867 | $errors = $finalizer->finalize( |
1848 | 1868 | $analyser->analyse([$file], null, null, true, $allAnalysedFiles), |
1849 | 1869 | false, |
|
0 commit comments