Skip to content

Commit

Permalink
Adds param-immediately-invoked-callable in Option
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Vispe committed May 29, 2024
1 parent fbbff2e commit 777c3d6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Psl/Option/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -140,6 +141,7 @@ public function unwrapOr(mixed $default): mixed
* @template O
*
* @param (Closure(): O) $default
* @param-immediately-invoked-callable $default
*
* @return T|O
*/
Expand Down Expand Up @@ -199,6 +201,7 @@ public function or(Option $option): Option
* - Option<T>::none() if `$predicate` returns false.
*
* @param (Closure(T): bool) $predicate
* @param-immediately-invoked-callable $predicate
*
* @return Option<T>
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -254,6 +259,7 @@ public function proceed(Closure $some, Closure $none): mixed
* Applies a function to a contained value and returns the original `Option<T>`.
*
* @param (Closure(T): mixed) $closure
* @param-immediately-invoked-callable $closure
*
* @return Option<T>
*/
Expand All @@ -272,6 +278,7 @@ public function apply(Closure $closure): Option
* @template Tu
*
* @param (Closure(T): Tu) $closure
* @param-immediately-invoked-callable $closure
*
* @return Option<Tu>
*/
Expand All @@ -291,6 +298,7 @@ public function map(Closure $closure): Option
* @template Tu
*
* @param (Closure(T): Option<Tu>) $closure
* @param-immediately-invoked-callable $closure
*
* @return Option<Tu>
*/
Expand All @@ -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<Tu>
Expand All @@ -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<Tu>
*/
Expand Down Expand Up @@ -395,6 +406,7 @@ public function zip(Option $other): Option
*
* @param Option<Tu> $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<Tr> The new `Option` containing the result of applying the closure to the values,
* or `None` if either this or the $other `Option is `None`.
Expand Down

0 comments on commit 777c3d6

Please sign in to comment.