lib/Promise.php
public function wait()
    {
        $hasEvents = true;
        while (self::PENDING === $this->state) {
            if (!$hasEvents) {
                throw new \LogicException('There were no more events in the loop. This promise will never be fulfilled.');
            }

            // As long as the promise is not fulfilled, we tell the event loop
            // to handle events, and to block.
            $hasEvents = Loop\tick(true);
        }

        if (self::FULFILLED === $this->state) {
            // If the state of this promise is fulfilled, we can return the value.
            return $this->value;
        } else {
            // If we got here, it means that the asynchronous operation
            // errored. Therefore we need to throw an exception.
            throw $this->value;
        }
    }
public function wait()
    {
        $hasEvents = true;
        while (self::PENDING === $this->state) {
            if (!$hasEvents) {
                throw new \LogicException('There were no more events in the loop. This promise will never be fulfilled.');
            }

            // As long as the promise is not fulfilled, we tell the event loop
            // to handle events, and to block.
            $hasEvents = Loop\tick(true);
        }

        if (self::FULFILLED === $this->state) {
            // If the state of this promise is fulfilled, we can return the value.
            return $this->value;
        } else {
            // If we got here, it means that the asynchronous operation
            // errored. Therefore we need to throw an exception.
            throw $this->value;
        }
    }
public function wait ( ) { $ hasEvents = true ; while ( self :: PENDING === $ this -> state ) { if ( ! $ hasEvents ) { throw new \ LogicException ( 'There were no more events in the loop. This promise will never be fulfilled.' ) ; } // As long as the promise is not fulfilled, we tell the event loop // to handle events, and to block. $ hasEvents = Loop \ tick ( true ) ; } if ( self :: FULFILLED === $ this -> state ) { // If the state of this promise is fulfilled, we can return the value. return $ this -> value ; } else { // If we got here, it means that the asynchronous operation // errored. Therefore we need to throw an exception. throw $ this -> value ; } }
Stops execution until this promise is resolved.

This method stops execution completely. If the promise is successful with
a value, this method will return this value. If the promise was
rejected, this method will throw an exception.

This effectively turns the asynchronous operation into a synchronous
one. In PHP it might be useful to call this on the last promise in a
chain.

@return mixed
Stops execution until this promise is resolved .