コード例 #1
0
 /**
  * Attempt to get the method signatures in one request via system.multicall().
  * This is a boxcar feature of XML-RPC and is found on fewer servers.  However,
  * can significantly improve performance if present.
  *
  * @param  array $methods
  * @return array array(array(return, param, param, param...))
  */
 public function getSignatureForEachMethodByMulticall($methods = null)
 {
     if ($methods === null) {
         $methods = $this->listMethods();
     }
     $multicallParams = array();
     foreach ($methods as $method) {
         $multicallParams[] = array('methodName' => 'system.methodSignature', 'params' => array($method));
     }
     $serverSignatures = $this->system->multicall($multicallParams);
     if (!is_array($serverSignatures)) {
         $type = gettype($serverSignatures);
         $error = "Multicall return is malformed.  Expected array, got {$type}";
         throw new Exception\IntrospectException($error);
     }
     if (count($serverSignatures) != count($methods)) {
         $error = 'Bad number of signatures received from multicall';
         throw new Exception\IntrospectException($error);
     }
     // Create a new signatures array with the methods name as keys and the signature as value
     $signatures = array();
     foreach ($serverSignatures as $i => $signature) {
         $signatures[$methods[$i]] = $signature;
     }
     return $signatures;
 }