예제 #1
0
파일: Interpreter.php 프로젝트: g4z/poop
 /**
  * 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);
         }
     }
 }
예제 #2
0
 public function testArray()
 {
     $result = new Result("1\n2\n3\n");
     $this->assertEquals([1, 2, 3], $result->toArray());
 }
예제 #3
0
파일: Error.php 프로젝트: jafarsidik/neuron
 public function toArray()
 {
     return array_merge(parent::toArray(), array('owner' => $this->owner, 'trace' => $this->_trace));
 }