From 777c3d6bd58c925704995c13fc2fcf45c1b8ee38 Mon Sep 17 00:00:00 2001 From: Victor Vispe Date: Wed, 29 May 2024 11:43:59 +0200 Subject: [PATCH] Adds `param-immediately-invoked-callable` in `Option` --- src/Psl/Option/Option.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Psl/Option/Option.php b/src/Psl/Option/Option.php index 4ac1575c..99309f00 100644 --- a/src/Psl/Option/Option.php +++ b/src/Psl/Option/Option.php @@ -74,6 +74,7 @@ public function isSome(): bool * Returns true if the option is a some and the value inside of it matches a predicate. * * @param (Closure(T): bool) $predicate + * @param-immediately-invoked-callable $predicate */ public function isSomeAnd(Closure $predicate): bool { @@ -140,6 +141,7 @@ public function unwrapOr(mixed $default): mixed * @template O * * @param (Closure(): O) $default + * @param-immediately-invoked-callable $default * * @return T|O */ @@ -199,6 +201,7 @@ public function or(Option $option): Option * - Option::none() if `$predicate` returns false. * * @param (Closure(T): bool) $predicate + * @param-immediately-invoked-callable $predicate * * @return Option */ @@ -235,9 +238,11 @@ public function contains(mixed $value): bool * @param (Closure(T): Ts) $some A closure to be called when the option is some. * The closure must accept the option value as its only argument and can return a value. * Example: `fn($value) => $value + 10` + * @param-immediately-invoked-callable $some * @param (Closure(): Ts) $none A closure to be called when the option is none. * The closure must not accept any arguments and can return a value. * Example: `fn() => 'Default value'` + * @param-immediately-invoked-callable $none * * @return Ts The result of calling the appropriate closure. */ @@ -254,6 +259,7 @@ public function proceed(Closure $some, Closure $none): mixed * Applies a function to a contained value and returns the original `Option`. * * @param (Closure(T): mixed) $closure + * @param-immediately-invoked-callable $closure * * @return Option */ @@ -272,6 +278,7 @@ public function apply(Closure $closure): Option * @template Tu * * @param (Closure(T): Tu) $closure + * @param-immediately-invoked-callable $closure * * @return Option */ @@ -291,6 +298,7 @@ public function map(Closure $closure): Option * @template Tu * * @param (Closure(T): Option) $closure + * @param-immediately-invoked-callable $closure * * @return Option */ @@ -314,6 +322,7 @@ public function andThen(Closure $closure): Option * @template Tu * * @param (Closure(T): Tu) $closure + * @param-immediately-invoked-callable $closure * @param Tu $default * * @return Option @@ -334,7 +343,9 @@ public function mapOr(Closure $closure, mixed $default): Option * @template Tu * * @param (Closure(T): Tu) $closure - * @param (Closure(): Tu) $else + * @param-immediately-invoked-callable $closure + * @param (Closure(): Tu) $default + * @param-immediately-invoked-callable $default * * @return Option */ @@ -395,6 +406,7 @@ public function zip(Option $other): Option * * @param Option $other The Option to zip with. * @param (Closure(T, Tu): Tr) $closure The closure to apply to the values. + * @param-immediately-invoked-callable $closure * * @return Option The new `Option` containing the result of applying the closure to the values, * or `None` if either this or the $other `Option is `None`.