|
2 | 2 |
|
3 | 3 | namespace PHPStan\Type; |
4 | 4 |
|
5 | | -use BugSelfReferencedTrait\BaseModelUseTrait; |
6 | 5 | use DependentPhpDocs\Foo; |
7 | 6 | use PHPStan\PhpDoc\Tag\ReturnTag; |
8 | 7 | use PHPStan\ShouldNotHappenException; |
9 | 8 | use PHPStan\Testing\PHPStanTestCase; |
10 | 9 | use RuntimeException; |
11 | | -use function clearstatcache; |
12 | | -use function hash; |
13 | | -use function is_file; |
14 | 10 | use function realpath; |
15 | | -use function sprintf; |
16 | | -use function substr; |
17 | | -use function unlink; |
18 | 11 |
|
19 | 12 | class FileTypeMapperTest extends PHPStanTestCase |
20 | 13 | { |
@@ -217,53 +210,4 @@ public function testFilesWithIdenticalPhpDocsUsingDifferentAliases(): void |
217 | 210 | $this->assertSame('AliasCollisionNamespace2\Foo', $doc2->getVarTags()['x']->getType()->describe(VerbosityLevel::precise())); |
218 | 211 | } |
219 | 212 |
|
220 | | - public function testRecursiveTraitUsedInAnonymousClassDoesNotLoopIndefinitely(): void |
221 | | - { |
222 | | - $realpath = realpath(__DIR__ . '/data/bug-self-referenced-trait/BaseModelUseTrait.php'); |
223 | | - if ($realpath === false) { |
224 | | - throw new ShouldNotHappenException(); |
225 | | - } |
226 | | - |
227 | | - $container = self::getContainer(); |
228 | | - $this->clearFileTypeMapperCache($container->getParameter('tmpDir'), $realpath); |
229 | | - self::createReflectionProvider(); |
230 | | - |
231 | | - /** @var FileTypeMapper $fileTypeMapper */ |
232 | | - $fileTypeMapper = $container->getByType(FileTypeMapper::class); |
233 | | - |
234 | | - $resolved = $fileTypeMapper->getResolvedPhpDoc( |
235 | | - $realpath, |
236 | | - BaseModelUseTrait::class, |
237 | | - null, |
238 | | - null, |
239 | | - '/** @method static Builder<static>|BaseModelUseTrait query() */', |
240 | | - ); |
241 | | - |
242 | | - $this->assertArrayHasKey('query', $resolved->getMethodTags()); |
243 | | - $returnTypeDescription = $resolved->getMethodTags()['query']->getReturnType()->describe(VerbosityLevel::precise()); |
244 | | - $this->assertStringContainsString('BugSelfReferencedTrait\BaseModelUseTrait', $returnTypeDescription); |
245 | | - $this->assertStringContainsString('BugSelfReferencedTrait\Builder<static(BugSelfReferencedTrait\BaseModelUseTrait)>', $returnTypeDescription); |
246 | | - } |
247 | | - |
248 | | - /** |
249 | | - * This ensure test result consistent regardless FileTypeMapper when just rolled back to verify back |
250 | | - */ |
251 | | - private function clearFileTypeMapperCache(string $tmpDir, string $fileName): void |
252 | | - { |
253 | | - $cacheKeyHash = hash('sha256', sprintf('ftm-%s', $fileName)); |
254 | | - |
255 | | - $directory1 = substr($cacheKeyHash, 0, 2); |
256 | | - $directory2 = substr($cacheKeyHash, 2, 2); |
257 | | - |
258 | | - $cacheTmpRootDir = sprintf('%s/cache/PHPStan', $tmpDir); |
259 | | - $cacheFilePath = $cacheTmpRootDir . '/' . $directory1 . '/' . $directory2 . '/' . $cacheKeyHash . '.php'; |
260 | | - |
261 | | - if (!is_file($cacheFilePath)) { |
262 | | - return; |
263 | | - } |
264 | | - |
265 | | - unlink($cacheFilePath); |
266 | | - clearstatcache(); |
267 | | - } |
268 | | - |
269 | 213 | } |
0 commit comments