From b0ebb22ffb6b914369ba9edcd3f21d8e767b410a Mon Sep 17 00:00:00 2001 From: brainshaker Date: Sun, 18 Oct 2026 19:49:21 +0200 Subject: [PATCH 1/2] Add failing test for imported @see in SeeAnnotationToTestRule --- .../Fixture/SkipImportedSee.php | 24 +++++++++++++++++++ .../SeeAnnotationToTestRuleTest.php | 1 + 2 files changed, 25 insertions(+) create mode 100644 tests/Rules/SeeAnnotationToTestRule/Fixture/SkipImportedSee.php diff --git a/tests/Rules/SeeAnnotationToTestRule/Fixture/SkipImportedSee.php b/tests/Rules/SeeAnnotationToTestRule/Fixture/SkipImportedSee.php new file mode 100644 index 000000000..176148f08 --- /dev/null +++ b/tests/Rules/SeeAnnotationToTestRule/Fixture/SkipImportedSee.php @@ -0,0 +1,24 @@ + Date: Sun, 18 Oct 2026 22:04:35 +0200 Subject: [PATCH 2/2] Resolve imported short @see class names in SeeAnnotationToTestRule --- src/Rules/SeeAnnotationToTestRule.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Rules/SeeAnnotationToTestRule.php b/src/Rules/SeeAnnotationToTestRule.php index 4dc038216..de91c805c 100644 --- a/src/Rules/SeeAnnotationToTestRule.php +++ b/src/Rules/SeeAnnotationToTestRule.php @@ -7,6 +7,7 @@ use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Stmt\Class_; +use PHPStan\Analyser\NameScope; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; use PHPStan\PhpDoc\Tag\DeprecatedTag; @@ -94,7 +95,7 @@ public function processNode(Node $node, Scope $scope): array } $seeTags = $this->seePhpDocTagNodesFinder->find($resolvedPhpDocBlock); - if ($this->hasSeeTestCaseAnnotation($seeTags)) { + if ($this->hasSeeTestCaseAnnotation($seeTags, $resolvedPhpDocBlock->getNullableNameScope())) { return []; } @@ -123,14 +124,19 @@ private function shouldSkipClassReflection(ClassReflection $classReflection): bo /** * @param PhpDocTagNode[] $seeTags */ - private function hasSeeTestCaseAnnotation(array $seeTags): bool + private function hasSeeTestCaseAnnotation(array $seeTags, ?NameScope $nameScope): bool { foreach ($seeTags as $seeTag) { if (! $seeTag->value instanceof GenericTagValueNode) { continue; } - if (is_a($seeTag->value->value, TestClassName::PHPUNIT_TEST_CASE, true)) { + // resolve short imported names to fully qualified ones + $className = $nameScope instanceof NameScope + ? $nameScope->resolveStringName($seeTag->value->value) + : $seeTag->value->value; + + if (is_a($className, TestClassName::PHPUNIT_TEST_CASE, true)) { return true; } }