Skip to content

Commit 1d5cf1e

Browse files
fix downgrade skip array type of union/intersection (#237)
* fix downgrade skip array type * [ci-review] Rector Rectify * fix * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <[email protected]>
1 parent 984353f commit 1d5cf1e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

rules/DowngradePhp81/Rector/Array_/DowngradeArraySpreadStringKeyRector.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use PHPStan\Type\ArrayType;
1212
use PHPStan\Type\Constant\ConstantArrayType;
1313
use PHPStan\Type\IntegerType;
14+
use PHPStan\Type\IntersectionType;
15+
use PHPStan\Type\UnionType;
1416
use Rector\DowngradePhp81\NodeAnalyzer\ArraySpreadAnalyzer;
1517
use Rector\DowngradePhp81\NodeFactory\ArrayMergeFromArraySpreadFactory;
1618
use Rector\PHPStan\ScopeFetcher;
@@ -94,6 +96,14 @@ private function shouldSkipArray(Array_ $array): bool
9496
continue;
9597
}
9698

99+
if ($type instanceof UnionType) {
100+
continue;
101+
}
102+
103+
if ($type instanceof IntersectionType) {
104+
continue;
105+
}
106+
97107
/** @var ArrayType|ConstantArrayType $type */
98108
$keyType = $type->getKeyType();
99109
if ($keyType instanceof IntegerType) {

0 commit comments

Comments
 (0)