Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 7, 2023
1 parent c620f6e commit 576ecd6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Codebase/ConstantTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ public static function resolve(
return new TArray([Type::getArrayKey(), Type::getMixed()]);
}

foreach ($spread_array->properties as $spread_array_type) {
$properties[$auto_key++] = $spread_array_type;
foreach ($spread_array->properties as $k => $spread_array_type) {
$properties[is_string($k) ? $k : $auto_key++] = $spread_array_type;
}
continue;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/ArrayAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,29 @@ function foo(array $arr) : string {
'ignored_issues' => [],
'php_version' => '8.1',
],
'constantArraySpreadWithString' => [
'code' => '<?php
class BaseClass {
public const KEYS = [
"a" => "a",
"b" => "b",
];
}
class ChildClass extends BaseClass {
public const A = [
...parent::KEYS,
"c" => "c",
];
}
$a = ChildClass::A;',
'assertions' => [
'$a===' => "array{a: 'a', b: 'b', c: 'c'}",
],
'ignored_issues' => [],
'php_version' => '8.1',
],
'listPropertyAssignmentAfterIsset' => [
'code' => '<?php
class Collection {
Expand Down

0 comments on commit 576ecd6

Please sign in to comment.