WooCommerce Code Reference

SyncPromise
in package

Synchronous promise implementation following Promises A+ spec.

Uses a hybrid approach for optimal memory and performance:

  • Lightweight closures in queue (fast execution)
  • Heavy payload (callbacks) stored on promise objects and cleared after use

Library users should use @see \Automattic\WooCommerce\Vendor\GraphQL\Deferred to create promises.

Tags
phpstan-type

Executor callable(): mixed

Table of Contents

FULFILLED  = 1
PENDING  = 0
REJECTED  = 2
$result  : mixed
Resolved value or rejection reason.
$state  : int
Current promise state.
$waiting  : array<string|int, mixed>
Promises created in `then` method awaiting resolution.
getQueue()  : SplQueue<string|int, callable>
TODO remove in next major version.
reject()  : $this
resolve()  : self
runQueue()  : void
TODO remove in next major version.
then()  : self
enqueueWaitingPromises()  : void

Constants

Properties

Methods