Skip to content

Commit b2ada2a

Browse files
Static closures
1 parent 2522889 commit b2ada2a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PhpOption/Option.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static function fromArraysValue($array, $key)
9393
*/
9494
public static function fromReturn($callback, array $arguments = [], $noneValue = null)
9595
{
96-
return new LazyOption(function () use ($callback, $arguments, $noneValue) {
96+
return new LazyOption(static function () use ($callback, $arguments, $noneValue) {
9797
/** @var mixed */
9898
$return = call_user_func_array($callback, $arguments);
9999

@@ -126,7 +126,7 @@ public static function ensure($value, $noneValue = null)
126126
if ($value instanceof self) {
127127
return $value;
128128
} elseif (is_callable($value)) {
129-
return new LazyOption(function () use ($value, $noneValue) {
129+
return new LazyOption(static function () use ($value, $noneValue) {
130130
/** @var mixed */
131131
$return = $value();
132132

@@ -159,14 +159,14 @@ public static function ensure($value, $noneValue = null)
159159
*/
160160
public static function lift($callback, $noneValue = null)
161161
{
162-
return function () use ($callback, $noneValue) {
162+
return static function () use ($callback, $noneValue) {
163163
/** @var array<int, mixed> */
164164
$args = func_get_args();
165165

166166
$reduced_args = array_reduce(
167167
$args,
168168
/** @param bool $status */
169-
function ($status, self $o) {
169+
static function ($status, self $o) {
170170
return $o->isEmpty() ? true : $status;
171171
},
172172
false
@@ -178,7 +178,7 @@ function ($status, self $o) {
178178

179179
$args = array_map(
180180
/** @return T */
181-
function (self $o) {
181+
static function (self $o) {
182182
// it is safe to do so because the fold above checked
183183
// that all arguments are of type Some
184184
/** @var T */

0 commit comments

Comments
 (0)