mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Add simple test for high order function arg inference
This commit is contained in:
parent
cce1f9a407
commit
fac7115eae
@ -233,7 +233,36 @@ class CallableTest extends TestCase
|
||||
'$inferred' => 'list<Foo>',
|
||||
],
|
||||
],
|
||||
'inferPartiallyAppliedClosureArgByPreviousFunctionArg' => [
|
||||
'inferTemplateOfHighOrderFunctionArgByPreviousArg' => [
|
||||
'<?php
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
function getList() { throw new RuntimeException("???"); }
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @return Closure(T): T
|
||||
*/
|
||||
function id() { throw new RuntimeException("???"); }
|
||||
|
||||
/**
|
||||
* @template A
|
||||
* @template B
|
||||
*
|
||||
* @param list<A> $_items
|
||||
* @param callable(A): B $_ab
|
||||
* @return list<B>
|
||||
*/
|
||||
function map(array $_items, callable $_ab) { throw new RuntimeException("???"); }
|
||||
|
||||
$result = map(getList(), id());
|
||||
',
|
||||
'assertions' => [
|
||||
'$result' => 'list<int>',
|
||||
],
|
||||
],
|
||||
'inferPipelineWithPartiallyAppliedFunctions' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T
|
||||
|
Loading…
Reference in New Issue
Block a user