Example #1
0
File: Task.php Project: 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;
 }
Example #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);
 }
Example #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;
 }