Skip to content

Commit

Permalink
Static closures
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Jun 7, 2020
1 parent 2522889 commit b2ada2a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/PhpOption/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function fromArraysValue($array, $key)
*/
public static function fromReturn($callback, array $arguments = [], $noneValue = null)
{
return new LazyOption(function () use ($callback, $arguments, $noneValue) {
return new LazyOption(static function () use ($callback, $arguments, $noneValue) {
/** @var mixed */
$return = call_user_func_array($callback, $arguments);

Expand Down Expand Up @@ -126,7 +126,7 @@ public static function ensure($value, $noneValue = null)
if ($value instanceof self) {
return $value;
} elseif (is_callable($value)) {
return new LazyOption(function () use ($value, $noneValue) {
return new LazyOption(static function () use ($value, $noneValue) {
/** @var mixed */
$return = $value();

Expand Down Expand Up @@ -159,14 +159,14 @@ public static function ensure($value, $noneValue = null)
*/
public static function lift($callback, $noneValue = null)
{
return function () use ($callback, $noneValue) {
return static function () use ($callback, $noneValue) {
/** @var array<int, mixed> */
$args = func_get_args();

$reduced_args = array_reduce(
$args,
/** @param bool $status */
function ($status, self $o) {
static function ($status, self $o) {
return $o->isEmpty() ? true : $status;
},
false
Expand All @@ -178,7 +178,7 @@ function ($status, self $o) {

$args = array_map(
/** @return T */
function (self $o) {
static function (self $o) {
// it is safe to do so because the fold above checked
// that all arguments are of type Some
/** @var T */
Expand Down

0 comments on commit b2ada2a

Please sign in to comment.