1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00
This commit is contained in:
Daniil Gentili 2023-12-07 17:29:22 +01:00
parent c620f6e80d
commit 576ecd66e6
2 changed files with 25 additions and 2 deletions

View File

@ -216,8 +216,8 @@ final class ConstantTypeResolver
return new TArray([Type::getArrayKey(), Type::getMixed()]); return new TArray([Type::getArrayKey(), Type::getMixed()]);
} }
foreach ($spread_array->properties as $spread_array_type) { foreach ($spread_array->properties as $k => $spread_array_type) {
$properties[$auto_key++] = $spread_array_type; $properties[is_string($k) ? $k : $auto_key++] = $spread_array_type;
} }
continue; continue;
} }

View File

@ -1280,6 +1280,29 @@ class ArrayAssignmentTest extends TestCase
'ignored_issues' => [], 'ignored_issues' => [],
'php_version' => '8.1', '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' => [ 'listPropertyAssignmentAfterIsset' => [
'code' => '<?php 'code' => '<?php
class Collection { class Collection {