Пример #1
0
 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $way = array_shift($args);
     $argc = sizeof($args);
     // Read sourcecode from STDIN if no further argument is given
     if (0 === $argc) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             $code = new Code($args[0]);
         }
     }
     // Perform
     $argv = [XPClass::nameOf(self::class)] + $args;
     $return = eval($code->head() . $code->expression());
     switch ($way) {
         case '-w':
             Console::writeLine($return);
             break;
         case '-d':
             var_dump($return);
             break;
     }
 }
Пример #2
0
 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $argc = sizeof($args);
     // Read sourcecode from STDIN if no further argument is given
     if (0 === $argc) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             $code = new Code($args[0]);
         }
     }
     // Perform
     $argv = [XPClass::nameOf(__CLASS__)] + $args;
     return eval($code->head() . $code->fragment());
 }
Пример #3
0
 /**
  * Main
  *
  * @param  string[] $args
  * @return int
  */
 public static function main(array $args)
 {
     // Read sourcecode from STDIN if no further argument is given
     if (empty($args)) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             if (is_file($args[0])) {
                 $code = new Code(file_get_contents($args[0]));
             } else {
                 $code = new Code($args[0]);
             }
         }
     }
     // Perform
     $argv = [XPClass::nameOf(self::class)] + $args;
     return eval($code->head() . $code->fragment());
 }