From 44e622b231d4a3fc2c1637202bfaceadd8ff5daa Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 25 Nov 2023 22:10:52 +0700 Subject: [PATCH 1/2] [Php80] Allow subnamespace from use statements support on AnnotationToAttributeRector --- rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php index 071080c803d..53f51cfd272 100644 --- a/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php +++ b/rules/CodingStyle/NodeAnalyzer/UseImportNameMatcher.php @@ -70,6 +70,12 @@ private function resolveName(string $prefix, string $tag, UseUse $useUse): strin } if (! $originalUseUseNode->alias instanceof Identifier) { + $lastName = $originalUseUseNode->name->getLast(); + if (str_starts_with($tag, $lastName . '\\')) { + $tagName = Strings::after($tag, '\\'); + return $prefix . $originalUseUseNode->name->toString() . '\\' . $tagName; + } + return $prefix . $originalUseUseNode->name->toString(); } From 5ef82e3f71e82a086c5821d0d388508baf55b9c9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 25 Nov 2023 22:10:59 +0700 Subject: [PATCH 2/2] fix --- .../Fixture/sub_namespace_from_use.php.inc | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/Issues/FqcnAnnotationToAttribute/Fixture/sub_namespace_from_use.php.inc diff --git a/tests/Issues/FqcnAnnotationToAttribute/Fixture/sub_namespace_from_use.php.inc b/tests/Issues/FqcnAnnotationToAttribute/Fixture/sub_namespace_from_use.php.inc new file mode 100644 index 00000000000..7a74f33e7e5 --- /dev/null +++ b/tests/Issues/FqcnAnnotationToAttribute/Fixture/sub_namespace_from_use.php.inc @@ -0,0 +1,27 @@ + +----- + \ No newline at end of file