Gliph\Graph\DirectedAdjacencyList::successorsOf PHP Метод

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

public successorsOf ( $vertex )
    public function successorsOf($vertex)
    {
        if (!$this->hasVertex($vertex)) {
            throw new NonexistentVertexException('Vertex is not in graph; cannot iterate over its successor vertices.');
        }
        $set = $this->getTraversableSplos($this->vertices[$vertex]);
        foreach ($set as $successor) {
            (yield $successor);
        }
        $this->walking->detach($set);
    }

Usage Example

Пример #1
0
 /**
  * @covers ::process
  * @covers ::implementSSA
  */
 public function testOperationLoopWithPhi()
 {
     $graph = new DirectedAdjacencyList();
     $a = new Variable();
     $func = new Function_([$a], new Type(0), $graph);
     $start = new NoOp();
     $noOp = new NoOp();
     $jumpz = new JumpZ($noOp, $a);
     $graph->ensureArc($func, $start);
     $graph->ensureArc($start, $jumpz);
     $graph->ensureArc($jumpz, $r = new Return_($a));
     $graph->ensureArc($r, new End());
     $graph->ensureArc($jumpz, $binary = new BinaryOp(BinaryOp::PLUS, $a, new Constant(2), $a));
     $graph->ensureArc($binary, $j = new Jump());
     $graph->ensureArc($j, $start);
     $state = new GraphState($func);
     $compiler = new SSACompiler();
     $compiler->process($state);
     $this->assertSame([$a], $func->getArguments());
     $i = 0;
     foreach ($graph->successorsOf($start) as $v) {
         $this->assertEquals(0, $i++, 'More then one adjacent node');
         $this->assertInstanceOf(Phi::class, $v);
         $this->assertContains($a, $v->getValues());
         $this->assertSame($r->getValue(), $v->getResult());
     }
 }