Skip to content

Commit

Permalink
Merge pull request #8798 from orklah/min_count
Browse files Browse the repository at this point in the history
fix sealed combination
  • Loading branch information
orklah committed Dec 1, 2022
2 parents aee4605 + 2da4bf9 commit b4aa951
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Psalm/Internal/Type/TypeCombiner.php
Expand Up @@ -1516,6 +1516,7 @@ private static function getArrayTypeFromGenericParams(
|| ($combination->array_sometimes_filled && $overwrite_empty_array)
|| ($combination->objectlike_entries
&& $combination->objectlike_sealed
&& ($combination->array_min_counts[0] ?? false) !== true
&& $overwrite_empty_array)
) {
if ($combination->all_arrays_lists) {
Expand Down
21 changes: 21 additions & 0 deletions tests/ArrayFunctionCallTest.php
Expand Up @@ -2290,6 +2290,27 @@ public function handle(): void {
}
',
],
'mergeBetweenSealedArrayWithPossiblyUndefinedAndMixedArrayIsMixedArray' => [
'code' => '<?php
function findit(Closure $x): void
{
$closure = new ReflectionFunction($x);
$statics = [];
if (rand(0, 1)) {
$statics = ["this" => "a"];
}
$b = $statics + $closure->getStaticVariables();
/** @psalm-check-type $b = array<array-key, mixed> */
$_a = count($b);
/** @psalm-check-type $_a = int<0, max> */
}
',
],
];
}

Expand Down

0 comments on commit b4aa951

Please sign in to comment.