src/Co.php
private function processGeneratorContainerDone(GeneratorContainer $gc)
    {
        // If exception has been thrown in generator, we have to propagate it as rejected value
        if ($gc->thrown()) {
            return new RejectedPromise($gc->getReturnOrThrown());
        }

        // Now we normalize returned value
        $returned = YieldableUtils::normalize($gc->getReturnOrThrown(), $gc->getYieldKey());
        $yieldables = YieldableUtils::getYieldables($returned, [], $this->runners);

        // If normalized value contains yieldables, we have to chain resolver
        if ($yieldables) {
            $deferred = new Deferred;
            return $this->promiseAll($yieldables, true)
            ->then(
                YieldableUtils::getApplier($returned, $yieldables, [$deferred, 'resolve']),
                [$deferred, 'reject']
            )
            ->then(function () use ($yieldables, $deferred) {
                $this->runners = array_diff_key($this->runners, $yieldables);
                return $deferred->promise();
            });
        }

        // Propagate normalized returned value
        return new FulfilledPromise($returned);
    }
private function processGeneratorContainerDone(GeneratorContainer $gc)
    {
        // If exception has been thrown in generator, we have to propagate it as rejected value
        if ($gc->thrown()) {
            return new RejectedPromise($gc->getReturnOrThrown());
        }

        // Now we normalize returned value
        $returned = YieldableUtils::normalize($gc->getReturnOrThrown(), $gc->getYieldKey());
        $yieldables = YieldableUtils::getYieldables($returned, [], $this->runners);

        // If normalized value contains yieldables, we have to chain resolver
        if ($yieldables) {
            $deferred = new Deferred;
            return $this->promiseAll($yieldables, true)
            ->then(
                YieldableUtils::getApplier($returned, $yieldables, [$deferred, 'resolve']),
                [$deferred, 'reject']
            )
            ->then(function () use ($yieldables, $deferred) {
                $this->runners = array_diff_key($this->runners, $yieldables);
                return $deferred->promise();
            });
        }

        // Propagate normalized returned value
        return new FulfilledPromise($returned);
    }
private function processGeneratorContainerDone ( GeneratorContainer $ gc ) { // If exception has been thrown in generator, we have to propagate it as rejected value if ( $ gc -> thrown ( ) ) { return new RejectedPromise ( $ gc -> getReturnOrThrown ( ) ) ; } // Now we normalize returned value $ returned = YieldableUtils :: normalize ( $ gc -> getReturnOrThrown ( ) , $ gc -> getYieldKey ( ) ) ; $ yieldables = YieldableUtils :: getYieldables ( $ returned , [ ] , $ this -> runners ) ; // If normalized value contains yieldables, we have to chain resolver if ( $ yieldables ) { $ deferred = new Deferred ; return $ this -> promiseAll ( $ yieldables , true ) -> then ( YieldableUtils :: getApplier ( $ returned , $ yieldables , [ $ deferred , 'resolve' ] ) , [ $ deferred , 'reject' ] ) -> then ( function ( ) use ( $ yieldables , $ deferred ) { $ this -> runners = array_diff_key ( $ this -> runners , $ yieldables ) ; return $ deferred -> promise ( ) ; } ) ; } // Propagate normalized returned value return new FulfilledPromise ( $ returned ) ; }
Handle resolving generators already done.
@param  GeneratorContainer $gc
@return PromiseInterface
Handle resolving generators already done .