Skip to content

Commit 1fc7024

Browse files
Replaced call_user_func* with native calls (#165)
1 parent 71b12f9 commit 1fc7024

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/EachPromise.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private function refillPending(): void
135135

136136
// Add only up to N pending promises.
137137
$concurrency = is_callable($this->concurrency)
138-
? call_user_func($this->concurrency, count($this->pending))
138+
? ($this->concurrency)(count($this->pending))
139139
: $this->concurrency;
140140
$concurrency = max($concurrency - count($this->pending), 0);
141141
// Concurrency may be set to 0 to disallow new promises.
@@ -170,8 +170,7 @@ private function addPending(): bool
170170
$this->pending[$idx] = $promise->then(
171171
function ($value) use ($idx, $key): void {
172172
if ($this->onFulfilled) {
173-
call_user_func(
174-
$this->onFulfilled,
173+
($this->onFulfilled)(
175174
$value,
176175
$key,
177176
$this->aggregate
@@ -181,8 +180,7 @@ function ($value) use ($idx, $key): void {
181180
},
182181
function ($reason) use ($idx, $key): void {
183182
if ($this->onRejected) {
184-
call_user_func(
185-
$this->onRejected,
183+
($this->onRejected)(
186184
$reason,
187185
$key,
188186
$this->aggregate

tests/CoroutineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public function testShouldProxyPromiseMethodsToResultPromise($method, $args = []
2929
{
3030
$coroutine = new Coroutine(function () { yield 0; });
3131
$mockPromise = $this->getMockForAbstractClass(PromiseInterface::class);
32-
call_user_func_array([$mockPromise->expects($this->once())->method($method), 'with'], $args);
32+
$mockPromise->expects($this->once())->method($method)->with(...$args);
3333

3434
$resultPromiseProp = (new ReflectionClass(Coroutine::class))->getProperty('result');
3535
$resultPromiseProp->setAccessible(true);
3636
$resultPromiseProp->setValue($coroutine, $mockPromise);
3737

38-
call_user_func_array([$coroutine, $method], $args);
38+
$coroutine->{$method}(...$args);
3939
}
4040

4141
public function promiseInterfaceMethodProvider()

0 commit comments

Comments
 (0)