protected function awaitFirstResult(Context $context, array $tasks, CancellationHandler $cancel, array & $errors): \Generator
    {
        if (empty($tasks)) {
            return;
        }
        
        try {
            $result = yield $context->first($tasks, $cancel, $errors);
        } catch (MultiReasonException $e) {
            $result = null;
        }
        
        return $result;
    }
protected function awaitFirstResult(Context $context, array $tasks, CancellationHandler $cancel, array & $errors): \Generator
    {
        if (empty($tasks)) {
            return;
        }
        
        try {
            $result = yield $context->first($tasks, $cancel, $errors);
        } catch (MultiReasonException $e) {
            $result = null;
        }
        
        return $result;
    }
protected function awaitFirstResult ( Context $ context , array $ tasks , CancellationHandler $ cancel , array & $ errors ) : \ Generator { if ( empty ( $ tasks ) ) { return ; } try { $ result = yield $ context -> first ( $ tasks , $ cancel , $ errors ) ; } catch ( MultiReasonException $ e ) { $ result = null ; } return $ result ; }
Helper method that collects errors thrown by promises into an array and allways resolves.

@param Context $context Async execution context.
@param array $tasks
@param CancellationHandler $cancel
@param array $errors
Helper method that collects errors thrown by promises into an array and allways resolves .