Merge "Remove useless PHP version comparison from wfDebugBacktrace()"
[lhc/web/wiklou.git] / includes / libs / virtualrest / RestbaseVirtualRESTService.php
index 3a7bc58..16c9331 100644 (file)
@@ -29,7 +29,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
         *  POST /local/v1/transform/html/to/wikitext{/title}{/revision}
         *   * body: array( 'html' => ... )
         *  POST /local/v1/transform/wikitext/to/html{/title}{/revision}
-        *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'bodyOnly' => true/false )
+        *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body_only' => true/false )
         *
         * @param array $params Key/value map
         *   - url            : RESTBase server URL
@@ -47,7 +47,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
         */
        public function __construct( array $params ) {
                // set up defaults and merge them with the given params
-               $mparams = array_merge( array(
+               $mparams = array_merge( [
                        'name' => 'restbase',
                        'url' => 'http://localhost:7231/',
                        'domain' => 'localhost',
@@ -55,7 +55,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
                        'forwardCookies' => false,
                        'HTTPProxy' => null,
                        'parsoidCompat' => false
-               ), $params );
+               ], $params );
                // Ensure that the url parameter has a trailing slash.
                $mparams['url'] = preg_replace(
                        '#/?$#',
@@ -79,7 +79,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
                        return $this->onParsoidRequests( $reqs, $idGenFunc );
                }
 
-               $result = array();
+               $result = [];
                foreach ( $reqs as $key => $req ) {
                        // replace /local/ with the current domain
                        $req['url'] = preg_replace( '#^local/#', $this->params['domain'] . '/', $req['url'] );
@@ -107,12 +107,12 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
         */
        public function onParsoidRequests( array $reqs, Closure $idGeneratorFunc ) {
 
-               $result = array();
+               $result = [];
                foreach ( $reqs as $key => $req ) {
-                       $parts = explode( '/', $req['url'] );
-                       if ( $parts[1] === 'v3' ) {
+                       $version = explode( '/', $req['url'] )[1];
+                       if ( $version === 'v3' ) {
                                $result[$key] = $this->onParsoid3Request( $req, $idGeneratorFunc );
-                       } elseif ( $parts[1] === 'v1' ) {
+                       } elseif ( $version === 'v1' ) {
                                $result[$key] = $this->onParsoid1Request( $req, $idGeneratorFunc );
                        } else {
                                throw new Exception( "Only v1 and v3 are supported." );
@@ -193,7 +193,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
                                        throw new Exception( "You must set a 'wikitext' body key for this request" );
                                }
                                if ( isset( $req['body']['body'] ) ) {
-                                       $req['body']['bodyOnly'] = $req['body']['body'];
+                                       $req['body']['body_only'] = $req['body']['body'];
                                        unset( $req['body']['body'] );
                                }
                        } else {
@@ -225,7 +225,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService {
         *   * body: array( 'html' => ... )
         *   * $title and $revision are optional
         *  POST /local/v3/transform/wikitext/to/html/{$title}{/$revision}
-        *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'bodyOnly' => true/false )
+        *   * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body_only' => true/false )
         *   * $title is optional
         *   * $revision is optional
         */