diff --git a/src/main/php/xp/compiler/CompileOnly.class.php b/src/main/php/xp/compiler/CompileOnly.class.php new file mode 100755 index 00000000..e9a14289 --- /dev/null +++ b/src/main/php/xp/compiler/CompileOnly.class.php @@ -0,0 +1,20 @@ + function($bytes) { }, + 'flush' => function() { }, + 'close' => function() { } + ]); + } +} \ No newline at end of file diff --git a/src/main/php/xp/compiler/CompileRunner.class.php b/src/main/php/xp/compiler/CompileRunner.class.php index 38ef76b4..82b0ce00 100755 --- a/src/main/php/xp/compiler/CompileRunner.class.php +++ b/src/main/php/xp/compiler/CompileRunner.class.php @@ -24,15 +24,18 @@ * ``` * - Compile `src/main/php` and `src/test/php` to the `dist` folder. * ```sh - * $ xp compile -o dist src/main/php/ src/test/php + * $ xp compile -o dist src/main/php/ src/test/php/ + * ``` + * - Compile `src/main/php`, do not write output + * ```sh + * $ xp compile -n src/main/php/ * ``` * - Target PHP 5.6 (default target is current PHP version) * ```sh * $ xp compile -t PHP.5.6 HelloWorld.php HelloWorld.class.php * ``` * - * By using the *-o* option, you can pass multiple input sources - * following it. + * The *-o* and *-n* options accept multiple input sources following them. * * @see https://github.com/xp-framework/rfc/issues/299 */ @@ -54,6 +57,10 @@ public static function main(array $args) { $out= $args[++$i]; $in= array_slice($args, $i + 1); break; + } else if ('-n' === $args[$i]) { + $out= null; + $in= array_slice($args, $i + 1); + break; } else { $in= $args[$i]; $out= isset($args[$i + 1]) ? $args[$i + 1] : '-'; diff --git a/src/main/php/xp/compiler/Output.class.php b/src/main/php/xp/compiler/Output.class.php index afb794be..f257ad34 100755 --- a/src/main/php/xp/compiler/Output.class.php +++ b/src/main/php/xp/compiler/Output.class.php @@ -11,7 +11,9 @@ abstract class Output { * @return self */ public static function newInstance($arg) { - if ('-' === $arg) { + if (null === $arg) { + return new CompileOnly(); + } else if ('-' === $arg) { return new ToStream(Console::$out->getStream()); } else if (strstr($arg, '.php')) { return new ToFile($arg);