Skip to content

Commit

Permalink
don't throw InvalidArrayOffset when dealing with templates (#5019)
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah authored Jan 14, 2021
1 parent 26f756d commit 7a40443
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static function analyze(
&& !$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'])
Expand Down
10 changes: 10 additions & 0 deletions tests/ArrayAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,16 @@ function getList(array $list): array {
return $list;
}'
],
'ArrayCreateTemplateArrayKey' => [
'/**
* @template K of array-key
* @param K $key
*/
function with($key): void
{
[$key => 123];
}',
],
];
}

Expand Down

0 comments on commit 7a40443

Please sign in to comment.