diff --git a/src/Functional/functions.php b/src/Functional/functions.php index 3030903..bfd10c0 100644 --- a/src/Functional/functions.php +++ b/src/Functional/functions.php @@ -26,7 +26,7 @@ * * @return mixed */ -function applicator($x, callable $f = null) +function applicator($x, ?callable $f = null) { return curryN(2, function ($y, callable $f) { return $f($y); @@ -168,7 +168,7 @@ function reverse(callable $function) * @param callable $transformation * @param Functor $value */ -function map(callable $transformation, Functor $value = null) +function map(callable $transformation, ?Functor $value = null) { return curryN(2, function (callable $transformation, Functor $value) { return $value->map($transformation); @@ -188,7 +188,7 @@ function map(callable $transformation, Functor $value = null) * @param callable $function * @param Monad $value */ -function bind(callable $function, Monad $value = null) +function bind(callable $function, ?Monad $value = null) { return curryN(2, function (callable $function, Monad $value) { return $value->bind($function); @@ -226,7 +226,7 @@ function join(Monad $monad): Monad * * @return mixed */ -function reduce(callable $callable, $accumulator = null, Foldable $foldable = null) +function reduce(callable $callable, $accumulator = null, ?Foldable $foldable = null) { return curryN(3, function ( callable $callable, @@ -254,7 +254,7 @@ function reduce(callable $callable, $accumulator = null, Foldable $foldable = nu * * @return mixed */ -function foldr(callable $callable, $accumulator = null, Foldable $foldable = null) +function foldr(callable $callable, $accumulator = null, ?Foldable $foldable = null) { return curryN(3, function ( callable $callable, @@ -282,7 +282,7 @@ function foldr(callable $callable, $accumulator = null, Foldable $foldable = nul * * @return Foldable|\Closure */ -function filter(callable $predicate, Foldable $list = null) +function filter(callable $predicate, ?Foldable $list = null) { return curryN(2, function (callable $predicate, Foldable $list) { return reduce(function (Listt $list, $x) use ($predicate) { @@ -394,9 +394,9 @@ function reThrow(\Exception $e) * @return Monad|\Closure */ function liftM2( - callable $transformation = null, - Monad $ma = null, - Monad $mb = null + ?callable $transformation = null, + ?Monad $ma = null, + ?Monad $mb = null ) { return call_user_func_array( liftA2, @@ -419,9 +419,9 @@ function liftM2( * @return Monad|\Closure */ function bindM2( - callable $transformation = null, - Monad $ma = null, - Monad $mb = null + ?callable $transformation = null, + ?Monad $ma = null, + ?Monad $mb = null ) { return curryN( 3, @@ -454,9 +454,9 @@ function ( * @return Applicative|\Closure */ function liftA2( - callable $transformation = null, - Applicative $fa = null, - Applicative $fb = null + ?callable $transformation = null, + ?Applicative $fa = null, + ?Applicative $fb = null ) { return curryN(3, function ( callable $transformation, @@ -491,7 +491,7 @@ function liftA2( * * @return Monad|\Closure */ -function sequenceM(Monad $a, Monad $b = null): Monad +function sequenceM(Monad $a, ?Monad $b = null): Monad { return curryN(2, function (Monad ...$monads): Monad { return array_reduce($monads, function (?Monad $a, Monad $b) { @@ -519,7 +519,7 @@ function sequenceM(Monad $a, Monad $b = null): Monad * * @return \Closure|Applicative f (t b) */ -function traverse(callable $transformation, Traversable $t = null) +function traverse(callable $transformation, ?Traversable $t = null) { return curryN(2, function ( callable $transformation, @@ -542,7 +542,7 @@ function traverse(callable $transformation, Traversable $t = null) * * @return \Closure|Monad m [a] */ -function filterM(callable $f, Foldable $xs = null) +function filterM(callable $f, ?Foldable $xs = null) { return curryN(2, function ( callable $f, @@ -585,7 +585,7 @@ function filterM(callable $f, Foldable $xs = null) * * @return mixed m a */ -function foldM(callable $f, $z0 = null, Foldable $xs = null) +function foldM(callable $f, $z0 = null, ?Foldable $xs = null) { return curryN(3, function ( callable $f, diff --git a/src/Functional/listt.php b/src/Functional/listt.php index 431b609..7146106 100644 --- a/src/Functional/listt.php +++ b/src/Functional/listt.php @@ -132,7 +132,7 @@ function concat(Foldable $xs): Listt * @param Listt $xs * @return Listt|\Closure */ -function prepend($x, Listt $xs = null) +function prepend($x, ?Listt $xs = null) { return curryN(2, function ($x, Listt $xs): Listt { return new ListtCons(function () use ($x, $xs) { @@ -160,7 +160,7 @@ function prepend($x, Listt $xs = null) * @param Listt|null $b * @return Listt|callable */ -function append(Listt $a, Listt $b = null) +function append(Listt $a, ?Listt $b = null) { return curryN(2, function (Listt $a, Listt $b): Listt { return $a->concat($b); diff --git a/src/Functional/monoid.php b/src/Functional/monoid.php index 2c54146..59b90cd 100644 --- a/src/Functional/monoid.php +++ b/src/Functional/monoid.php @@ -31,7 +31,7 @@ function emptyM(Monoid $a): Monoid * * @return Semigroup|\Closure */ -function concatM(Semigroup $a, Semigroup $b = null) +function concatM(Semigroup $a, ?Semigroup $b = null) { return curryN(2, function (Semigroup $a, Semigroup $b) { return $a->concat($b); diff --git a/src/Functional/predicates.php b/src/Functional/predicates.php index ef6b411..bb3c015 100644 --- a/src/Functional/predicates.php +++ b/src/Functional/predicates.php @@ -50,7 +50,7 @@ function lt($expected, $value = null) * * @return bool|\Closure */ -function orr(callable $predicateA, callable $predicateB = null, $value = null) +function orr(callable $predicateA, ?callable $predicateB = null, $value = null) { return curryN(3, function (callable $a, callable $b, $value): bool { return $a($value) || $b($value); diff --git a/src/Functional/setoid.php b/src/Functional/setoid.php index 5bc3a38..b07bd79 100644 --- a/src/Functional/setoid.php +++ b/src/Functional/setoid.php @@ -16,7 +16,7 @@ * * @return bool|\Closure */ -function equal(Setoid $a, Setoid $b = null) +function equal(Setoid $a, ?Setoid $b = null) { return curryN(2, function (Setoid $a, Setoid $b):bool { return $a->equals($b); diff --git a/src/Functional/sublist.php b/src/Functional/sublist.php index 8b0eae0..eb1faec 100644 --- a/src/Functional/sublist.php +++ b/src/Functional/sublist.php @@ -23,7 +23,7 @@ * @param Listt $xs * @return Listt|\Closure */ -function take(int $n, Listt $xs = null) +function take(int $n, ?Listt $xs = null) { return curryN(2, function (int $n, Listt $xs): Listt { if ($n < 1) { @@ -49,7 +49,7 @@ function take(int $n, Listt $xs = null) * @param Listt $xs * @return Listt|\Closure */ -function drop(int $n, Listt $xs = null) +function drop(int $n, ?Listt $xs = null) { return curryN(2, function (int $n, Listt $xs): Listt { if ($n < 1) { @@ -84,7 +84,7 @@ function drop(int $n, Listt $xs = null) * @param Listt $xs * @return Listt|\Closure */ -function dropWhile(callable $predicate, Listt $xs = null) +function dropWhile(callable $predicate, ?Listt $xs = null) { return curryN(2, function (callable $predicate, Listt $xs): Listt { if ($xs instanceof ListtNil) { @@ -126,7 +126,7 @@ function dropWhile(callable $predicate, Listt $xs = null) * @param Listt $xs * @return array|\Closure */ -function span(callable $predicate, Listt $xs = null) +function span(callable $predicate, ?Listt $xs = null) { return curryN(2, function (callable $predicate, Listt $xs): array { try { diff --git a/src/Functional/zipping.php b/src/Functional/zipping.php index 4b3d405..8f46496 100644 --- a/src/Functional/zipping.php +++ b/src/Functional/zipping.php @@ -23,7 +23,7 @@ * @param Listt|null $ys * @return Listt|\Closure */ -function zip(Listt $xs, Listt $ys = null) +function zip(Listt $xs, ?Listt $ys = null) { return curryN(2, function (Listt $xs, Listt $ys): Listt { try { diff --git a/src/Monad/Either/functions.php b/src/Monad/Either/functions.php index 5c2cbd1..460df68 100644 --- a/src/Monad/Either/functions.php +++ b/src/Monad/Either/functions.php @@ -62,7 +62,7 @@ function left($value) * * @return mixed c */ -function either(callable $left, callable $right = null, Either $either = null) +function either(callable $left, ?callable $right = null, ?Either $either = null) { return f\curryN(3, function (callable $left, callable $right, Either $either) { return $either->either($left, $right); @@ -82,7 +82,7 @@ function either(callable $left, callable $right = null, Either $either = null) * * @return Left|Right|\Closure */ -function doubleMap(callable $left, callable $right = null, Either $either = null) +function doubleMap(callable $left, ?callable $right = null, ?Either $either = null) { return f\curryN(3, function (callable $left, callable $right, Either $either) { return either( @@ -106,7 +106,7 @@ function doubleMap(callable $left, callable $right = null, Either $either = null * * @return Either|\Closure */ -function tryCatch(callable $function = null, callable $catchFunction = null, $value = null) +function tryCatch(?callable $function = null, ?callable $catchFunction = null, $value = null) { return f\curryN(3, function (callable $function, callable $catchFunction, $value) { return f\tryCatch( @@ -140,9 +140,9 @@ function toMaybe(Either $either) * @param Either $either * @return mixed */ -function fromLeft($a, Either $either = null) +function fromLeft($a, ?Either $either = null) { - return f\curryN(2, function ($a, Either $either = null) { + return f\curryN(2, function ($a, ?Either $either = null) { return either(f\identity, f\constt($a), $either); })(...func_get_args()); } @@ -156,9 +156,9 @@ function fromLeft($a, Either $either = null) * @param Either $either * @return mixed */ -function fromRight($a, Either $either = null) +function fromRight($a, ?Either $either = null) { - return f\curryN(2, function ($a, Either $either = null) { + return f\curryN(2, function ($a, ?Either $either = null) { return either(f\constt($a), f\identity, $either); })(...func_get_args()); } diff --git a/src/Monad/Free/functions.php b/src/Monad/Free/functions.php index 3223793..049810a 100644 --- a/src/Monad/Free/functions.php +++ b/src/Monad/Free/functions.php @@ -39,7 +39,7 @@ function liftF(Functor $f): MonadFree * * @return Monad|callable */ -function foldFree(callable $interpreter, MonadFree $free = null, callable $return = null) +function foldFree(callable $interpreter, ?MonadFree $free = null, ?callable $return = null) { return curryN(3, function (callable $interpreter, MonadFree $free, callable $return): Monad { return $free->foldFree($interpreter, $return); diff --git a/src/Monad/IO/errors.php b/src/Monad/IO/errors.php index 21b7192..9cc76e7 100644 --- a/src/Monad/IO/errors.php +++ b/src/Monad/IO/errors.php @@ -50,7 +50,7 @@ function throwIO(\Exception $e) * * @return M\IO|\Closure */ -function tryCatch(M\IO $io = null, callable $catchFunction = null) +function tryCatch(?M\IO $io = null, ?callable $catchFunction = null) { return f\curryN(2, function (M\IO $io, callable $catchFunction) { return M\IO::of(function () use ($io, $catchFunction) { diff --git a/src/Monad/Maybe/functions.php b/src/Monad/Maybe/functions.php index 54752d4..11ef56f 100644 --- a/src/Monad/Maybe/functions.php +++ b/src/Monad/Maybe/functions.php @@ -53,7 +53,7 @@ function just($value) * * @return mixed|\Closure */ -function maybe($default, callable $fn = null, Maybe $maybe = null) +function maybe($default, ?callable $fn = null, ?Maybe $maybe = null) { return f\curryN(3, function ($default, callable $fn, Maybe $maybe) { if ($maybe instanceof Nothing) { @@ -94,7 +94,7 @@ function maybeNull($value = null) * * @return mixed */ -function fromMaybe($default = null, Maybe $maybe = null) +function fromMaybe($default = null, ?Maybe $maybe = null) { return f\curryN(2, function ($default, Maybe $maybe) { return maybe($default, f\identity, $maybe); diff --git a/src/Monad/Writer.php b/src/Monad/Writer.php index 4df6236..244eee6 100644 --- a/src/Monad/Writer.php +++ b/src/Monad/Writer.php @@ -11,7 +11,7 @@ class Writer implements FantasyLand\Monad { const of = 'Widmogrod\Monad\Writer::of'; - public static function of($value, FantasyLand\Monoid $side = null) + public static function of($value, ?FantasyLand\Monoid $side = null) { return new static($value, $side === null ? S::mempty() : $side); } diff --git a/test/Functional/LiftM2Test.php b/test/Functional/LiftM2Test.php index ab5f85d..2a18425 100644 --- a/test/Functional/LiftM2Test.php +++ b/test/Functional/LiftM2Test.php @@ -21,7 +21,7 @@ public function test_it_should_lift2M( Monad $mb, callable $transformation, string $expectedFQCN, - callable $valueAssertion = null + ?callable $valueAssertion = null ) { $mc = f\liftM2($transformation, $ma, $mb);