Skip to content

Commit f2c6529

Browse files
authored
Merge pull request #151 from WyriHaximus-secret-labs/drop-call-user_func-in-favour-of-calling-callables-directly
Drop call_user_func calls in favour of calling callables directly
2 parents 15036d2 + 1867694 commit f2c6529

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Deferred.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public function resolve($value = null): void
3333
{
3434
$this->promise();
3535

36-
\call_user_func($this->resolveCallback, $value);
36+
($this->resolveCallback)($value);
3737
}
3838

3939
public function reject(\Throwable $reason): void
4040
{
4141
$this->promise();
4242

43-
\call_user_func($this->rejectCallback, $reason);
43+
($this->rejectCallback)($reason);
4444
}
4545
}

tests/PromiseAdapter/CallbackPromiseAdapter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ public function __construct(array $callbacks)
1515

1616
public function promise(): ?PromiseInterface
1717
{
18-
return call_user_func_array($this->callbacks['promise'], func_get_args());
18+
return ($this->callbacks['promise'])(...func_get_args());
1919
}
2020

2121
public function resolve(): ?PromiseInterface
2222
{
23-
return call_user_func_array($this->callbacks['resolve'], func_get_args());
23+
return ($this->callbacks['resolve'])(...func_get_args());
2424
}
2525

2626
public function reject(): ?PromiseInterface
2727
{
28-
return call_user_func_array($this->callbacks['reject'], func_get_args());
28+
return ($this->callbacks['reject'])(...func_get_args());
2929
}
3030

3131
public function settle(): ?PromiseInterface
3232
{
33-
return call_user_func_array($this->callbacks['settle'], func_get_args());
33+
return ($this->callbacks['settle'])(...func_get_args());
3434
}
3535
}

tests/fixtures/SimpleTestCancellableThenable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function cancel()
2222
$this->cancelCalled = true;
2323

2424
if (is_callable($this->onCancel)) {
25-
call_user_func($this->onCancel);
25+
($this->onCancel)();
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)