Skip to content

Commit

Permalink
Merge pull request #151 from WyriHaximus-secret-labs/drop-call-user_f…
Browse files Browse the repository at this point in the history
…unc-in-favour-of-calling-callables-directly

Drop call_user_func calls in favour of calling callables directly
  • Loading branch information
WyriHaximus committed Nov 30, 2019
2 parents 15036d2 + 1867694 commit f2c6529
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Deferred.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public function resolve($value = null): void
{
$this->promise();

\call_user_func($this->resolveCallback, $value);
($this->resolveCallback)($value);
}

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

\call_user_func($this->rejectCallback, $reason);
($this->rejectCallback)($reason);
}
}
8 changes: 4 additions & 4 deletions tests/PromiseAdapter/CallbackPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ public function __construct(array $callbacks)

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

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

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

public function settle(): ?PromiseInterface
{
return call_user_func_array($this->callbacks['settle'], func_get_args());
return ($this->callbacks['settle'])(...func_get_args());
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/SimpleTestCancellableThenable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function cancel()
$this->cancelCalled = true;

if (is_callable($this->onCancel)) {
call_user_func($this->onCancel);
($this->onCancel)();
}
}
}

0 comments on commit f2c6529

Please sign in to comment.