Skip to content

fixing php8.4 deprecation messages #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/Functional/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/Functional/listt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Functional/monoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Functional/predicates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Functional/setoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Functional/sublist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/Functional/zipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions src/Monad/Either/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
2 changes: 1 addition & 1 deletion src/Monad/Free/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Monad/IO/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/Monad/Maybe/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Monad/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Functional/LiftM2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down