1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Prevent TypeParseException when dealing with nested template in assertion

This commit is contained in:
Matt Brown 2021-02-16 20:06:15 -05:00
parent 7b24552534
commit 196f24aac3
2 changed files with 14 additions and 1 deletions

View File

@ -510,7 +510,9 @@ class FunctionLikeDocblockScanner
$self_fqcln,
null,
true
)
),
null,
$function_template_types + $class_template_types
);
} catch (TypeParseTreeException $e) {
$storage->docblock_issues[] = new InvalidDocblock(

View File

@ -767,6 +767,17 @@ class FunctionTemplateAssertTest extends TestCase
}
}'
],
'noCrashWhenAssertingTemplatedKeyOf' => [
'<?php
/**
* @template TArray as array
* @template TCandidateKey as array-key
* @param TArray $arr
* @param array-key $key
* @psalm-assert key-of<TArray> $key
*/
function keyExists(array $arr, $key) : void {}'
],
];
}