/** * Handle output based on Environment and Options * @param Result $result Object derived from Result * @return Interpreter */ public function doOutput(Result $result) { $this->debug(__METHOD__, __LINE__); if ($this->environment->isWeb()) { $json = json_encode($result->toArray()); $this->stdout($json); } else { if ($result->hasErrors()) { foreach ($result->getErrors() as $error) { $errstr = $this->outputFormatErrorMessage($error); $this->stderr($errstr); } if ($result->isFail()) { return; } } if ($buffer = trim($result->getOutput())) { $this->stdout($buffer . PHP_EOL); } } }
public function testArray() { $result = new Result("1\n2\n3\n"); $this->assertEquals([1, 2, 3], $result->toArray()); }
public function toArray() { return array_merge(parent::toArray(), array('owner' => $this->owner, 'trace' => $this->_trace)); }