File tree Expand file tree Collapse file tree 3 files changed +2691
-0
lines changed Expand file tree Collapse file tree 3 files changed +2691
-0
lines changed Original file line number Diff line number Diff line change @@ -897,6 +897,10 @@ private static function optimizeConstantArrays(array $types): array
897897 $ keyType = self ::union (...$ keyTypes );
898898 $ valueType = self ::union (...$ valueTypes );
899899
900+ if ($ valueType instanceof UnionType && count ($ valueType ->getTypes ()) > ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT ) {
901+ $ valueType = $ valueType ->generalize (GeneralizePrecision::lessSpecific ());
902+ }
903+
900904 $ arrayType = new ArrayType ($ keyType , $ valueType );
901905 if ($ eachIsList ) {
902906 $ arrayType = self ::intersect ($ arrayType , new AccessoryArrayListType ());
Original file line number Diff line number Diff line change @@ -1510,6 +1510,12 @@ public function testBug12627(): void
15101510 $ this ->assertNoErrors ($ errors );
15111511 }
15121512
1513+ public function testBug12159 (): void
1514+ {
1515+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-12159.php ' );
1516+ $ this ->assertNoErrors ($ errors );
1517+ }
1518+
15131519 /**
15141520 * @param string[]|null $allAnalysedFiles
15151521 * @return Error[]
You can’t perform that action at this time.
0 commit comments