Skip to content

Commit

Permalink
Merge pull request #9415 from ptomulik/issue-4460
Browse files Browse the repository at this point in the history
An attempt to fix #4460
  • Loading branch information
orklah committed Feb 28, 2023
2 parents e212b06 + 78e6545 commit 381a23b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Expand Up @@ -514,11 +514,8 @@ private static function updateArrayAssignmentChildType(
$array_atomic_key_type = Type::getArrayKey();
}

if ($offset_already_existed
&& $parent_var_id
&& ($parent_type = $context->vars_in_scope[$parent_var_id] ?? null)
) {
if ($parent_type->hasList() && strpos($parent_var_id, '[') === false) {
if ($parent_var_id && ($parent_type = $context->vars_in_scope[$parent_var_id] ?? null)) {
if ($offset_already_existed && $parent_type->hasList() && strpos($parent_var_id, '[') === false) {
$array_atomic_type_list = $value_type;
} elseif ($parent_type->hasClassStringMap()
&& $key_type
Expand Down
16 changes: 16 additions & 0 deletions tests/Template/ClassStringMapTest.php
Expand Up @@ -105,6 +105,22 @@ public function set(array $map): void {
}
}',
],
'simpleSetter' => [
'code' => '<?php
class Container {
/** @var class-string-map<T, T> */
public array $map = [];
/**
* @template U of object
* @param class-string<U> $key
* @param U $obj
*/
public function set(string $key, object $obj): void {
$this->map[$key] = $obj;
}
}'
,
],
];
}

Expand Down

0 comments on commit 381a23b

Please sign in to comment.