Skip to content

Commit

Permalink
refactor: Use new keyword everywhere.
Browse files Browse the repository at this point in the history
Follow up of previous commit.
  • Loading branch information
drupol committed Feb 3, 2022
1 parent a69acec commit 8a3a05a
Show file tree
Hide file tree
Showing 119 changed files with 84 additions and 324 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/Contract/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@

use Closure;

/** @immutable */
/**
* @immutable
*/
interface Operation
{
/**
* @pure
*/
public function __invoke(): Closure;

/**
* @pure
*/
public static function of(): Closure;
}
6 changes: 0 additions & 6 deletions src/Operation/AbstractOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
*/
abstract class AbstractOperation implements Operation
{
/**
* @pure
*/
final public function __construct()
{
}

/**
* @pure
*/
public static function of(): Closure
{
return (new static())->__invoke();
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
final class All extends AbstractOperation
{
/**
* @pure
*
* @return Closure(bool): Closure(iterable<TKey, T>): iterable<int, T>|iterable<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Append.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Append extends AbstractOperation
{
/**
* @pure
*
* @return Closure(T...): Closure(iterable<TKey, T>): Generator<int|TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class Apply extends AbstractOperation
{
/**
* @pure
*
* @return Closure(callable(T=, TKey=, iterable<TKey, T>=):bool ...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Associate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class Associate extends AbstractOperation
{
/**
* @pure
*
* @template NewTKey
* @template NewT
*
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/AsyncMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
final class AsyncMap extends AbstractOperation
{
/**
* @pure
*
* @template V
*
* @return Closure(callable(T, TKey): V): Closure(iterable<TKey, T>): Generator<TKey, V>
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/AsyncMapN.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
final class AsyncMapN extends AbstractOperation
{
/**
* @pure
*
* @return Closure(callable(mixed, mixed): mixed ...): Closure(iterable<TKey, T>): Generator<mixed, mixed>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
final class Cache extends AbstractOperation
{
/**
* @pure
*
* @return Closure(CacheItemPoolInterface): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Chunk extends AbstractOperation
{
/**
* @pure
*
* @return Closure(int...): Closure(iterable<TKey, T>): Generator<int, list<T>>
*/
public function __invoke(): Closure
Expand Down
8 changes: 3 additions & 5 deletions src/Operation/Coalesce.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
final class Coalesce extends AbstractOperation
{
/**
* @pure
*
* @return Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
{
/** @var Closure(iterable<TKey, T>): Generator<TKey, T> $pipe */
$pipe = Pipe::of()(
Compact::of()(),
Head::of(),
$pipe = (new Pipe())()(
(new Compact())()(),
(new Head())(),
);

// Point free style.
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Collapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TKey, (T|iterable<TKey, T>)>): Generator<TKey, T>
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
final class Column extends AbstractOperation
{
/**
* @pure
*
* @return Closure(mixed): Closure(iterable<TKey, T>): Generator<int, mixed>
*/
public function __invoke(): Closure
Expand Down
3 changes: 0 additions & 3 deletions src/Operation/Combinate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
*/
final class Combinate extends AbstractOperation
{
/**
* @pure
*/
public function __invoke(): Closure
{
return static function (?int $length = null): Closure {
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Combine.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
final class Combine extends AbstractOperation
{
/**
* @pure
*
* @template U
*
* @return Closure(U...): Closure(iterable<TKey, T>): Generator<null|U, null|T>
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Compact.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
final class Compact extends AbstractOperation
{
/**
* @pure
*
* @return Closure(T...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Contains.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
final class Contains extends AbstractOperation
{
/**
* @pure
*
* @return Closure(T ...$values): Closure(iterable<TKey, T>): Generator<TKey, bool>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Current.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
final class Current extends AbstractOperation
{
/**
* @pure
*
* @template V
*
* @return Closure(TKey): Closure(V): Closure(iterable<TKey, T>): Generator<int, T|V>
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
final class Cycle extends AbstractOperation
{
/**
* @pure
*
* @return Closure(iterable<TKey, T>): iterable<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class Diff extends AbstractOperation
{
/**
* @pure
*
* @return Closure(T...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/DiffKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class DiffKeys extends AbstractOperation
{
/**
* @pure
*
* @return Closure(TKey...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Distinct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TKey, T>): Generator<TKey, T>
Expand Down
4 changes: 1 addition & 3 deletions src/Operation/Drop.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
final class Drop extends AbstractOperation
{
/**
* @pure
*
* @return Closure(int): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
{
return Limit::of()(-1);
return (new Limit())()(-1);
}
}
2 changes: 0 additions & 2 deletions src/Operation/DropWhile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class DropWhile extends AbstractOperation
{
/**
* @pure
*
* @return Closure(callable(T=, TKey=, iterable<TKey, T>=): bool ...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Dump extends AbstractOperation
{
/**
* @pure
*
* @return Closure(string): Closure(int): Closure(?Closure): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TKey, T>): Generator<TKey, T>
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Equals.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Equals extends AbstractOperation
{
/**
* @pure
*
* @return Closure(iterable<TKey, T>): Closure(iterable<TKey, T>): Generator<int|TKey, bool>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Every.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Every extends AbstractOperation
{
/**
* @pure
*
* @return Closure(callable(T, TKey, iterable<TKey, T>...): bool): Closure(callable(T, TKey, iterable<TKey, T>...): bool): Closure(iterable<TKey, T>): Generator<TKey, bool>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Explode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
final class Explode extends AbstractOperation
{
/**
* @pure
*
* @return Closure(T...): Closure(iterable<TKey, T>): Generator<int, list<T>>
*/
public function __invoke(): Closure
Expand Down
10 changes: 4 additions & 6 deletions src/Operation/Falsy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
final class Falsy extends AbstractOperation
{
/**
* @pure
*
* @return Closure(iterable<TKey, T>): Generator<int, bool>
*/
public function __invoke(): Closure
Expand All @@ -35,15 +33,15 @@ public function __invoke(): Closure
static fn (bool $value): bool => $value;

/** @var Closure(iterable<TKey, T>): Generator<int, bool> $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
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
final class Filter extends AbstractOperation
{
/**
* @pure
*
* @return Closure(callable(T=, TKey=, iterable<TKey, T>=): bool ...): Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class Find extends AbstractOperation
{
/**
* @pure
*
* @template V
*
* @return Closure(V): Closure(callable(T=, TKey=, iterable<TKey, T>=): bool ...): Closure(iterable<TKey, T>): Generator<TKey, T|V>
Expand Down
4 changes: 1 addition & 3 deletions src/Operation/First.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
final class First extends AbstractOperation
{
/**
* @pure
*
* @return Closure(iterable<TKey, T>): Generator<TKey, T>
*/
public function __invoke(): Closure
{
/** @var Closure(iterable<TKey, T>): Generator<TKey, T> $head */
$head = Head::of();
$head = (new Head())();

// Point free style.
return $head;
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/FlatMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
final class FlatMap extends AbstractOperation
{
/**
* @pure
*
* @template IKey
* @template IValue
*
Expand Down
2 changes: 0 additions & 2 deletions src/Operation/Flatten.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
final class Flatten extends AbstractOperation
{
/**
* @pure
*
* @return Closure(int): Closure(iterable<TKey, T>): Generator<mixed, mixed>
*/
public function __invoke(): Closure
Expand Down
Loading

0 comments on commit 8a3a05a

Please sign in to comment.