Skip to content

Commit

Permalink
fix frames types transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Dec 3, 2023
1 parent b1a20b5 commit 11b9d58
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- `Innmind\IO\Readable\Frame\NoOp` constructor type
- Frames types transitions via `::filter()`, `::map()` and `::flatMap()`

## 2.4.0 - 2023-12-03

Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public static function of(int $size): self

/**
* @psalm-mutation-free
*
* @param callable(Str): bool $predicate
*
* @return Frame<Str>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -56,6 +60,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Str): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -64,6 +74,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Str): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Chunks.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function until(int $size, callable $predicate): self

/**
* @psalm-mutation-free
*
* @param callable(Seq<Str>): bool $predicate
*
* @return Frame<Seq<Str>>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -108,6 +112,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Seq<Str>): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -116,6 +126,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Seq<Str>): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public static function of(Frame $frame, callable $predicate): self

/**
* @psalm-mutation-free
*
* @param callable(T): bool $predicate
*
* @return Frame<T>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -62,6 +66,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(T): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -70,6 +80,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(T): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/FlatMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public static function of(Frame $frame, callable $map): self

/**
* @psalm-mutation-free
*
* @param callable(U): bool $predicate
*
* @return Frame<U>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -65,6 +69,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template V
*
* @param callable(U): V $map
*
* @return Frame<V>
*/
public function map(callable $map): Frame
{
Expand All @@ -73,6 +83,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template V
*
* @param callable(U): Frame<V> $map
*
* @return Frame<V>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public static function new(): self

/**
* @psalm-mutation-free
*
* @param callable(Str): bool $predicate
*
* @return Frame<Str>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -46,6 +50,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Str): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -54,6 +64,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Str): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public static function of(Frame $frame, callable $map): self

/**
* @psalm-mutation-free
*
* @param callable(U): bool $predicate
*
* @return Frame<U>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -64,6 +68,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template V
*
* @param callable(U): V $map
*
* @return Frame<V>
*/
public function map(callable $map): Frame
{
Expand All @@ -72,6 +82,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template V
*
* @param callable(U): Frame<V> $map
*
* @return Frame<V>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/NoOp.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public static function of(mixed $value): self

/**
* @psalm-mutation-free
*
* @param callable(T): bool $predicate
*
* @return Frame<T>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -60,6 +64,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(T): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -68,6 +78,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(T): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down
16 changes: 16 additions & 0 deletions src/Readable/Frame/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public function until(callable $predicate): self

/**
* @psalm-mutation-free
*
* @param callable(Seq<T>): bool $predicate
*
* @return Frame<Seq<T>>
*/
public function filter(callable $predicate): Frame
{
Expand All @@ -90,6 +94,12 @@ public function filter(callable $predicate): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Seq<T>): U $map
*
* @return Frame<U>
*/
public function map(callable $map): Frame
{
Expand All @@ -98,6 +108,12 @@ public function map(callable $map): Frame

/**
* @psalm-mutation-free
*
* @template U
*
* @param callable(Seq<T>): Frame<U> $map
*
* @return Frame<U>
*/
public function flatMap(callable $map): Frame
{
Expand Down

0 comments on commit 11b9d58

Please sign in to comment.