Skip to content

Commit d5ee005

Browse files
committed
call_user_func replaced with expression
1 parent 083335e commit d5ee005

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/Iterators/Mapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(\Traversable $iterator, callable $callback)
2828

2929
public function current()
3030
{
31-
return call_user_func($this->callback, parent::current(), parent::key());
31+
return ($this->callback)(parent::current(), parent::key());
3232
}
3333

3434
}

src/Utils/Callback.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function closure($callable, $m = NULL)
5959
public static function invoke($callable, ...$args)
6060
{
6161
self::check($callable);
62-
return call_user_func_array($callable, $args);
62+
return $callable(...$args);
6363
}
6464

6565

@@ -70,7 +70,7 @@ public static function invoke($callable, ...$args)
7070
public static function invokeArgs($callable, array $args = [])
7171
{
7272
self::check($callable);
73-
return call_user_func_array($callable, $args);
73+
return $callable(...$args);
7474
}
7575

7676

src/Utils/ObjectMixin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function call($_this, $name, $args)
113113
}
114114

115115
} elseif ($isProp && $_this->$name instanceof \Closure) { // closure in property
116-
return call_user_func_array($_this->$name, $args);
116+
return ($_this->$name)(...$args);
117117

118118
} elseif (($methods = &self::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods
119119
list($op, $rp, $type) = $methods[$name];
@@ -412,7 +412,7 @@ public static function checkType(&$val, $type)
412412
case 'callable':
413413
case 'resource':
414414
case 'null':
415-
return call_user_func("is_$type", $val);
415+
return ("is_$type")($val);
416416
default:
417417
return $val instanceof $type;
418418
}

src/Utils/Validators.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static function is($value, $expected)
130130

131131
list($type) = $item = explode(':', $item, 2);
132132
if (isset(static::$validators[$type])) {
133-
if (!call_user_func(static::$validators[$type], $value)) {
133+
if (!static::$validators[$type]($value)) {
134134
continue;
135135
}
136136
} elseif ($type === 'pattern') {
@@ -145,7 +145,7 @@ public static function is($value, $expected)
145145
if (isset($item[1])) {
146146
$length = $value;
147147
if (isset(static::$counters[$type])) {
148-
$length = call_user_func(static::$counters[$type], $value);
148+
$length = static::$counters[$type]($value);
149149
}
150150
$range = explode('..', $item[1]);
151151
if (!isset($range[1])) {

tests/Utils/Callback.closure.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ test(function () { // closure
101101
Assert::same($closure, Callback::unwrap($closure));
102102
Assert::same('{closure}', Callback::toString($closure));
103103
Assert::same('{closure}', getName(Callback::toReflection($closure)));
104-
Assert::same('{closure}', call_user_func_array(Callback::closure($closure), [&$res]));
104+
Assert::same('{closure}', Callback::closure($closure)(...[&$res]));
105105
Assert::same('{closure}', $res);
106106
});
107107

@@ -142,7 +142,7 @@ test(function () { // object methods
142142

143143
Assert::same('Test::privateFun*', Callback::closure($test, 'privateFun')->__invoke('*'));
144144

145-
Assert::same('Test::ref', call_user_func_array(Callback::closure($test, 'ref'), [&$res]));
145+
Assert::same('Test::ref', Callback::closure($test, 'ref')(...[&$res]));
146146
Assert::same('Test::ref', $res);
147147
});
148148

0 commit comments

Comments
 (0)