valid() публичный Метод

Return whether generator is actually working.
public valid ( ) : boolean
Результат boolean
Пример #1
0
Файл: Co.php Проект: mpyw/co
 /**
  * Handle resolving generators.
  * @param  GeneratorContainer $gc
  * @return PromiseInterface
  */
 private function processGeneratorContainer(GeneratorContainer $gc)
 {
     return $gc->valid() ? $this->processGeneratorContainerRunning($gc) : $this->processGeneratorContainerDone($gc);
 }
Пример #2
0
 public function testExternalException()
 {
     $gen = (function () {
         $this->assertInstanceOf(\RuntimeException::class, (yield CoInterface::SAFE => null));
         (yield null);
     })();
     $con = new GeneratorContainer($gen);
     $con->key() === CoInterface::SAFE ? $con->send(new \RuntimeException()) : $con->throw_(new \RuntimeException());
     $this->assertTrue($con->valid());
     $this->assertFalse($con->thrown());
     $gen = (function () {
         (yield null);
         (yield null);
     })();
     $con = new GeneratorContainer($gen);
     $con->key() === CoInterface::SAFE ? $con->send(new \RuntimeException()) : $con->throw_(new \RuntimeException());
     $this->assertFalse($con->valid());
     $this->assertTrue($con->thrown());
     $this->assertInstanceOf(\RuntimeException::class, $con->getReturnOrThrown());
 }