Exemplo n.º 1
0
Arquivo: Task.php Projeto: chh/bob
 function invoke()
 {
     if (!$this->enable) {
         if ($this->application->trace) {
             $this->application['log']->debug("{$this->inspect()} is not enabled");
         }
         return;
     }
     if (!$this->reenable and $this->application['invocation_chain']->has($this)) {
         return;
     }
     if (!$this->application->forceRun and !$this->isNeeded()) {
         $this->application->trace and $this->application['log']->debug("Skipping {$this->inspect()}");
         return;
     }
     $this->application['invocation_chain']->push($this);
     if ($this->application->trace) {
         $this->application['log']->debug("Invoke {$this->inspect()}");
     }
     $app = $this->application;
     itertools\walk(itertools\filter(itertools\to_iterator($this->prerequisites), function ($p) use($app) {
         return $app->taskDefined((string) $p);
     }), function ($p) use($app) {
         $app['tasks'][(string) $p]->invoke();
     });
     if ($this->prerequisites !== null) {
         $this->prerequisites->rewind();
     }
     $this->execute();
     $this->reenable = false;
 }
Exemplo n.º 2
0
 function testWalk()
 {
     $a = itertools\xrange(1, 7);
     $numbers = array();
     itertools\walk($a, function ($number) use(&$numbers) {
         $numbers[] = $number;
     });
     $this->assertEquals(range(1, 7), $numbers);
 }
Exemplo n.º 3
0
 function each($callback, $context = null)
 {
     if ($context !== null and $callback instanceof \Closure) {
         $callback = \Closure::bind($callback, $context);
     }
     $iterator = $this->getIterator();
     itertools\walk($iterator, $callback);
     return $this;
 }