mpyw\Co\Internal\GeneratorContainer::current PHP Method

current() public method

Return current value.
public current ( ) : mixed
return mixed
    public function current()
    {
        $this->validateValidity();
        return $this->g->current();
    }

Usage Example

Beispiel #1
0
 public function testPseudoReturn()
 {
     $gen = (function () {
         $this->assertEquals(2, (yield 1));
         $this->assertEquals(4, (yield 3));
         (yield CoInterface::RETURN_WITH => 5);
     })();
     $con = new GeneratorContainer($gen);
     $this->assertEquals($con->current(), 1);
     $con->send(2);
     $this->assertEquals($con->current(), 3);
     $con->send(4);
     $this->assertFalse($con->valid());
     $this->assertEquals(5, $con->getReturnOrThrown());
     $this->setExpectedException(\LogicException::class);
     $con->send(null);
 }
All Usage Examples Of mpyw\Co\Internal\GeneratorContainer::current