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

Test contextual closure arg inference for class methods

This commit is contained in:
klimick 2023-04-24 00:00:15 +03:00
parent 88c444a8cc
commit cf0ca8b57a

View File

@ -145,6 +145,29 @@ class CallableTest extends TestCase
'$b' => 'ArrayList<list{int}>',
],
],
'inferArgByPreviousMethodArg' => [
'code' => '<?php
final class ArrayList
{
/**
* @template A
* @template B
* @template C
* @param list<A> $list
* @param callable(A): B $first
* @param callable(B): C $second
* @return list<C>
*/
public function map(array $list, callable $first, callable $second): array
{
throw new RuntimeException("never");
}
}
$result = (new ArrayList())->map([1, 2, 3], fn($i) => ["num" => $i], fn($i) => ["object" => $i]);',
'assertions' => [
'$result' => 'list<array{object: array{num: int}}>',
],
],
'inferArgByPreviousFunctionArg' => [
'code' => '<?php
/**