Merge "resourceloader: Remove PHP4-compat code"
[lhc/web/wiklou.git] / includes / libs / virtualrest / VirtualRESTServiceClient.php
index 519da43..4b8ad5e 100644 (file)
@@ -47,7 +47,7 @@ class VirtualRESTServiceClient {
        /** @var MultiHttpClient */
        protected $http;
        /** @var Array Map of (prefix => VirtualRESTService) */
-       protected $instances = array();
+       protected $instances = [];
 
        const VALID_MOUNT_REGEX = '#^/[0-9a-z]+/([0-9a-z]+/)*$#';
 
@@ -103,7 +103,7 @@ class VirtualRESTServiceClient {
                        return ( $al < $bl ) ? 1 : -1; // largest prefix first
                };
 
-               $matches = array(); // matching prefixes (mount points)
+               $matches = []; // matching prefixes (mount points)
                foreach ( $this->instances as $prefix => $service ) {
                        if ( strpos( $path, $prefix ) === 0 ) {
                                $matches[] = $prefix;
@@ -113,8 +113,8 @@ class VirtualRESTServiceClient {
 
                // Return the most specific prefix and corresponding service
                return isset( $matches[0] )
-                       ? array( $matches[0], $this->instances[$matches[0]] )
-                       : array( null, null );
+                       ? [ $matches[0], $this->instances[$matches[0]] ]
+                       : [ null, null ];
        }
 
        /**
@@ -134,8 +134,7 @@ class VirtualRESTServiceClient {
         * @return array Response array for request
         */
        public function run( array $req ) {
-               $responses = $this->runMulti( array( $req ) );
-               return $responses[0];
+               return $this->runMulti( [ $req ] )[0];
        }
 
        /**
@@ -166,17 +165,17 @@ class VirtualRESTServiceClient {
                                $req['url'] = $req[1]; // short-form
                                unset( $req[1] );
                        }
-                       $req['chain'] = array(); // chain or list of replaced requests
+                       $req['chain'] = []; // chain or list of replaced requests
                }
                unset( $req ); // don't assign over this by accident
 
                $curUniqueId = 0;
-               $armoredIndexMap = array(); // (original index => new index)
+               $armoredIndexMap = []; // (original index => new index)
 
-               $doneReqs = array(); // (index => request)
-               $executeReqs = array(); // (index => request)
-               $replaceReqsByService = array(); // (prefix => index => request)
-               $origPending = array(); // (index => 1) for original requests
+               $doneReqs = []; // (index => request)
+               $executeReqs = []; // (index => request)
+               $replaceReqsByService = []; // (prefix => index => request)
+               $origPending = []; // (index => 1) for original requests
 
                foreach ( $reqs as $origIndex => $req ) {
                        // Re-index keys to consecutive integers (they will be swapped back later)
@@ -210,12 +209,12 @@ class VirtualRESTServiceClient {
                        }
                        // Track requests executed this round that have a prefix/service.
                        // Note that this also includes requests where 'response' was forced.
-                       $checkReqIndexesByPrefix = array();
+                       $checkReqIndexesByPrefix = [];
                        // Resolve the virtual URLs valid and qualified HTTP(S) URLs
                        // and add any required authentication headers for the backend.
                        // Services can also replace requests with new ones, either to
                        // defer the original or to set a proxy response to the original.
-                       $newReplaceReqsByService = array();
+                       $newReplaceReqsByService = [];
                        foreach ( $replaceReqsByService as $prefix => $servReqs ) {
                                $service = $this->instances[$prefix];
                                foreach ( $service->onRequests( $servReqs, $idFunc ) as $index => $req ) {
@@ -245,13 +244,13 @@ class VirtualRESTServiceClient {
                                $doneReqs[$index] = $ranReq;
                                unset( $origPending[$index] );
                        }
-                       $executeReqs = array();
+                       $executeReqs = [];
                        // Services can also replace requests with new ones, either to
                        // defer the original or to set a proxy response to the original.
                        // Any replacement requests executed above will need to be replaced
                        // with new requests (eventually the original). The responses can be
                        // forced by setting 'response' rather than actually be sent over the wire.
-                       $newReplaceReqsByService = array();
+                       $newReplaceReqsByService = [];
                        foreach ( $checkReqIndexesByPrefix as $prefix => $servReqIndexes ) {
                                $service = $this->instances[$prefix];
                                // $doneReqs actually has the requests (with 'response' set)
@@ -278,7 +277,7 @@ class VirtualRESTServiceClient {
                        $replaceReqsByService = $newReplaceReqsByService;
                } while ( count( $origPending ) );
 
-               $responses = array();
+               $responses = [];
                // Update $reqs to include 'response' and normalized request 'headers'.
                // This maintains the original order of $reqs.
                foreach ( $reqs as $origIndex => $req ) {