From 0d3b455d21cc7cc88608dae34dbbb9f3ca415f9e Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 13:20:43 +0200 Subject: [PATCH 1/3] Fix recursion condition in alias resolution --- server/lib/PhpStan/PhpStanUtils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/lib/PhpStan/PhpStanUtils.php b/server/lib/PhpStan/PhpStanUtils.php index 7e64c03..8854825 100644 --- a/server/lib/PhpStan/PhpStanUtils.php +++ b/server/lib/PhpStan/PhpStanUtils.php @@ -59,8 +59,8 @@ public function resolveType(Node $node, string $class_name, ?array $generic_args // Resolve ImportAlias $namespace = null; for ($i = 0; isset($alias['namespace']); $i++) { - if ($i > $this->max_recursion) { - throw new \Exception("Maximum recusion level ({$this->max_recursion}) reached: Failed importing {$alias['name']} from {$alias['namespace']}"); + if ($i >= $this->max_recursion) { + throw new \Exception("Maximum recusion level ({$this->max_recursion}) reached while resolving alias {$alias['name']} from {$alias['namespace']}"); } $namespace = $alias['namespace']; $alias = $this->resolveImportAlias($alias); From 333a632acbf97c303d472536a29671a19b448bd6 Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 13:23:13 +0200 Subject: [PATCH 2/3] Update error message for recursion level in tests --- server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php b/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php index a6e2fa1..0b18cad 100644 --- a/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php +++ b/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php @@ -373,7 +373,7 @@ public function testResolveTypeInfiniteLoop(): void { FakeLoop2::class => true, ], $utils->testOnlyGetAliasCacheKeys()); $this->assertSame( - 'Maximum recusion level (100) reached: Failed importing InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop1', + 'Maximum recusion level (100) reached while resolving alias InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop1', $th->getMessage(), ); } From fece77865418ac678e7e518dae24baefa1d453cb Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 13:51:44 +0200 Subject: [PATCH 3/3] Update test assertion message for InfiniteLoop alias --- server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php b/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php index 0b18cad..5e4fca1 100644 --- a/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php +++ b/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php @@ -373,7 +373,7 @@ public function testResolveTypeInfiniteLoop(): void { FakeLoop2::class => true, ], $utils->testOnlyGetAliasCacheKeys()); $this->assertSame( - 'Maximum recusion level (100) reached while resolving alias InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop1', + 'Maximum recusion level (100) reached while resolving alias InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop2', $th->getMessage(), ); }