mpyw\Co\Co::any PHP Method

any() public static method

If all yieldables failed, AllFailedException is thrown. If no yieldables found, AllFailedException is thrown.
public static any ( mixed $value ) : Generator
$value mixed
return Generator Resolved value.
    public static function any($value)
    {
        (yield Co::RETURN_WITH => (yield ControlUtils::anyOrRace($value, ['\\mpyw\\Co\\Internal\\ControlUtils', 'reverse'], 'Co::any() failed.')));
        // @codeCoverageIgnoreStart
    }

Usage Example

Exemplo n.º 1
0
 public function testAnyEmpty()
 {
     try {
         Co::wait(Co::any(['A', 'B']));
         $this->assertTrue(false);
     } catch (AllFailedException $e) {
         $this->assertEquals('Co::any() failed.', $e->getMessage());
         $this->assertEquals(['A', 'B'], $e->getReasons());
     }
 }