1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #9439 from ptomulik/issue-9433

Fix #9433
This commit is contained in:
orklah 2023-03-12 18:57:14 +01:00 committed by GitHub
commit 60a138987b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -551,6 +551,8 @@ class TypeCombiner
}
foreach ($type->type_params as $i => $type_param) {
// See https://github.com/vimeo/psalm/pull/9439#issuecomment-1464563015
/** @psalm-suppress PropertyTypeCoercion */
$combination->array_type_params[$i] = Type::combineUnionTypes(
$combination->array_type_params[$i] ?? null,
$type_param,
@ -599,6 +601,8 @@ class TypeCombiner
if ($type instanceof TClassStringMap) {
foreach ([$type->getStandinKeyParam(), $type->value_param] as $i => $type_param) {
// See https://github.com/vimeo/psalm/pull/9439#issuecomment-1464563015
/** @psalm-suppress PropertyTypeCoercion */
$combination->array_type_params[$i] = Type::combineUnionTypes(
$combination->array_type_params[$i] ?? null,
$type_param,

View File

@ -761,7 +761,7 @@ class Reconciler
return null;
}
$new_base_type_candidate = $existing_key_type_part->getGenericValueType();
$new_base_type_candidate = $existing_key_type_part->getGenericValueType(true);
} else {
$array_properties = $existing_key_type_part->properties;

View File

@ -1153,6 +1153,25 @@ class IssetTest extends TestCase
}',
'error_message' => 'RedundantPropertyInitializationCheck',
],
'setArbitraryListElementAfterIsset' => [
'code' => '<?php
/** @param list<string> $list */
function foo(array &$list, int $offset): void {
if (isset($list[$offset])) {}
$list[$offset] = "";
}',
'error_message' => 'ReferenceConstraintViolation',
],
'setArbitraryListWithinNotIsset' => [
'code' => '<?php
/** @param list<string> $list */
function foo(array &$list, int $offset): void {
if (!isset($list[$offset])) {
$list[$offset] = "";
}
}',
'error_message' => 'ReferenceConstraintViolation',
],
];
}
}