From 017d054077d31a4365be720bb8bb38d82eead8d7 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Mon, 16 Feb 2026 14:05:39 +0100 Subject: [PATCH] Resolve class references in any PHPDoc tag containing "::" --- .../PhpDocTagGenericUsesDecorator.php | 4 --- .../CustomPhpDocTagClassReferenceTest.php | 28 +++++++++++++++++++ ...ip_custom_tag_with_class_reference.php.inc | 12 ++++++++ .../Source/NotificationHandler.php | 12 ++++++++ .../config/configured_rule.php | 9 ++++++ 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 tests/Issues/CustomPhpDocTagClassReference/CustomPhpDocTagClassReferenceTest.php create mode 100644 tests/Issues/CustomPhpDocTagClassReference/Fixture/skip_custom_tag_with_class_reference.php.inc create mode 100644 tests/Issues/CustomPhpDocTagClassReference/Source/NotificationHandler.php create mode 100644 tests/Issues/CustomPhpDocTagClassReference/config/configured_rule.php diff --git a/src/BetterPhpDocParser/PhpDocParser/PhpDocTagGenericUsesDecorator.php b/src/BetterPhpDocParser/PhpDocParser/PhpDocTagGenericUsesDecorator.php index df31fe464a9..0fb6f23cc97 100644 --- a/src/BetterPhpDocParser/PhpDocParser/PhpDocTagGenericUsesDecorator.php +++ b/src/BetterPhpDocParser/PhpDocParser/PhpDocTagGenericUsesDecorator.php @@ -46,10 +46,6 @@ public function decorate(PhpDocNode $phpDocNode, PhpNode $phpNode): void return null; } - if (! in_array($node->name, ['@uses', '@used-by', '@see'], true)) { - return null; - } - $reference = $node->value->value; if (! str_contains($reference, '::')) { return null; diff --git a/tests/Issues/CustomPhpDocTagClassReference/CustomPhpDocTagClassReferenceTest.php b/tests/Issues/CustomPhpDocTagClassReference/CustomPhpDocTagClassReferenceTest.php new file mode 100644 index 00000000000..4c32f332d2b --- /dev/null +++ b/tests/Issues/CustomPhpDocTagClassReference/CustomPhpDocTagClassReferenceTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Issues/CustomPhpDocTagClassReference/Fixture/skip_custom_tag_with_class_reference.php.inc b/tests/Issues/CustomPhpDocTagClassReference/Fixture/skip_custom_tag_with_class_reference.php.inc new file mode 100644 index 00000000000..3f320f1f055 --- /dev/null +++ b/tests/Issues/CustomPhpDocTagClassReference/Fixture/skip_custom_tag_with_class_reference.php.inc @@ -0,0 +1,12 @@ +removeUnusedImports(); +};