예제 #1
0
 /**
  * @param array    $yamlForeach
  * @param Scope    $scope
  * @param callable $callback
  * @param array    $parameters
  * @return int Number of iteration (where $callback is called) made by the loop for the given scope.
  */
 protected function parseForeach($yamlForeach, Scope $scope, callable $callback, array $parameters)
 {
     // Parse the foreach expression.
     $subScopes = $this->forEachExecutor->execute($yamlForeach['foreach'], $scope);
     return $this->doLoop($yamlForeach, $subScopes, $callback, $parameters);
 }
예제 #2
0
 public function testWithMethodCall()
 {
     $scope = new Scope();
     $scope->bind('foo', new FixtureClass());
     $parser = new ForEachExecutor();
     $subScopes = $parser->execute('foo.getStuff() as bar', $scope);
     $this->assertCount(2, $subScopes);
     foreach ($subScopes as $i => $subScope) {
         $this->assertInstanceOf('Xport\\Parser\\Scope', $subScope);
         $this->assertEquals('barValue' . $i, $subScope->get('bar'));
     }
 }