diff --git a/src/Internal/CancellationQueue.php b/src/Internal/CancellationQueue.php index 52abf6e2..35fb1a8b 100644 --- a/src/Internal/CancellationQueue.php +++ b/src/Internal/CancellationQueue.php @@ -22,7 +22,7 @@ public function __invoke(): void public function enqueue($cancellable): void { - if (!\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) { + if (!\is_object($cancellable) || !\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) { return; } diff --git a/src/functions.php b/src/functions.php index 2439c77c..b7b89cb1 100644 --- a/src/functions.php +++ b/src/functions.php @@ -25,7 +25,7 @@ function resolve($promiseOrValue = null): PromiseInterface return $promiseOrValue; } - if (\method_exists($promiseOrValue, 'then')) { + if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) { $canceller = null; if (\method_exists($promiseOrValue, 'cancel')) {