From fac7115eaed89cd87ac5ddbf0e3f1aaef5f4b8ce Mon Sep 17 00:00:00 2001 From: adrew Date: Tue, 18 Jan 2022 12:48:53 +0300 Subject: [PATCH] Add simple test for high order function arg inference --- tests/CallableTest.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/CallableTest.php b/tests/CallableTest.php index 917099a0f..05fc088be 100644 --- a/tests/CallableTest.php +++ b/tests/CallableTest.php @@ -233,7 +233,36 @@ class CallableTest extends TestCase '$inferred' => 'list', ], ], - 'inferPartiallyAppliedClosureArgByPreviousFunctionArg' => [ + 'inferTemplateOfHighOrderFunctionArgByPreviousArg' => [ + ' + */ + function getList() { throw new RuntimeException("???"); } + + /** + * @template T + * @return Closure(T): T + */ + function id() { throw new RuntimeException("???"); } + + /** + * @template A + * @template B + * + * @param list $_items + * @param callable(A): B $_ab + * @return list + */ + function map(array $_items, callable $_ab) { throw new RuntimeException("???"); } + + $result = map(getList(), id()); + ', + 'assertions' => [ + '$result' => 'list', + ], + ], + 'inferPipelineWithPartiallyAppliedFunctions' => [ '