1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix array spread false negative that crashes (fixes #5431, reverts #2852) (#5432)

This commit is contained in:
AndrolGenhald 2021-03-19 20:51:36 -05:00 committed by GitHub
parent d4590711d6
commit b859fba52d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 16 deletions

View File

@ -762,6 +762,7 @@ class Union implements TypeNode
|| isset($this->types['trait-string'])
|| isset($this->types['numeric-string'])
|| isset($this->types['callable-string'])
|| isset($this->types['array-key'])
|| $this->literal_string_types
|| $this->typed_class_strings;
}

View File

@ -1800,6 +1800,19 @@ class ArrayAssignmentTest extends TestCase
}',
'error_message' => 'DuplicateArrayKey'
],
'unpackArrayWithArrayKeyIntoArray' => [
'<?php
/**
* @param array<array-key, mixed> $data
* @return list<mixed>
*/
function unpackArray(array $data): array
{
return [...$data];
}',
'error_message' => 'DuplicateArrayKey',
],
'ArrayCreateOffsetObject' => [
'<?php
$_a = [new stdClass => "a"];

View File

@ -1761,22 +1761,6 @@ class ArrayFunctionCallTest extends TestCase
'error_levels' => [],
'7.4',
],
'allowUnpackWithArrayKey' => [
'<?php
class Foo {
protected function one(): array {
return [];
}
protected function two(): array {
return [];
}
public function three(): array {
return [...$this->one(), ...$this->two()];
}
}'
],
'spliceTurnsintKeyedInputToList' => [
'<?php
/**