Skip to content

Commit ccd60f8

Browse files
authored
Merge pull request #161 from smscr/smscr-promise-or-value-fix
Suggestion: when detecting promisable by method presense check its an object
2 parents e400476 + af072f6 commit ccd60f8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Internal/CancellationQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __invoke(): void
2222

2323
public function enqueue($cancellable): void
2424
{
25-
if (!\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) {
25+
if (!\is_object($cancellable) || !\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) {
2626
return;
2727
}
2828

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function resolve($promiseOrValue = null): PromiseInterface
2525
return $promiseOrValue;
2626
}
2727

28-
if (\method_exists($promiseOrValue, 'then')) {
28+
if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
2929
$canceller = null;
3030

3131
if (\method_exists($promiseOrValue, 'cancel')) {

0 commit comments

Comments
 (0)