File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ public function enterNode(Node $node): Node|int|null
5050 return null ;
5151 }
5252
53+ // verify long name, as short name verify may conflict
54+ // see test PR: https://github.com/rectorphp/rector-src/pull/6208
55+ // ref https://3v4l.org/21H5j vs https://3v4l.org/GIHSB
56+ if (substr_count ($ node ->toCodeString (), '\\' ) > 1 ) {
57+ $ originalName = $ node ->getAttribute (AttributeKey::ORIGINAL_NAME );
58+ if ($ originalName instanceof Name && $ originalName ->getLast () === $ originalName ->toString ()) {
59+ return null ;
60+ }
61+ }
62+
5363 if ($ this ->classNameImportSkipper ->shouldSkipName ($ node , $ this ->currentUses )) {
5464 return null ;
5565 }
Original file line number Diff line number Diff line change @@ -89,17 +89,17 @@ private function findNonUseImportNames(Namespace_|FileWithoutNamespace $namespac
8989 return null ;
9090 }
9191
92- $ names [] = $ node ->toString ();
93-
9492 if ($ node instanceof FullyQualified) {
9593 $ originalName = $ node ->getAttribute (AttributeKey::ORIGINAL_NAME );
9694
9795 if ($ originalName instanceof Name) {
98- // collect original Name as well to cover namespaced used
96+ // collect original Name as cover namespaced used
9997 $ names [] = $ originalName ->toString ();
98+ return $ node ;
10099 }
101100 }
102101
102+ $ names [] = $ node ->toString ();
103103 return $ node ;
104104 });
105105
You can’t perform that action at this time.
0 commit comments