99use PhpParser \Node \Expr \ArrayItem ;
1010use PhpParser \Node \Expr \MethodCall ;
1111use PhpParser \Node \Scalar \String_ ;
12- use Rector \Core \NodeManipulator \ArrayManipulator ;
1312use Rector \Core \Rector \AbstractRector ;
1413use RectorLaravel \NodeAnalyzer \LumenRouteRegisteringMethodAnalyzer ;
1514use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
2120final class LumenRoutesStringMiddlewareToArrayRector extends AbstractRector
2221{
2322 public function __construct (
24- private readonly ArrayManipulator $ arrayManipulator ,
2523 private readonly LumenRouteRegisteringMethodAnalyzer $ lumenRouteRegisteringMethodAnalyzer
2624 ) {
2725 }
@@ -118,7 +116,7 @@ private function findItemInArrayByKey(Array_ $array, string $keyName): ?ArrayIte
118116 if (! $ item instanceof ArrayItem) {
119117 continue ;
120118 }
121- if (! $ this ->arrayManipulator -> hasKeyName ($ item , $ keyName )) {
119+ if (! $ this ->hasKeyName ($ item , $ keyName )) {
122120 continue ;
123121 }
124122 $ foundArrayItem = $ array ->items [$ i ];
@@ -136,7 +134,7 @@ private function replaceItemInArrayByKey(Array_ $array, ArrayItem $arrayItem, st
136134 if (! $ item instanceof ArrayItem) {
137135 continue ;
138136 }
139- if (! $ this ->arrayManipulator -> hasKeyName ($ item , $ keyName )) {
137+ if (! $ this ->hasKeyName ($ item , $ keyName )) {
140138 continue ;
141139 }
142140 if (! $ array ->items [$ i ] instanceof ArrayItem) {
@@ -146,4 +144,13 @@ private function replaceItemInArrayByKey(Array_ $array, ArrayItem $arrayItem, st
146144 $ array ->items [$ i ] = $ arrayItem ;
147145 }
148146 }
147+
148+ private function hasKeyName (ArrayItem $ arrayItem , string $ name ): bool
149+ {
150+ if (! $ arrayItem ->key instanceof String_) {
151+ return false ;
152+ }
153+
154+ return $ arrayItem ->key ->value === $ name ;
155+ }
149156}
0 commit comments