@@ -101,16 +101,16 @@ public function configure(array $configuration): void
101101 $ this ->arrayDimFetchToMethodCalls = $ configuration ;
102102 }
103103
104- private function handleIsset (Isset_ $ node ): Expr |int |null
104+ private function handleIsset (Isset_ $ isset ): Expr |int |null
105105 {
106106 $ issets = [];
107107 $ exprs = [];
108108
109- foreach ($ node ->vars as $ var ) {
109+ foreach ($ isset ->vars as $ var ) {
110110 if ($ var instanceof ArrayDimFetch) {
111111 $ methodCall = $ this ->getMethodCall ($ var , 'exists ' );
112112
113- if ($ methodCall !== null ) {
113+ if ($ methodCall instanceof MethodCall ) {
114114 $ exprs [] = $ methodCall ;
115115 continue ;
116116 }
@@ -124,30 +124,30 @@ private function handleIsset(Isset_ $node): Expr|int|null
124124 }
125125
126126 if ($ issets !== []) {
127- $ node ->vars = $ issets ;
128- array_unshift ($ exprs , $ node );
127+ $ isset ->vars = $ issets ;
128+ array_unshift ($ exprs , $ isset );
129129 }
130130
131131 return array_reduce (
132132 $ exprs ,
133- fn (?Expr $ carry , Expr $ expr ) => $ carry === null ? $ expr : new BooleanAnd ($ carry , $ expr ),
133+ fn (?Expr $ carry , Expr $ expr ): Isset_ | MethodCall | BooleanAnd => $ carry instanceof Expr ? new BooleanAnd ($ carry , $ expr ) : $ expr ,
134134 null ,
135135 );
136136 }
137137
138138 /**
139139 * @return Stmt[]|int
140140 */
141- private function handleUnset (Unset_ $ node ): array |int
141+ private function handleUnset (Unset_ $ unset ): array |int
142142 {
143143 $ unsets = [];
144144 $ stmts = [];
145145
146- foreach ($ node ->vars as $ var ) {
146+ foreach ($ unset ->vars as $ var ) {
147147 if ($ var instanceof ArrayDimFetch) {
148148 $ methodCall = $ this ->getMethodCall ($ var , 'unset ' );
149149
150- if ($ methodCall !== null ) {
150+ if ($ methodCall instanceof MethodCall ) {
151151 $ stmts [] = new Expression ($ methodCall );
152152 continue ;
153153 }
@@ -161,8 +161,8 @@ private function handleUnset(Unset_ $node): array|int
161161 }
162162
163163 if ($ unsets !== []) {
164- $ node ->vars = $ unsets ;
165- array_unshift ($ stmts , $ node );
164+ $ unset ->vars = $ unsets ;
165+ array_unshift ($ stmts , $ unset );
166166 }
167167
168168 return $ stmts ;
@@ -171,14 +171,14 @@ private function handleUnset(Unset_ $node): array|int
171171 /**
172172 * @param 'get'|'set'|'exists'|'unset' $action
173173 */
174- private function getMethodCall (ArrayDimFetch $ fetch , string $ action , ?Expr $ value = null ): ?MethodCall
174+ private function getMethodCall (ArrayDimFetch $ arrayDimFetch , string $ action , ?Expr $ expr = null ): ?MethodCall
175175 {
176- if (!$ fetch ->dim instanceof Node) {
176+ if (!$ arrayDimFetch ->dim instanceof Node) {
177177 return null ;
178178 }
179179
180180 foreach ($ this ->arrayDimFetchToMethodCalls as $ arrayDimFetchToMethodCall ) {
181- if (!$ this ->isObjectType ($ fetch ->var , $ arrayDimFetchToMethodCall ->getObjectType ())) {
181+ if (!$ this ->isObjectType ($ arrayDimFetch ->var , $ arrayDimFetchToMethodCall ->getObjectType ())) {
182182 continue ;
183183 }
184184
@@ -193,13 +193,13 @@ private function getMethodCall(ArrayDimFetch $fetch, string $action, ?Expr $valu
193193 continue ;
194194 }
195195
196- $ args = [new Arg ($ fetch ->dim )];
196+ $ args = [new Arg ($ arrayDimFetch ->dim )];
197197
198- if ($ value instanceof Expr) {
199- $ args [] = new Arg ($ value );
198+ if ($ expr instanceof Expr) {
199+ $ args [] = new Arg ($ expr );
200200 }
201201
202- return new MethodCall ($ fetch ->var , $ method , $ args );
202+ return new MethodCall ($ arrayDimFetch ->var , $ method , $ args );
203203 }
204204
205205 return null ;
0 commit comments