collection = $collection; $this->task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; $this->rollbackTask = $rollbackTask; } /** * {@inheritdoc} */ public function original() { return $this->task; } /** * Before running this task, register its rollback and completion * handlers on its collection. The reason this class exists is to * defer registration of rollback and completion tasks until 'run()' time. * * @return \Robo\Result */ public function run() { if ($this->rollbackTask) { $this->collection->registerRollback($this->rollbackTask); } if ($this->task instanceof RollbackInterface) { $this->collection->registerRollback(new CallableTask([$this->task, 'rollback'], $this->task)); } if ($this->task instanceof CompletionInterface) { $this->collection->registerCompletion(new CallableTask([$this->task, 'complete'], $this->task)); } return $this->task->run(); } /** * Make this wrapper object act like the class it wraps. * * @param string $function * @param array $args * * @return mixed */ public function __call($function, $args) { return call_user_func_array(array($this->task, $function), $args); } }