File tree Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -20,29 +20,32 @@ public function __construct(
2020 private readonly \Closure $ transform ,
2121 ) {}
2222
23- private function containsName ( Node $ node ): bool
23+ private function map ( Name $ name ): Name
2424 {
25- return $ node instanceof NamedTypeNode
26- || $ node instanceof CallableTypeNode
27- || $ node instanceof ConstMaskNode
28- || $ node instanceof ClassConstMaskNode
29- ;
25+ $ result = ($ this ->transform )($ name );
26+
27+ if ($ result instanceof Name) {
28+ return $ result ;
29+ }
30+
31+ return $ name ;
3032 }
3133
3234 public function enter (Node $ node ): ?Command
3335 {
34- if ($ this ->containsName ($ node )) {
35- /**
36- * @var object{name: Name} $node
37- * @psalm-suppress MixedAssignment
38- */
39- $ mapped = ($ this ->transform )($ node ->name );
40-
41- if ($ mapped instanceof Name) {
42- $ node ->key = $ mapped ;
43- }
36+ switch (true ) {
37+ case $ node instanceof NamedTypeNode:
38+ case $ node instanceof CallableTypeNode:
39+ case $ node instanceof ConstMaskNode:
40+ $ node ->name = $ this ->map ($ node ->name );
41+ return null ;
42+
43+ case $ node instanceof ClassConstMaskNode:
44+ $ node ->class = $ this ->map ($ node ->class );
45+ return null ;
46+
47+ default :
48+ return null ;
4449 }
45-
46- return null ;
4750 }
4851}
You can’t perform that action at this time.
0 commit comments