Skip to content

Commit 480066f

Browse files
committed
Docs about partitionT in PsalmSupport.md
1 parent 1f9aa2f commit 480066f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/Doc/Md/Psalm/1_PsalmSupport.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,28 @@ $ vendor/bin/psalm-plugin enable fp4php/functional
321321
return $separated->toEither();
322322
}
323323
```
324-
324+
325+
- #### partitionT
326+
327+
Plugin infers each `list` type from predicates of `partitionT`:
328+
329+
```php
330+
<?php
331+
332+
declare(strict_types=1);
333+
334+
use Tests\Mock\Foo;
335+
use Tests\Mock\Bar;
336+
use Tests\Mock\Baz;
337+
338+
use function Fp\Collection\partitionT;
339+
340+
/**
341+
* @param list<Foo|Bar|Baz> $list
342+
* @return array{list<Foo>, list<Bar>, list<Baz>}
343+
*/
344+
function testExhaustiveInference(array $list): array
345+
{
346+
return partitionT($list, fn($i) => $i instanceof Foo, fn($i) => $i instanceof Bar);
347+
}
348+
```

0 commit comments

Comments
 (0)