Example #1
0
 /**
  * @param string $source
  * @param string $input
  * @param int    $fetchMode
  *
  * @return array|string
  */
 public function run($source, $input = "", $fetchMode = Output::FETCH_ARRAY)
 {
     $this->parser->loadSource($source);
     if ($this->parser->getFlag("string_output") === true) {
         $fetchMode = Output::FETCH_STRING;
     }
     $appLoop = $this->parser->parse($this->optimize);
     $appInput = $this->parser->getInput();
     if (!empty($appInput)) {
         $input = $appInput;
     }
     $this->vm->init($input);
     $appLoop->execute($this->vm);
     return $this->vm->getOutput()->fetch($fetchMode);
 }