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

Add test for mismatch param type from docblock

This commit is contained in:
adrew 2021-12-22 16:34:25 +03:00 committed by Bruce Weirdan
parent 63a1c71c83
commit 3d212c642c
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D

View File

@ -1318,6 +1318,42 @@ class CallableTest extends TestCase
c("hii");',
'error_message' => 'InvalidArgument',
],
'mismatchParamTypeFromDocblock' => [
'<?php
/**
* @template A
*/
final class ArrayList
{
/**
* @template B
* @param Closure(A): B $effect
* @return ArrayList<B>
*/
public function map(Closure $effect): ArrayList
{
throw new RuntimeException("???");
}
}
/**
* @template T
* @template B
*
* @param ArrayList<T> $list
* @return ArrayList<array{T}>
*/
function genericContext(ArrayList $list): ArrayList
{
return $list->map(
/** @param B $_a */
function ($_a) {
return [$_a];
}
);
}',
'error_message' => 'InvalidArgument',
]
];
}
}