@@ -21,8 +21,6 @@ final class VariadicMethodsVisitor extends NodeVisitorAbstract
21
21
22
22
private ?string $ inNamespace = null ;
23
23
24
- private ?string $ inClassLike = null ;
25
-
26
24
/** @var array<string> */
27
25
private array $ classStack = [];
28
26
@@ -41,7 +39,6 @@ public function beforeTraverse(array $nodes): ?array
41
39
$ this ->variadicMethods = [];
42
40
$ this ->inNamespace = null ;
43
41
$ this ->classStack = [];
44
- $ this ->inClassLike = null ;
45
42
$ this ->inMethod = null ;
46
43
$ this ->anonymousClassIndex = 0 ;
47
44
@@ -66,25 +63,27 @@ public function enterNode(Node $node): ?Node
66
63
}
67
64
68
65
$ this ->classStack [] = $ className ;
69
- $ this -> inClassLike = $ this ->inNamespace !== null ? $ this ->inNamespace . '\\' . implode ('\\' , $ this ->classStack ) : implode ('\\' , $ this ->classStack );
70
- $ this ->variadicMethods [$ this -> inClassLike ] ??= [];
66
+ $ inClassLike = $ this ->inNamespace !== null ? $ this ->inNamespace . '\\' . implode ('\\' , $ this ->classStack ) : implode ('\\' , $ this ->classStack );
67
+ $ this ->variadicMethods [$ inClassLike ] ??= [];
71
68
}
72
69
73
- if ($ this ->inClassLike !== null && $ node instanceof ClassMethod) {
70
+ if ($ this ->classStack !== [] && $ node instanceof ClassMethod) {
74
71
$ this ->inMethod = $ node ->name ->name ;
75
72
}
76
73
77
74
if (
78
- $ this ->inClassLike !== null
75
+ $ this ->classStack !== []
79
76
&& $ this ->inMethod !== null
80
77
&& $ node instanceof Node \Expr \FuncCall
81
78
&& $ node ->name instanceof Name
82
79
&& in_array ((string ) $ node ->name , ParametersAcceptor::VARIADIC_FUNCTIONS , true )
83
80
) {
84
- if (!array_key_exists ($ this ->inMethod , $ this ->variadicMethods [$ this ->inClassLike ])) {
85
- $ this ->variadicMethods [$ this ->inClassLike ][$ this ->inMethod ] = TrinaryLogic::createYes ();
81
+ $ inClassLike = $ this ->inNamespace !== null ? $ this ->inNamespace . '\\' . implode ('\\' , $ this ->classStack ) : implode ('\\' , $ this ->classStack );
82
+
83
+ if (!array_key_exists ($ this ->inMethod , $ this ->variadicMethods [$ inClassLike ])) {
84
+ $ this ->variadicMethods [$ inClassLike ][$ this ->inMethod ] = TrinaryLogic::createYes ();
86
85
} else {
87
- $ this ->variadicMethods [$ this -> inClassLike ][$ this ->inMethod ]->and (TrinaryLogic::createYes ());
86
+ $ this ->variadicMethods [$ inClassLike ][$ this ->inMethod ]->and (TrinaryLogic::createYes ());
88
87
}
89
88
90
89
}
@@ -96,20 +95,16 @@ public function leaveNode(Node $node): ?Node
96
95
{
97
96
if (
98
97
$ node instanceof ClassMethod
99
- && $ this ->inClassLike !== null
98
+ && $ this ->classStack !== []
100
99
) {
101
- $ this ->variadicMethods [$ this ->inClassLike ][$ node ->name ->name ] ??= TrinaryLogic::createNo ();
100
+ $ inClassLike = $ this ->inNamespace !== null ? $ this ->inNamespace . '\\' . implode ('\\' , $ this ->classStack ) : implode ('\\' , $ this ->classStack );
101
+
102
+ $ this ->variadicMethods [$ inClassLike ][$ node ->name ->name ] ??= TrinaryLogic::createNo ();
102
103
$ this ->inMethod = null ;
103
104
}
104
105
105
106
if ($ node instanceof Node \Stmt \ClassLike) {
106
107
array_pop ($ this ->classStack );
107
-
108
- if ($ this ->classStack !== []) {
109
- $ this ->inClassLike = $ this ->inNamespace !== null ? $ this ->inNamespace . '\\' . implode ('\\' , $ this ->classStack ) : implode ('\\' , $ this ->classStack );
110
- } else {
111
- $ this ->inClassLike = null ;
112
- }
113
108
}
114
109
115
110
if ($ node instanceof Node \Stmt \Namespace_ && $ node ->name !== null ) {
0 commit comments