Skip to content

Commit eac3d48

Browse files
committed
fix
1 parent c541dfe commit eac3d48

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

phpstan.neon

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,3 @@ parameters:
345345
-
346346
identifier: symplify.noReference
347347
message: '#Use explicit return value over magic &reference#'
348-
349-
# known type
350-
-
351-
identifier: argument.type
352-
message: '#Parameter \#1 \$expr of method Rector\\CodeQuality\\Rector\\BooleanOr\\RepeatedOrEqualToInArrayRector\:\:matchComparedExprAndValueExpr\(\) expects PhpParser\\Node\\Expr\\BinaryOp\\Equal\|PhpParser\\Node\\Expr\\BinaryOp\\Identical, PhpParser\\Node\\Expr given#'
353-
354-
-
355-
path: rules/Renaming/Rector/Name/RenameClassRector.php
356-
identifier: return.type
357-
358-
- '#Method Rector\\(.*?)Rector\:\:refactor\(\) never returns \d so it can be removed from the return type#'

rules/CodeQuality/Rector/BooleanOr/RepeatedOrEqualToInArrayRector.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Rector\Rector\AbstractRector;
1818
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1919
use 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

Comments
 (0)