1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

don't throw InvalidArrayOffset when dealing with templates (#5019)

This commit is contained in:
orklah 2021-01-14 22:35:06 +01:00 committed by Daniil Gentili
parent d56f941303
commit 8954c12eaa
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 11 additions and 0 deletions

View File

@ -154,6 +154,7 @@ class ArrayAnalyzer
&& !$atomic_key_type instanceof Type\Atomic\TInt
&& !$atomic_key_type instanceof Type\Atomic\TArrayKey
&& !$atomic_key_type instanceof Type\Atomic\TMixed
&& !$atomic_key_type instanceof Type\Atomic\TTemplateParam
&& !(
$atomic_key_type instanceof Type\Atomic\TObjectWithProperties
&& isset($atomic_key_type->methods['__toString'])

View File

@ -1506,6 +1506,16 @@ class ArrayAssignmentTest extends TestCase
return $list;
}'
],
'ArrayCreateTemplateArrayKey' => [
'/**
* @template K of array-key
* @param K $key
*/
function with($key): void
{
[$key => 123];
}',
],
];
}