File tree Expand file tree Collapse file tree 3 files changed +2695
-0
lines changed
Expand file tree Collapse file tree 3 files changed +2695
-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,16 @@ public function testBug12627(): void
15101510 $ this ->assertNoErrors ($ errors );
15111511 }
15121512
1513+ public function testBug12159 (): void
1514+ {
1515+ if (PHP_VERSION_ID < 80300 ) {
1516+ $ this ->markTestSkipped ('Test requires PHP 8.3. ' );
1517+ }
1518+
1519+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-12159.php ' );
1520+ $ this ->assertNoErrors ($ errors );
1521+ }
1522+
15131523 /**
15141524 * @param string[]|null $allAnalysedFiles
15151525 * @return Error[]
You can’t perform that action at this time.
0 commit comments