Skip to content

Commit

Permalink
Merge pull request #7558 from orklah/tweaksToArrays
Browse files Browse the repository at this point in the history
sealed keyed arrays
  • Loading branch information
orklah committed Feb 1, 2022
2 parents bd14653 + 1c2ffc8 commit ff2636e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -230,6 +230,7 @@ public static function analyze(
if ($type instanceof Scalar) {
$keyed_array = new TKeyedArray([new Union([$type])]);
$keyed_array->is_list = true;
$keyed_array->sealed = true;
$permissible_atomic_types[] = $keyed_array;
} elseif ($type instanceof TNull) {
$permissible_atomic_types[] = new TArray([Type::getEmpty(), Type::getEmpty()]);
Expand Down
4 changes: 3 additions & 1 deletion src/Psalm/Internal/Codebase/ConstantTypeResolver.php
Expand Up @@ -137,7 +137,9 @@ public static function resolve(
}

if ($left instanceof TKeyedArray && $right instanceof TKeyedArray) {
return new TKeyedArray($left->properties + $right->properties);
$keyed_array = new TKeyedArray($left->properties + $right->properties);
$keyed_array->sealed = true;
return $keyed_array;
}

return new TMixed;
Expand Down

0 comments on commit ff2636e

Please sign in to comment.