1717use Rector \Rector \AbstractRector ;
1818use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1919use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
20+ use Webmozart \Assert \Assert ;
2021
2122/**
2223 * @see \Rector\Tests\CodeQuality\Rector\BooleanOr\RepeatedOrEqualToInArrayRector\RepeatedOrEqualToInArrayRectorTest
@@ -107,8 +108,13 @@ public function refactor(Node $node): ?FuncCall
107108 return new FuncCall (new Name ('in_array ' ), $ args );
108109 }
109110
110- private function findIdenticalsOrEquals (BooleanOr $ booleanOr , string $ type = Identical::class): array
111+ /**
112+ * @return array<Identical|Equal>
113+ */
114+ private function findIdenticalsOrEquals (BooleanOr $ booleanOr , string $ type ): array
111115 {
116+ Assert::oneOf ($ type , [Identical::class, Equal::class]);
117+
112118 $ identicalsOrEquals = [];
113119 if ($ booleanOr ->left instanceof $ type ) {
114120 $ identicalsOrEquals [] = $ booleanOr ->left ;
@@ -122,6 +128,7 @@ private function findIdenticalsOrEquals(BooleanOr $booleanOr, string $type = Ide
122128 $ identicalsOrEquals [] = $ booleanOr ->right ;
123129 }
124130
131+ /** @var array<Identical|Equal> $identicalsOrEquals */
125132 return $ identicalsOrEquals ;
126133 }
127134
@@ -172,7 +179,9 @@ private function matchComparedAndDesiredValues(BooleanOr $booleanOr): ?array
172179 return null ;
173180 }
174181
175- $ comparedExprAndValueExprs [] = $ this ->matchComparedExprAndValueExpr ($ currentBooleanOr ->left ->right );
182+ /** @var Identical|Equal $leftRight */
183+ $ leftRight = $ currentBooleanOr ->left ->right ;
184+ $ comparedExprAndValueExprs [] = $ this ->matchComparedExprAndValueExpr ($ leftRight );
176185 $ currentBooleanOr = $ currentBooleanOr ->left ;
177186 }
178187
0 commit comments