Merge "Use POST to submit wikitext to mw.api.parse"
[lhc/web/wiklou.git] / includes / shell / Command.php
index 2afc548..ba8133f 100644 (file)
@@ -111,11 +111,10 @@ class Command {
         * Adds parameters to the command. All parameters are sanitized via Shell::escape().
         * Null values are ignored.
         *
-        * @param string|string[] $args,...
+        * @param string|string[] ...$args
         * @return $this
         */
-       public function params( /* ... */ ) {
-               $args = func_get_args();
+       public function params( ...$args ) {
                if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
                        // If only one argument has been passed, and that argument is an array,
                        // treat it as a list of arguments
@@ -130,11 +129,10 @@ class Command {
         * Adds unsafe parameters to the command. These parameters are NOT sanitized in any way.
         * Null values are ignored.
         *
-        * @param string|string[] $args,...
+        * @param string|string[] ...$args
         * @return $this
         */
-       public function unsafeParams( /* ... */ ) {
-               $args = func_get_args();
+       public function unsafeParams( ...$args ) {
                if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
                        // If only one argument has been passed, and that argument is an array,
                        // treat it as a list of arguments
@@ -429,13 +427,13 @@ class Command {
                        }
 
                        // clear get_last_error without actually raising an error
-                       // from https://secure.php.net/manual/en/function.error-get-last.php#113518
+                       // from https://www.php.net/manual/en/function.error-get-last.php#113518
                        // TODO replace with clear_last_error when requirements are bumped to PHP7
                        set_error_handler( function () {
                        }, 0 );
-                       \MediaWiki\suppressWarnings();
+                       \Wikimedia\suppressWarnings();
                        trigger_error( '' );
-                       \MediaWiki\restoreWarnings();
+                       \Wikimedia\restoreWarnings();
                        restore_error_handler();
 
                        $readPipes = array_filter( $pipes, function ( $fd ) use ( $desc ) {
@@ -553,4 +551,15 @@ class Command {
 
                return new Result( $retval, $buffers[1], $buffers[2] );
        }
+
+       /**
+        * Returns the final command line before environment/limiting, etc are applied.
+        * Use string conversion only for debugging, don't try to pass this to
+        * some other execution medium.
+        *
+        * @return string
+        */
+       public function __toString() {
+               return "#Command: {$this->command}";
+       }
 }