コード例 #1
0
ファイル: ModelBuilder.php プロジェクト: myclabs/xport
 /**
  * @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
ファイル: ForEachExecutorTest.php プロジェクト: myclabs/xport
 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'));
     }
 }