diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1048641c9..78422b8bf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -75,6 +75,11 @@ parameters: count: 1 path: src/Operation/Head.php + - + message: "#^Parameter \\#1 \\.\\.\\.\\$ of closure expects callable\\(mixed, mixed, iterable\\)\\: bool, Closure\\(mixed, mixed, CachingIterator\\)\\: bool given\\.$#" + count: 1 + path: src/Operation/Init.php + - message: "#^Foreach overwrites \\$current with its value variable\\.$#" count: 1 diff --git a/src/Contract/Operation.php b/src/Contract/Operation.php index 7e7a5b95b..c1adde937 100644 --- a/src/Contract/Operation.php +++ b/src/Contract/Operation.php @@ -11,16 +11,12 @@ use Closure; -/** @immutable */ +/** + * @immutable + */ interface Operation { - /** - * @pure - */ public function __invoke(): Closure; - /** - * @pure - */ public static function of(): Closure; } diff --git a/src/Operation/AbstractOperation.php b/src/Operation/AbstractOperation.php index 2a4253419..d42b2ed53 100644 --- a/src/Operation/AbstractOperation.php +++ b/src/Operation/AbstractOperation.php @@ -17,16 +17,10 @@ */ abstract class AbstractOperation implements Operation { - /** - * @pure - */ final public function __construct() { } - /** - * @pure - */ public static function of(): Closure { return (new static())->__invoke(); diff --git a/src/Operation/All.php b/src/Operation/All.php index d0b6f7a1e..cbf8c874c 100644 --- a/src/Operation/All.php +++ b/src/Operation/All.php @@ -20,8 +20,6 @@ final class All extends AbstractOperation { /** - * @pure - * * @return Closure(bool): Closure(iterable): iterable|iterable */ public function __invoke(): Closure diff --git a/src/Operation/Append.php b/src/Operation/Append.php index 9f195849d..28f9519cc 100644 --- a/src/Operation/Append.php +++ b/src/Operation/Append.php @@ -24,8 +24,6 @@ final class Append extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Apply.php b/src/Operation/Apply.php index 5846fd91d..3be9b922d 100644 --- a/src/Operation/Apply.php +++ b/src/Operation/Apply.php @@ -23,8 +23,6 @@ final class Apply extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=):bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Associate.php b/src/Operation/Associate.php index 788281cb5..a280f1aeb 100644 --- a/src/Operation/Associate.php +++ b/src/Operation/Associate.php @@ -23,8 +23,6 @@ final class Associate extends AbstractOperation { /** - * @pure - * * @template NewTKey * @template NewT * diff --git a/src/Operation/AsyncMap.php b/src/Operation/AsyncMap.php index 5e2420121..f742300f4 100644 --- a/src/Operation/AsyncMap.php +++ b/src/Operation/AsyncMap.php @@ -36,8 +36,6 @@ final class AsyncMap extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(callable(T, TKey): V): Closure(iterable): Generator diff --git a/src/Operation/AsyncMapN.php b/src/Operation/AsyncMapN.php index ffed4518e..a8bc0b12c 100644 --- a/src/Operation/AsyncMapN.php +++ b/src/Operation/AsyncMapN.php @@ -36,8 +36,6 @@ final class AsyncMapN extends AbstractOperation { /** - * @pure - * * @return Closure(callable(mixed, mixed): mixed ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Cache.php b/src/Operation/Cache.php index c281756db..b75098ca2 100644 --- a/src/Operation/Cache.php +++ b/src/Operation/Cache.php @@ -26,8 +26,6 @@ final class Cache extends AbstractOperation { /** - * @pure - * * @return Closure(CacheItemPoolInterface): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Chunk.php b/src/Operation/Chunk.php index d7aa3bfca..aac0bd573 100644 --- a/src/Operation/Chunk.php +++ b/src/Operation/Chunk.php @@ -24,8 +24,6 @@ final class Chunk extends AbstractOperation { /** - * @pure - * * @return Closure(int...): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Coalesce.php b/src/Operation/Coalesce.php index 3731ccd96..14b9cccdf 100644 --- a/src/Operation/Coalesce.php +++ b/src/Operation/Coalesce.php @@ -21,16 +21,14 @@ final class Coalesce extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Compact::of()(), - Head::of(), + $pipe = (new Pipe())()( + (new Compact())()(), + (new Head())(), ); // Point free style. diff --git a/src/Operation/Collapse.php b/src/Operation/Collapse.php index 0f515d8c7..f3f742880 100644 --- a/src/Operation/Collapse.php +++ b/src/Operation/Collapse.php @@ -21,8 +21,6 @@ final class Collapse extends AbstractOperation { /** - * @pure - * * @psalm-suppress ImpureFunctionCall - using Filter and Flatten as an internal tools, not returned. * * @return Closure(iterable)>): Generator diff --git a/src/Operation/Column.php b/src/Operation/Column.php index e4a386464..a0d50611a 100644 --- a/src/Operation/Column.php +++ b/src/Operation/Column.php @@ -21,8 +21,6 @@ final class Column extends AbstractOperation { /** - * @pure - * * @return Closure(mixed): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Combinate.php b/src/Operation/Combinate.php index 8a73e5f82..035789f83 100644 --- a/src/Operation/Combinate.php +++ b/src/Operation/Combinate.php @@ -23,9 +23,6 @@ */ final class Combinate extends AbstractOperation { - /** - * @pure - */ public function __invoke(): Closure { return static function (?int $length = null): Closure { diff --git a/src/Operation/Combine.php b/src/Operation/Combine.php index b2bc04fad..d214552d7 100644 --- a/src/Operation/Combine.php +++ b/src/Operation/Combine.php @@ -25,8 +25,6 @@ final class Combine extends AbstractOperation { /** - * @pure - * * @template U * * @return Closure(U...): Closure(iterable): Generator diff --git a/src/Operation/Compact.php b/src/Operation/Compact.php index e8c918551..b590a8c92 100644 --- a/src/Operation/Compact.php +++ b/src/Operation/Compact.php @@ -25,8 +25,6 @@ final class Compact extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Contains.php b/src/Operation/Contains.php index 66107c01f..c095dbb5c 100644 --- a/src/Operation/Contains.php +++ b/src/Operation/Contains.php @@ -21,8 +21,6 @@ final class Contains extends AbstractOperation { /** - * @pure - * * @return Closure(T ...$values): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Current.php b/src/Operation/Current.php index 4194c9b4f..250ce35c9 100644 --- a/src/Operation/Current.php +++ b/src/Operation/Current.php @@ -21,8 +21,6 @@ final class Current extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(TKey): Closure(V): Closure(iterable): Generator diff --git a/src/Operation/Cycle.php b/src/Operation/Cycle.php index b2be36ca5..e73f6a33b 100644 --- a/src/Operation/Cycle.php +++ b/src/Operation/Cycle.php @@ -22,8 +22,6 @@ final class Cycle extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): iterable */ public function __invoke(): Closure diff --git a/src/Operation/Diff.php b/src/Operation/Diff.php index 833a6dff6..6073d590c 100644 --- a/src/Operation/Diff.php +++ b/src/Operation/Diff.php @@ -23,8 +23,6 @@ final class Diff extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/DiffKeys.php b/src/Operation/DiffKeys.php index 8150eb3aa..13e21ad9a 100644 --- a/src/Operation/DiffKeys.php +++ b/src/Operation/DiffKeys.php @@ -23,8 +23,6 @@ final class DiffKeys extends AbstractOperation { /** - * @pure - * * @return Closure(TKey...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Distinct.php b/src/Operation/Distinct.php index 52be54516..43f3a9f85 100644 --- a/src/Operation/Distinct.php +++ b/src/Operation/Distinct.php @@ -23,8 +23,6 @@ final class Distinct extends AbstractOperation { /** - * @pure - * * @template U * * @return Closure(callable(U): Closure(U): bool): Closure(callable(T, TKey): U): Closure(iterable): Generator diff --git a/src/Operation/Drop.php b/src/Operation/Drop.php index 3acaaae0f..48c765e5b 100644 --- a/src/Operation/Drop.php +++ b/src/Operation/Drop.php @@ -23,12 +23,10 @@ final class Drop extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure { - return Limit::of()(-1); + return (new Limit())()(-1); } } diff --git a/src/Operation/DropWhile.php b/src/Operation/DropWhile.php index 86c4883df..257077674 100644 --- a/src/Operation/DropWhile.php +++ b/src/Operation/DropWhile.php @@ -24,8 +24,6 @@ final class DropWhile extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Dump.php b/src/Operation/Dump.php index ecbdc32a3..177da0fda 100644 --- a/src/Operation/Dump.php +++ b/src/Operation/Dump.php @@ -24,8 +24,6 @@ final class Dump extends AbstractOperation { /** - * @pure - * * @return Closure(string): Closure(int): Closure(?Closure): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Duplicate.php b/src/Operation/Duplicate.php index 99529d7c0..0348fbac4 100644 --- a/src/Operation/Duplicate.php +++ b/src/Operation/Duplicate.php @@ -23,8 +23,6 @@ final class Duplicate extends AbstractOperation { /** - * @pure - * * @template U * * @return Closure(callable(U): Closure(U): bool): Closure(callable(T, TKey): U): Closure(iterable): Generator diff --git a/src/Operation/Equals.php b/src/Operation/Equals.php index 82017087f..77b44071c 100644 --- a/src/Operation/Equals.php +++ b/src/Operation/Equals.php @@ -24,8 +24,6 @@ final class Equals extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Every.php b/src/Operation/Every.php index a565f6461..020388196 100644 --- a/src/Operation/Every.php +++ b/src/Operation/Every.php @@ -24,8 +24,6 @@ final class Every extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T, TKey, iterable...): bool): Closure(callable(T, TKey, iterable...): bool): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Explode.php b/src/Operation/Explode.php index 4231488ef..8dbeb7d7e 100644 --- a/src/Operation/Explode.php +++ b/src/Operation/Explode.php @@ -22,8 +22,6 @@ final class Explode extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Falsy.php b/src/Operation/Falsy.php index d7e5317f8..f0c95608b 100644 --- a/src/Operation/Falsy.php +++ b/src/Operation/Falsy.php @@ -21,8 +21,6 @@ final class Falsy extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -35,15 +33,15 @@ public function __invoke(): Closure static fn (bool $value): bool => $value; /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Map::of()( + $pipe = (new Pipe())()( + (new Map())()( /** * @param T $value */ static fn ($value): bool => (bool) $value ), - MatchOne::of()($matchWhenNot)($matcher), - Map::of()( + (new MatchOne())()($matchWhenNot)($matcher), + (new Map())()( /** * @param bool $value */ diff --git a/src/Operation/Filter.php b/src/Operation/Filter.php index ba2c95489..0747b9ed7 100644 --- a/src/Operation/Filter.php +++ b/src/Operation/Filter.php @@ -24,8 +24,6 @@ final class Filter extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Find.php b/src/Operation/Find.php index 02d5592b2..0822087bd 100644 --- a/src/Operation/Find.php +++ b/src/Operation/Find.php @@ -23,8 +23,6 @@ final class Find extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(V): Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator diff --git a/src/Operation/First.php b/src/Operation/First.php index 593da9456..d6d90c81f 100644 --- a/src/Operation/First.php +++ b/src/Operation/First.php @@ -21,14 +21,12 @@ final class First extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $head */ - $head = Head::of(); + $head = (new Head())(); // Point free style. return $head; diff --git a/src/Operation/FlatMap.php b/src/Operation/FlatMap.php index 3a977122a..a5e49f3d5 100644 --- a/src/Operation/FlatMap.php +++ b/src/Operation/FlatMap.php @@ -23,8 +23,6 @@ final class FlatMap extends AbstractOperation { /** - * @pure - * * @template IKey * @template IValue * diff --git a/src/Operation/Flatten.php b/src/Operation/Flatten.php index 56859f35d..ede0100fb 100644 --- a/src/Operation/Flatten.php +++ b/src/Operation/Flatten.php @@ -21,8 +21,6 @@ final class Flatten extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Flip.php b/src/Operation/Flip.php index 9d115b50c..90535aa92 100644 --- a/src/Operation/Flip.php +++ b/src/Operation/Flip.php @@ -21,8 +21,6 @@ final class Flip extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -46,7 +44,7 @@ public function __invoke(): Closure static fn ($value, $key) => $key; /** @var Closure(iterable): Generator $associate */ - $associate = Associate::of()($callbackForKeys)($callbackForValues); + $associate = (new Associate())()($callbackForKeys)($callbackForValues); // Point free style. return $associate; diff --git a/src/Operation/FoldLeft.php b/src/Operation/FoldLeft.php index 4a75e26bc..9c8073659 100644 --- a/src/Operation/FoldLeft.php +++ b/src/Operation/FoldLeft.php @@ -23,8 +23,6 @@ final class FoldLeft extends AbstractOperation { /** - * @pure - * * @return Closure(callable((T|null), T, TKey, iterable):(T|null)): Closure(T): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/FoldLeft1.php b/src/Operation/FoldLeft1.php index b66b616fd..ac6c95e32 100644 --- a/src/Operation/FoldLeft1.php +++ b/src/Operation/FoldLeft1.php @@ -23,8 +23,6 @@ final class FoldLeft1 extends AbstractOperation { /** - * @pure - * * @return Closure(callable((T|null), T, TKey, iterable):(T|null)): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/FoldRight.php b/src/Operation/FoldRight.php index 48eed1f2b..a96bbdc64 100644 --- a/src/Operation/FoldRight.php +++ b/src/Operation/FoldRight.php @@ -23,8 +23,6 @@ final class FoldRight extends AbstractOperation { /** - * @pure - * * @return Closure(callable((T|null), T, TKey, iterable):(T|null)): Closure(T): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/FoldRight1.php b/src/Operation/FoldRight1.php index 5baef5ac7..8f1a1f0d7 100644 --- a/src/Operation/FoldRight1.php +++ b/src/Operation/FoldRight1.php @@ -23,8 +23,6 @@ final class FoldRight1 extends AbstractOperation { /** - * @pure - * * @return Closure(callable((T|null), T, TKey, iterable): (T|null)):Closure (iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Forget.php b/src/Operation/Forget.php index d71dec49a..0c7cf1dfe 100644 --- a/src/Operation/Forget.php +++ b/src/Operation/Forget.php @@ -23,8 +23,6 @@ final class Forget extends AbstractOperation { /** - * @pure - * * @return Closure(TKey...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Frequency.php b/src/Operation/Frequency.php index 0334544a8..765999959 100644 --- a/src/Operation/Frequency.php +++ b/src/Operation/Frequency.php @@ -21,8 +21,6 @@ final class Frequency extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -56,10 +54,10 @@ static function (array $storage, $value): array { }; /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Reduce::of()($reduceCallback)([]), - Flatten::of()(1), - Unpack::of() + $pipe = (new Pipe())()( + (new Reduce())()($reduceCallback)([]), + (new Flatten())()(1), + (new Unpack())() ); // Point free style. diff --git a/src/Operation/Get.php b/src/Operation/Get.php index c0e4154c6..171f3a241 100644 --- a/src/Operation/Get.php +++ b/src/Operation/Get.php @@ -21,8 +21,6 @@ final class Get extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(TKey): Closure(V): Closure(iterable): Generator diff --git a/src/Operation/Group.php b/src/Operation/Group.php index d94fc4367..4db99669b 100644 --- a/src/Operation/Group.php +++ b/src/Operation/Group.php @@ -21,8 +21,6 @@ final class Group extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/GroupBy.php b/src/Operation/GroupBy.php index 61aa1fd7b..cc2c401b2 100644 --- a/src/Operation/GroupBy.php +++ b/src/Operation/GroupBy.php @@ -23,8 +23,6 @@ final class GroupBy extends AbstractOperation { /** - * @pure - * * @template NewTKey of array-key * * @return Closure(callable(T=, TKey=): NewTKey): Closure(iterable): Generator> diff --git a/src/Operation/Has.php b/src/Operation/Has.php index a8e90190f..63290b751 100644 --- a/src/Operation/Has.php +++ b/src/Operation/Has.php @@ -23,8 +23,6 @@ final class Has extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): T ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Head.php b/src/Operation/Head.php index 5017641b2..7a0ca57dc 100644 --- a/src/Operation/Head.php +++ b/src/Operation/Head.php @@ -21,8 +21,6 @@ final class Head extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/IfThenElse.php b/src/Operation/IfThenElse.php index c4eeef0fa..c43ef89fa 100644 --- a/src/Operation/IfThenElse.php +++ b/src/Operation/IfThenElse.php @@ -23,8 +23,6 @@ final class IfThenElse extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool): Closure(callable(T=, TKey=, iterable=): T): Closure(callable(T=, TKey=, iterable=): T): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Implode.php b/src/Operation/Implode.php index fe7a7c032..a3676a5e7 100644 --- a/src/Operation/Implode.php +++ b/src/Operation/Implode.php @@ -23,8 +23,6 @@ final class Implode extends AbstractOperation { /** - * @pure - * * @return Closure(string): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Init.php b/src/Operation/Init.php index 8edc2526f..246a03a79 100644 --- a/src/Operation/Init.php +++ b/src/Operation/Init.php @@ -25,9 +25,8 @@ final class Init extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator + * @psalm-suppress InvalidArgument */ public function __invoke(): Closure { @@ -48,9 +47,9 @@ public function __invoke(): Closure static fn (iterable $iterator): CachingIterator => new CachingIterator((new IterableIteratorAggregate($iterator))->getIterator(), CachingIterator::FULL_CACHE); /** @var Closure(iterable): Generator $takeWhile */ - $takeWhile = Pipe::of()( + $takeWhile = (new Pipe())()( $buildCachingIterator, - TakeWhile::of()($callback) + (new TakeWhile())()($callback) ); // Point free style. diff --git a/src/Operation/Inits.php b/src/Operation/Inits.php index 67cbfecdd..1e919a921 100644 --- a/src/Operation/Inits.php +++ b/src/Operation/Inits.php @@ -21,8 +21,6 @@ final class Inits extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator> */ public function __invoke(): Closure @@ -41,9 +39,9 @@ static function (array $carry, array $value): array { }; /** @var Closure(iterable): Generator> $inits */ - $inits = Pipe::of()( - Pack::of(), - ScanLeft::of()($scanLeftCallback)([]), + $inits = (new Pipe())()( + (new Pack())(), + (new ScanLeft())()($scanLeftCallback)([]), (new Normalize())() ); diff --git a/src/Operation/Intersect.php b/src/Operation/Intersect.php index a93800091..b4bb946c7 100644 --- a/src/Operation/Intersect.php +++ b/src/Operation/Intersect.php @@ -23,8 +23,6 @@ final class Intersect extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/IntersectKeys.php b/src/Operation/IntersectKeys.php index 7b573df85..83b1fbe41 100644 --- a/src/Operation/IntersectKeys.php +++ b/src/Operation/IntersectKeys.php @@ -23,8 +23,6 @@ final class IntersectKeys extends AbstractOperation { /** - * @pure - * * @return Closure(TKey...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Intersperse.php b/src/Operation/Intersperse.php index 50f2c4543..e7dcd0249 100644 --- a/src/Operation/Intersperse.php +++ b/src/Operation/Intersperse.php @@ -24,8 +24,6 @@ final class Intersperse extends AbstractOperation { /** - * @pure - * * @return Closure(T): Closure(int): Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/IsEmpty.php b/src/Operation/IsEmpty.php index cce075e03..e50c8699e 100644 --- a/src/Operation/IsEmpty.php +++ b/src/Operation/IsEmpty.php @@ -24,8 +24,6 @@ final class IsEmpty extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Key.php b/src/Operation/Key.php index 56cc0dbf0..9358ce606 100644 --- a/src/Operation/Key.php +++ b/src/Operation/Key.php @@ -21,8 +21,6 @@ final class Key extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Keys.php b/src/Operation/Keys.php index dcd60bfcc..11614d74e 100644 --- a/src/Operation/Keys.php +++ b/src/Operation/Keys.php @@ -21,15 +21,13 @@ final class Keys extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Flip::of(), + $pipe = (new Pipe())()( + (new Flip())(), (new Normalize())() ); diff --git a/src/Operation/Last.php b/src/Operation/Last.php index 8a65a7838..966b46910 100644 --- a/src/Operation/Last.php +++ b/src/Operation/Last.php @@ -21,8 +21,6 @@ final class Last extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Limit.php b/src/Operation/Limit.php index be14fcde5..9348fe7f5 100644 --- a/src/Operation/Limit.php +++ b/src/Operation/Limit.php @@ -24,8 +24,6 @@ final class Limit extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Lines.php b/src/Operation/Lines.php index 4acb112af..72a19da45 100644 --- a/src/Operation/Lines.php +++ b/src/Operation/Lines.php @@ -23,8 +23,6 @@ final class Lines extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -36,9 +34,9 @@ public function __invoke(): Closure static fn (array $value): string => implode('', $value); /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Explode::of()(PHP_EOL, "\n", "\r\n"), - Map::of()($mapCallback) + $pipe = (new Pipe())()( + (new Explode())()(PHP_EOL, "\n", "\r\n"), + (new Map())()($mapCallback) ); // Point free style. diff --git a/src/Operation/Map.php b/src/Operation/Map.php index dbc01ae65..b544981c4 100644 --- a/src/Operation/Map.php +++ b/src/Operation/Map.php @@ -23,8 +23,6 @@ final class Map extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(callable(T=, TKey=, iterable=): mixed): Closure(iterable): Generator diff --git a/src/Operation/MapN.php b/src/Operation/MapN.php index 3e6d0f09e..04c3de4cf 100644 --- a/src/Operation/MapN.php +++ b/src/Operation/MapN.php @@ -23,8 +23,6 @@ final class MapN extends AbstractOperation { /** - * @pure - * * @return Closure(callable(mixed, mixed, iterable): mixed ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/MatchOne.php b/src/Operation/MatchOne.php index 2e2162838..7dcc82ab9 100644 --- a/src/Operation/MatchOne.php +++ b/src/Operation/MatchOne.php @@ -24,8 +24,6 @@ final class MatchOne extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Matching.php b/src/Operation/Matching.php index 4d03db518..aa3412baa 100644 --- a/src/Operation/Matching.php +++ b/src/Operation/Matching.php @@ -26,8 +26,6 @@ final class Matching extends AbstractOperation { /** - * @pure - * * @return Closure(Criteria): Closure(iterable): Generator */ public function __invoke(): Closure @@ -53,18 +51,16 @@ static function (Criteria $criteria): Closure { $next = ClosureExpressionVisitor::sortByField($field, Criteria::DESC === $ordering ? -1 : 1, $next); } - $pipes[] = Sort::of()(Sortable::BY_VALUES)($next); + $pipes[] = (new Sort())()(Sortable::BY_VALUES)($next); } $offset = $criteria->getFirstResult(); $length = $criteria->getMaxResults(); - if (null !== $offset || null !== $length) { - $pipes[] = Limit::of()($length)((int) $offset); - } + $pipes[] = (new Limit())()(null !== $length ? $length : -1)(null !== $offset ? $offset : 0); /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()(...$pipes); + $pipe = (new Pipe())()(...$pipes); // Point free style. return $pipe; diff --git a/src/Operation/Merge.php b/src/Operation/Merge.php index 619f98909..1b96dd103 100644 --- a/src/Operation/Merge.php +++ b/src/Operation/Merge.php @@ -24,8 +24,6 @@ final class Merge extends AbstractOperation { /** - * @pure - * * @return Closure(iterable ...$sources): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Normalize.php b/src/Operation/Normalize.php index df4fcf6a5..260122e31 100644 --- a/src/Operation/Normalize.php +++ b/src/Operation/Normalize.php @@ -22,8 +22,6 @@ final class Normalize extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Nth.php b/src/Operation/Nth.php index c77ffa760..4f7aa9a47 100644 --- a/src/Operation/Nth.php +++ b/src/Operation/Nth.php @@ -21,8 +21,6 @@ final class Nth extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Nullsy.php b/src/Operation/Nullsy.php index aa42ff72a..83c33838f 100644 --- a/src/Operation/Nullsy.php +++ b/src/Operation/Nullsy.php @@ -30,8 +30,6 @@ final class Nullsy extends AbstractOperation public const VALUES = [null, [], 0, false, '']; /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -44,15 +42,15 @@ public function __invoke(): Closure static fn (bool $value): bool => in_array($value, self::VALUES, true); /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Map::of()( + $pipe = (new Pipe())()( + (new Map())()( /** * @param T $value */ static fn ($value): bool => (bool) $value ), - MatchOne::of()($matchWhenNot)($matcher), - Map::of()( + (new MatchOne())()($matchWhenNot)($matcher), + (new Map())()( /** * @param bool $value */ diff --git a/src/Operation/Pack.php b/src/Operation/Pack.php index d1dbb4916..3a504249e 100644 --- a/src/Operation/Pack.php +++ b/src/Operation/Pack.php @@ -22,8 +22,6 @@ final class Pack extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Pad.php b/src/Operation/Pad.php index 9e36abc8e..32988276d 100644 --- a/src/Operation/Pad.php +++ b/src/Operation/Pad.php @@ -21,8 +21,6 @@ final class Pad extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(T): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Pair.php b/src/Operation/Pair.php index 345e088d6..ce06e8f41 100644 --- a/src/Operation/Pair.php +++ b/src/Operation/Pair.php @@ -21,8 +21,6 @@ final class Pair extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -45,10 +43,10 @@ public function __invoke(): Closure static fn (array $value) => $value[1] ?? null; /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Chunk::of()(2), - Map::of()(static fn (array $value): array => array_values($value)), - Associate::of()($callbackForKeys)($callbackForValues) + $pipe = (new Pipe())()( + (new Chunk())()(2), + (new Map())()(static fn (array $value): array => array_values($value)), + (new Associate())()($callbackForKeys)($callbackForValues) ); // Point free style. diff --git a/src/Operation/Partition.php b/src/Operation/Partition.php index 1c8cdc4f9..ca95c4ac3 100644 --- a/src/Operation/Partition.php +++ b/src/Operation/Partition.php @@ -26,8 +26,6 @@ final class Partition extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Permutate.php b/src/Operation/Permutate.php index 4d2e4ee48..1e5f77ddb 100644 --- a/src/Operation/Permutate.php +++ b/src/Operation/Permutate.php @@ -23,9 +23,6 @@ */ final class Permutate extends AbstractOperation { - /** - * @pure - */ public function __invoke(): Closure { $getPermutations = diff --git a/src/Operation/Pipe.php b/src/Operation/Pipe.php index 9d96f3089..cdeb4e8c0 100644 --- a/src/Operation/Pipe.php +++ b/src/Operation/Pipe.php @@ -22,8 +22,6 @@ final class Pipe extends AbstractOperation { /** - * @pure - * * @return Closure(callable(iterable): iterable ...): Closure(iterable): iterable */ public function __invoke(): Closure diff --git a/src/Operation/Pluck.php b/src/Operation/Pluck.php index 62c604257..30db4ddb2 100644 --- a/src/Operation/Pluck.php +++ b/src/Operation/Pluck.php @@ -31,8 +31,6 @@ final class Pluck extends AbstractOperation { /** - * @pure - * * @return Closure(T):Closure(T):Closure(iterable):Generator, mixed, void> */ public function __invoke(): Closure @@ -80,7 +78,7 @@ static function (iterable $iterable, $target, array $key, $default = null) use ( } /** @var Generator $collapse */ - $collapse = Collapse::of()($result); + $collapse = (new Collapse())()($result); return in_array('*', $key, true) ? $collapse : $result; } @@ -93,7 +91,7 @@ static function (iterable $iterable, $target, array $key, $default = null) use ( $target = $target[$segment]; } elseif ($target instanceof Collection) { /** @var T $target */ - $target = (Get::of()($segment)($default)($target))->current(); + $target = ((new Get())()($segment)($default)($target))->current(); } elseif (is_object($target) && property_exists($target, $segment)) { /** @var T $target */ $target = (new ReflectionClass($target))->getProperty($segment)->getValue($target); diff --git a/src/Operation/Prepend.php b/src/Operation/Prepend.php index 03fd62f6d..6cb9ca6a7 100644 --- a/src/Operation/Prepend.php +++ b/src/Operation/Prepend.php @@ -24,8 +24,6 @@ final class Prepend extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(iterable): iterable */ public function __invoke(): Closure diff --git a/src/Operation/Product.php b/src/Operation/Product.php index c6e995e5f..a17e67856 100644 --- a/src/Operation/Product.php +++ b/src/Operation/Product.php @@ -25,8 +25,6 @@ final class Product extends AbstractOperation { /** - * @pure - * * @template UKey * @template U */ diff --git a/src/Operation/RSample.php b/src/Operation/RSample.php index 383a9b7ea..c27f8de2e 100644 --- a/src/Operation/RSample.php +++ b/src/Operation/RSample.php @@ -23,8 +23,6 @@ final class RSample extends AbstractOperation { /** - * @pure - * * @return Closure(float): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Random.php b/src/Operation/Random.php index 91670f5e0..d97155a28 100644 --- a/src/Operation/Random.php +++ b/src/Operation/Random.php @@ -21,8 +21,6 @@ final class Random extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Range.php b/src/Operation/Range.php index 9830ccf5b..265f801d8 100644 --- a/src/Operation/Range.php +++ b/src/Operation/Range.php @@ -25,8 +25,6 @@ final class Range extends AbstractOperation { /** - * @pure - * * @return Closure(float=): Closure(float=): Closure(float=): Closure(): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Reduce.php b/src/Operation/Reduce.php index d4c59ada9..389a9b9ff 100644 --- a/src/Operation/Reduce.php +++ b/src/Operation/Reduce.php @@ -23,8 +23,6 @@ final class Reduce extends AbstractOperation { /** - * @pure - * * @template V * @template W * diff --git a/src/Operation/Reduction.php b/src/Operation/Reduction.php index 4929cf1ca..5f26d8f30 100644 --- a/src/Operation/Reduction.php +++ b/src/Operation/Reduction.php @@ -23,8 +23,6 @@ final class Reduction extends AbstractOperation { /** - * @pure - * * @template V * @template W * diff --git a/src/Operation/Reject.php b/src/Operation/Reject.php index 6351771b8..72473aa96 100644 --- a/src/Operation/Reject.php +++ b/src/Operation/Reject.php @@ -24,8 +24,6 @@ final class Reject extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Reverse.php b/src/Operation/Reverse.php index 82b8c46cc..1ba75ba78 100644 --- a/src/Operation/Reverse.php +++ b/src/Operation/Reverse.php @@ -21,8 +21,6 @@ final class Reverse extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -37,9 +35,9 @@ public function __invoke(): Closure static fn (array $carry, array $value): array => [...$value, ...$carry]; /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( + $pipe = (new Pipe())()( (new Pack())(), - Reduce::of()($callback)([]), + (new Reduce())()($callback)([]), (new Unpack())(), ); diff --git a/src/Operation/Same.php b/src/Operation/Same.php index 1a9aa1530..0f2126fbf 100644 --- a/src/Operation/Same.php +++ b/src/Operation/Same.php @@ -24,8 +24,6 @@ final class Same extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Closure(callable(T, TKey): Closure(T, TKey): bool): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Scale.php b/src/Operation/Scale.php index 44b34c32f..b87c5e561 100644 --- a/src/Operation/Scale.php +++ b/src/Operation/Scale.php @@ -25,8 +25,6 @@ final class Scale extends AbstractOperation { /** - * @pure - * * @return Closure(float): Closure(float): Closure(float): Closure(float): Closure(float): Closure(iterable): Generator */ public function __invoke(): Closure @@ -54,7 +52,7 @@ public function __invoke(): Closure static function (float $base = 0.0) use ($lowerBound, $upperBound, $wantedLowerBound, $wantedUpperBound): Closure { $wantedLowerBound = (0.0 === $wantedLowerBound) ? (0.0 === $base ? 0.0 : 1.0) : $wantedLowerBound; $wantedUpperBound = (1.0 === $wantedUpperBound) ? (0.0 === $base ? 1.0 : $base) : $wantedUpperBound; - /** @var callable(Generator):Generator $mapper */ + $mapper = (new Map())()( /** * @param float|int $v @@ -82,7 +80,7 @@ static function ($v) use ($lowerBound, $upperBound, $wantedLowerBound, $wantedUp ); /** @var Closure(iterable):(Generator) $pipe */ - $pipe = Pipe::of()($filter, $mapper); + $pipe = (new Pipe())()($filter, $mapper); // Point free style. return $pipe; diff --git a/src/Operation/ScanLeft.php b/src/Operation/ScanLeft.php index 0e7535d13..fa4a959fd 100644 --- a/src/Operation/ScanLeft.php +++ b/src/Operation/ScanLeft.php @@ -23,8 +23,6 @@ final class ScanLeft extends AbstractOperation { /** - * @pure - * * @template V * @template W * diff --git a/src/Operation/ScanLeft1.php b/src/Operation/ScanLeft1.php index 16f2f3280..8ba33fd86 100644 --- a/src/Operation/ScanLeft1.php +++ b/src/Operation/ScanLeft1.php @@ -24,8 +24,6 @@ final class ScanLeft1 extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(callable(mixed, T, TKey, iterable): mixed): Closure(iterable): Generator diff --git a/src/Operation/ScanRight.php b/src/Operation/ScanRight.php index 64c858c66..fc60aec40 100644 --- a/src/Operation/ScanRight.php +++ b/src/Operation/ScanRight.php @@ -23,8 +23,6 @@ final class ScanRight extends AbstractOperation { /** - * @pure - * * @template V * @template W * diff --git a/src/Operation/ScanRight1.php b/src/Operation/ScanRight1.php index e6c14a4cf..24fd4ca83 100644 --- a/src/Operation/ScanRight1.php +++ b/src/Operation/ScanRight1.php @@ -23,8 +23,6 @@ final class ScanRight1 extends AbstractOperation { /** - * @pure - * * @template V * * @return Closure(callable(mixed, T, TKey, iterable): mixed): Closure(iterable): Generator diff --git a/src/Operation/Shuffle.php b/src/Operation/Shuffle.php index 1560cf507..3aa5f4b25 100644 --- a/src/Operation/Shuffle.php +++ b/src/Operation/Shuffle.php @@ -24,8 +24,6 @@ final class Shuffle extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Since.php b/src/Operation/Since.php index f659d9ac5..d892724ef 100644 --- a/src/Operation/Since.php +++ b/src/Operation/Since.php @@ -24,8 +24,6 @@ final class Since extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=):bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Slice.php b/src/Operation/Slice.php index c98325e49..cbfd46024 100644 --- a/src/Operation/Slice.php +++ b/src/Operation/Slice.php @@ -21,8 +21,6 @@ final class Slice extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(int=): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Sort.php b/src/Operation/Sort.php index 7461e16e3..d72f1d99b 100644 --- a/src/Operation/Sort.php +++ b/src/Operation/Sort.php @@ -26,8 +26,6 @@ final class Sort extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(callable(T|TKey, T|TKey): int): Closure(iterable): Generator */ public function __invoke(): Closure @@ -61,12 +59,12 @@ static function (iterable $iterable) use ($type, $callback): Generator { $operations = Operation\Sortable::BY_VALUES === $type ? [ - 'before' => [Pack::of()], - 'after' => [Unpack::of()], + 'before' => [(new Pack())()], + 'after' => [(new Unpack())()], ] : [ - 'before' => [Flip::of(), Pack::of()], - 'after' => [Unpack::of(), Flip::of()], + 'before' => [(new Flip())(), (new Pack())()], + 'after' => [(new Unpack())(), (new Flip())()], ]; $sortCallback = @@ -83,12 +81,12 @@ static function (iterable $iterable) use ($type, $callback): Generator { static fn (array $left, array $right): int => $callback($left[1], $right[1]); /** @var callable(iterable): Generator | callable(iterable): Generator $before */ - $before = Pipe::of()(...$operations['before']); + $before = (new Pipe())()(...$operations['before']); $arrayIterator = new ArrayIterator([...$before($iterable)]); $arrayIterator->uasort($sortCallback($callback)); - yield from Pipe::of()(...$operations['after'])($arrayIterator); + yield from (new Pipe())()(...$operations['after'])($arrayIterator); }; }; } diff --git a/src/Operation/Span.php b/src/Operation/Span.php index 99d8d1766..ea69e7c08 100644 --- a/src/Operation/Span.php +++ b/src/Operation/Span.php @@ -26,8 +26,6 @@ final class Span extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Split.php b/src/Operation/Split.php index 5f3d51438..7afceb7e9 100644 --- a/src/Operation/Split.php +++ b/src/Operation/Split.php @@ -25,8 +25,6 @@ final class Split extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure((callable(T, TKey): bool)...): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Strict.php b/src/Operation/Strict.php index 42d12cdcb..cf3cc47a1 100644 --- a/src/Operation/Strict.php +++ b/src/Operation/Strict.php @@ -25,8 +25,6 @@ final class Strict extends AbstractOperation { /** - * @pure - * * @return Closure(null|callable(mixed): string): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Tail.php b/src/Operation/Tail.php index bb3ef8c95..d8c94f177 100644 --- a/src/Operation/Tail.php +++ b/src/Operation/Tail.php @@ -21,14 +21,12 @@ final class Tail extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $drop */ - $drop = Drop::of()(1); + $drop = (new Drop())()(1); // Point free style. return $drop; diff --git a/src/Operation/Tails.php b/src/Operation/Tails.php index fab14190b..be6377b7e 100644 --- a/src/Operation/Tails.php +++ b/src/Operation/Tails.php @@ -21,8 +21,6 @@ final class Tails extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator, mixed, void> */ public function __invoke(): Closure @@ -35,11 +33,11 @@ public function __invoke(): Closure */ static function (iterable $iterable): Generator { /** @var Generator $generator */ - $generator = Pack::of()($iterable); + $generator = (new Pack())()($iterable); $data = [...$generator]; while ([] !== $data) { - yield [...Unpack::of()($data)]; + yield [...(new Unpack())()($data)]; array_shift($data); } diff --git a/src/Operation/TakeWhile.php b/src/Operation/TakeWhile.php index 309b6aef6..6bb4c386c 100644 --- a/src/Operation/TakeWhile.php +++ b/src/Operation/TakeWhile.php @@ -24,8 +24,6 @@ final class TakeWhile extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Times.php b/src/Operation/Times.php index e500f6018..28a6d8439 100644 --- a/src/Operation/Times.php +++ b/src/Operation/Times.php @@ -24,8 +24,6 @@ final class Times extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(null|callable(int): (int|T)): Closure(null|Iterator): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Transpose.php b/src/Operation/Transpose.php index 6505e449e..90423d756 100644 --- a/src/Operation/Transpose.php +++ b/src/Operation/Transpose.php @@ -23,8 +23,6 @@ final class Transpose extends AbstractOperation { /** - * @pure - * * @psalm-suppress ImpureMethodCall - using MultipleIterator as an internal tool which is not returned * * @return Closure(iterable): Generator> @@ -48,16 +46,16 @@ public function __invoke(): Closure static fn (array $value): array => $value; /** @var Closure(iterable): Generator> $pipe */ - $pipe = Pipe::of()( - Reduce::of()( + $pipe = (new Pipe())()( + (new Reduce())()( static function (MultipleIterator $acc, iterable $iterable): MultipleIterator { $acc->attachIterator((new IterableIteratorAggregate($iterable))->getIterator()); return $acc; } )(new MultipleIterator(MultipleIterator::MIT_NEED_ANY)), - Flatten::of()(1), - Associate::of()($callbackForKeys)($callbackForValues) + (new Flatten())()(1), + (new Associate())()($callbackForKeys)($callbackForValues) ); // Point free style. diff --git a/src/Operation/Truthy.php b/src/Operation/Truthy.php index 2073924d8..bf2985492 100644 --- a/src/Operation/Truthy.php +++ b/src/Operation/Truthy.php @@ -21,8 +21,6 @@ final class Truthy extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -35,15 +33,15 @@ public function __invoke(): Closure static fn (bool $value): bool => !$value; /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Map::of()( + $pipe = (new Pipe())()( + (new Map())()( /** * @param T $value */ static fn ($value): bool => (bool) $value ), - MatchOne::of()($matchWhenNot)($matcher), - Map::of()($matcher), + (new MatchOne())()($matchWhenNot)($matcher), + (new Map())()($matcher), ); // Point free style. diff --git a/src/Operation/Unfold.php b/src/Operation/Unfold.php index 62e49a1ff..fcd4c1ac5 100644 --- a/src/Operation/Unfold.php +++ b/src/Operation/Unfold.php @@ -23,8 +23,6 @@ final class Unfold extends AbstractOperation { /** - * @pure - * * @return Closure(T...): Closure(callable(T...): list): Closure(): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Unlines.php b/src/Operation/Unlines.php index 9239ca11b..649219eac 100644 --- a/src/Operation/Unlines.php +++ b/src/Operation/Unlines.php @@ -23,14 +23,12 @@ final class Unlines extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable):Generator $implode */ - $implode = Implode::of()(PHP_EOL); + $implode = (new Implode())()(PHP_EOL); // Point free style. return $implode; diff --git a/src/Operation/Unpack.php b/src/Operation/Unpack.php index 880c173e4..7b640bab6 100644 --- a/src/Operation/Unpack.php +++ b/src/Operation/Unpack.php @@ -26,17 +26,15 @@ final class Unpack extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Map::of()(static fn (iterable $iterable): iterable => new IterableIteratorAggregate($iterable)), - Map::of()(Chunk::of()(2)), - Flatten::of()(1), + $pipe = (new Pipe())()( + (new Map())()(static fn (iterable $iterable): iterable => new IterableIteratorAggregate($iterable)), + (new Map())()((new Chunk())()(2)), + (new Flatten())()(1), static fn (iterable $iterable): IteratorAggregate => new UnpackIterableAggregate($iterable) ); diff --git a/src/Operation/Unpair.php b/src/Operation/Unpair.php index 924e4fc6b..859b9f79f 100644 --- a/src/Operation/Unpair.php +++ b/src/Operation/Unpair.php @@ -21,8 +21,6 @@ final class Unpair extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Until.php b/src/Operation/Until.php index e6dc6f1f6..43871cae6 100644 --- a/src/Operation/Until.php +++ b/src/Operation/Until.php @@ -24,8 +24,6 @@ final class Until extends AbstractOperation { /** - * @pure - * * @return Closure(callable(T=, TKey=, iterable=): bool ...): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Unwindow.php b/src/Operation/Unwindow.php index ef3726158..d4d82103a 100644 --- a/src/Operation/Unwindow.php +++ b/src/Operation/Unwindow.php @@ -21,14 +21,12 @@ final class Unwindow extends AbstractOperation { /** - * @pure - * * @return Closure(iterable>): Generator */ public function __invoke(): Closure { /** @var Closure(iterable>): Generator $unwindow */ - $unwindow = Map::of()( + $unwindow = (new Map())()( /** * @param iterable> $iterable * diff --git a/src/Operation/Unwords.php b/src/Operation/Unwords.php index de613f312..1a74498c2 100644 --- a/src/Operation/Unwords.php +++ b/src/Operation/Unwords.php @@ -21,14 +21,12 @@ final class Unwords extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $implode */ - $implode = Implode::of()(' '); + $implode = (new Implode())()(' '); // Point free style. return $implode; diff --git a/src/Operation/Unwrap.php b/src/Operation/Unwrap.php index 19b772434..36d7e5f13 100644 --- a/src/Operation/Unwrap.php +++ b/src/Operation/Unwrap.php @@ -21,14 +21,12 @@ final class Unwrap extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure { /** @var Closure(iterable): Generator $flatten */ - $flatten = Flatten::of()(1); + $flatten = (new Flatten())()(1); // Point free style. return $flatten; diff --git a/src/Operation/Unzip.php b/src/Operation/Unzip.php index 43f448131..77dddbc0a 100644 --- a/src/Operation/Unzip.php +++ b/src/Operation/Unzip.php @@ -21,8 +21,6 @@ final class Unzip extends AbstractOperation { /** - * @pure - * * @return Closure(iterable>): Generator> */ public function __invoke(): Closure @@ -45,9 +43,9 @@ static function (array $carry, iterable $value): array { }; /** @var Closure(iterable>): Generator> $pipe */ - $pipe = Pipe::of()( - Reduce::of()($reduceCallback)([]), - Flatten::of()(1) + $pipe = (new Pipe())()( + (new Reduce())()($reduceCallback)([]), + (new Flatten())()(1) ); // Point free style. diff --git a/src/Operation/When.php b/src/Operation/When.php index 67524eda6..b5654043b 100644 --- a/src/Operation/When.php +++ b/src/Operation/When.php @@ -23,8 +23,6 @@ final class When extends AbstractOperation { /** - * @pure - * * @return Closure(callable(iterable): bool): Closure(callable(iterable): iterable): Closure(callable(iterable): iterable): Closure(iterable): Generator */ public function __invoke(): Closure diff --git a/src/Operation/Window.php b/src/Operation/Window.php index 72c13712a..27cf60764 100644 --- a/src/Operation/Window.php +++ b/src/Operation/Window.php @@ -23,8 +23,6 @@ final class Window extends AbstractOperation { /** - * @pure - * * @return Closure(int): Closure(iterable): Generator> */ public function __invoke(): Closure diff --git a/src/Operation/Words.php b/src/Operation/Words.php index c13fd016a..b3fcf5c37 100644 --- a/src/Operation/Words.php +++ b/src/Operation/Words.php @@ -21,8 +21,6 @@ final class Words extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator */ public function __invoke(): Closure @@ -34,10 +32,10 @@ public function __invoke(): Closure static fn (array $value): string => implode('', $value); /** @var Closure(iterable): Generator $pipe */ - $pipe = Pipe::of()( - Explode::of()("\t", "\n", ' '), - Map::of()($mapCallback), - Compact::of()() + $pipe = (new Pipe())()( + (new Explode())()("\t", "\n", ' '), + (new Map())()($mapCallback), + (new Compact())()() ); // Point free style. diff --git a/src/Operation/Wrap.php b/src/Operation/Wrap.php index e4bcab516..f35a70b62 100644 --- a/src/Operation/Wrap.php +++ b/src/Operation/Wrap.php @@ -21,8 +21,6 @@ final class Wrap extends AbstractOperation { /** - * @pure - * * @return Closure(iterable): Generator> */ public function __invoke(): Closure @@ -37,8 +35,8 @@ public function __invoke(): Closure static fn ($value, $key): array => [$key => $value]; /** @var Closure(iterable): Generator> $pipe */ - $pipe = Pipe::of()( - Map::of()($mapCallback), + $pipe = (new Pipe())()( + (new Map())()($mapCallback), (new Normalize())() ); diff --git a/src/Operation/Zip.php b/src/Operation/Zip.php index 43462a5f4..70557d7fa 100644 --- a/src/Operation/Zip.php +++ b/src/Operation/Zip.php @@ -25,8 +25,6 @@ final class Zip extends AbstractOperation { /** - * @pure - * * @template UKey * @template U * diff --git a/src/Utils/CallbacksArrayReducer.php b/src/Utils/CallbacksArrayReducer.php index 15dc02c26..3f02e1fc0 100644 --- a/src/Utils/CallbacksArrayReducer.php +++ b/src/Utils/CallbacksArrayReducer.php @@ -22,8 +22,6 @@ final class CallbacksArrayReducer { /** - * @pure - * * @return Closure(array=): bool>, T, TKey, iterable): bool */ public static function or(): Closure