From ecf306d4b480e48d55ea55bbd0969746b8f1fb4f Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 21 Nov 2022 12:59:09 +0300 Subject: [PATCH] Build new doc --- doc/Psalm.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/doc/Psalm.md b/doc/Psalm.md index eb512b7d..be67479e 100644 --- a/doc/Psalm.md +++ b/doc/Psalm.md @@ -11,6 +11,8 @@ - [N-combinators](#N-combinators) - [proveTrue](#proveTrue) - [toEither](#toEither) + - [partitionT](#partitionT) + - [filterNotNull](#filterNotNull) # Static analysis @@ -349,3 +351,49 @@ $ vendor/bin/psalm-plugin enable fp4php/functional return $separated->toEither(); } ``` + + - #### partitionT + + Plugin infers each `list` type from predicates of `partitionT`: + + ``` php + $list + * @return array{list, list, list} + */ + function testExhaustiveInference(array $list): array + { + return partitionT($list, fn($i) => $i instanceof Foo, fn($i) => $i instanceof Bar); + } + ``` + + - #### filterNotNull + + Plugin turns all nullable keys to possibly undefined keys: + + ``` php +