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); diff --git a/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php b/server/tests/UnitTests/PhpStan/PhpStanUtilsTest.php index a6e2fa1..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: Failed importing InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop1', + 'Maximum recusion level (100) reached while resolving alias InfiniteLoop from PhpTypeScriptApi\Tests\UnitTests\PhpStan\FakeLoop2', $th->getMessage(), ); }