1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Add test for high order function arg inference in class context

This commit is contained in:
adrew 2022-01-18 13:12:01 +03:00
parent 6f9b6f8538
commit 3886d5b4c6

View File

@ -262,6 +262,39 @@ class CallableTest extends TestCase
'$result' => 'list<int>',
],
],
'inferTemplateOfHighOrderFunctionArgByPreviousArgInClassContext' => [
'<?php
/**
* @template A
*/
final class ArrayList
{
/**
* @template B
*
* @param callable(A): B $ab
* @return ArrayList<B>
*/
public function map(callable $ab) { throw new RuntimeException("???"); }
}
/**
* @return ArrayList<int>
*/
function getList() { throw new RuntimeException("???"); }
/**
* @template T
* @return Closure(T): T
*/
function id() { throw new RuntimeException("???"); }
$result = getList()->map(id());
',
'assertions' => [
'$result' => 'ArrayList<int>',
],
],
'inferPipelineWithPartiallyAppliedFunctions' => [
'<?php
/**