Passed
Push — master ( d1e4d1...1fc984 )
by Gaetano
09:00
created
src/Client.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
             $server = $parts['host'];
159 159
             $path = isset($parts['path']) ? $parts['path'] : '';
160 160
             if (isset($parts['query'])) {
161
-                $path .= '?' . $parts['query'];
161
+                $path .= '?'.$parts['query'];
162 162
             }
163 163
             if (isset($parts['fragment'])) {
164
-                $path .= '#' . $parts['fragment'];
164
+                $path .= '#'.$parts['fragment'];
165 165
             }
166 166
             if (isset($parts['port'])) {
167 167
                 $port = $parts['port'];
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             }
178 178
         }
179 179
         if ($path == '' || $path[0] != '/') {
180
-            $this->path = '/' . $path;
180
+            $this->path = '/'.$path;
181 181
         } else {
182 182
             $this->path = $path;
183 183
         }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         }*/
216 216
 
217 217
         // initialize user_agent string
218
-        $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion;
218
+        $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion;
219 219
     }
220 220
 
221 221
     /**
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      */
595 595
     protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '',
596 596
         $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1,
597
-        $method='http')
597
+        $method = 'http')
598 598
     {
599 599
         //trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED);
600 600
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
      *
628 628
      * @return Response
629 629
      */
630
-    protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '',  $password = '',
630
+    protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '',
631 631
         $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
632 632
         $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '',
633 633
         $sslVersion = 0)
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
      */
668 668
     protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '',
669 669
         $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
670
-        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '',
670
+        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '',
671 671
         $sslVersion = 0)
672 672
     {
673 673
         /// @todo log a warning if passed an unsupported method
@@ -703,16 +703,16 @@  discard block
 block discarded – undo
703 703
         // thanks to Grant Rauscher <[email protected]> for this
704 704
         $credentials = '';
705 705
         if ($username != '') {
706
-            $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
706
+            $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n";
707 707
             if ($authType != 1) {
708 708
                 /// @todo make this a proper error, ie. return a failure
709
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
709
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
710 710
             }
711 711
         }
712 712
 
713 713
         $acceptedEncoding = '';
714 714
         if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
715
-            $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
715
+            $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n";
716 716
         }
717 717
 
718 718
         $proxyCredentials = '';
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
             $connectPort = $proxyPort;
725 725
             $transport = 'tcp';
726 726
             /// @todo check: should we not use https in some cases?
727
-            $uri = 'http://' . $server . ':' . $port . $this->path;
727
+            $uri = 'http://'.$server.':'.$port.$this->path;
728 728
             if ($proxyUsername != '') {
729 729
                 if ($proxyAuthType != 1) {
730 730
                     /// @todo make this a proper error, ie. return a failure
731
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
731
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
732 732
                 }
733
-                $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n";
733
+                $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n";
734 734
             }
735 735
         } else {
736 736
             $connectServer = $server;
@@ -745,45 +745,45 @@  discard block
 block discarded – undo
745 745
             $version = '';
746 746
             foreach ($this->cookies as $name => $cookie) {
747 747
                 if ($cookie['version']) {
748
-                    $version = ' $Version="' . $cookie['version'] . '";';
749
-                    $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";';
748
+                    $version = ' $Version="'.$cookie['version'].'";';
749
+                    $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";';
750 750
                     if ($cookie['path']) {
751
-                        $cookieHeader .= ' $Path="' . $cookie['path'] . '";';
751
+                        $cookieHeader .= ' $Path="'.$cookie['path'].'";';
752 752
                     }
753 753
                     if ($cookie['domain']) {
754
-                        $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";';
754
+                        $cookieHeader .= ' $Domain="'.$cookie['domain'].'";';
755 755
                     }
756 756
                     if ($cookie['port']) {
757
-                        $cookieHeader .= ' $Port="' . $cookie['port'] . '";';
757
+                        $cookieHeader .= ' $Port="'.$cookie['port'].'";';
758 758
                     }
759 759
                 } else {
760
-                    $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";";
760
+                    $cookieHeader .= ' '.$name.'='.$cookie['value'].";";
761 761
                 }
762 762
             }
763
-            $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n";
763
+            $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n";
764 764
         }
765 765
 
766 766
         // omit port if default
767 767
         if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) {
768
-            $port =  '';
768
+            $port = '';
769 769
         } else {
770
-            $port = ':' . $port;
770
+            $port = ':'.$port;
771 771
         }
772 772
 
773
-        $op = 'POST ' . $uri . " HTTP/1.0\r\n" .
774
-            'User-Agent: ' . $this->user_agent . "\r\n" .
775
-            'Host: ' . $server . $port . "\r\n" .
776
-            $credentials .
777
-            $proxyCredentials .
778
-            $acceptedEncoding .
779
-            $encodingHdr .
780
-            'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
781
-            $cookieHeader .
782
-            'Content-Type: ' . $req->content_type . "\r\nContent-Length: " .
783
-            strlen($payload) . "\r\n\r\n" .
773
+        $op = 'POST '.$uri." HTTP/1.0\r\n".
774
+            'User-Agent: '.$this->user_agent."\r\n".
775
+            'Host: '.$server.$port."\r\n".
776
+            $credentials.
777
+            $proxyCredentials.
778
+            $acceptedEncoding.
779
+            $encodingHdr.
780
+            'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n".
781
+            $cookieHeader.
782
+            'Content-Type: '.$req->content_type."\r\nContent-Length: ".
783
+            strlen($payload)."\r\n\r\n".
784 784
             $payload;
785 785
 
786
-        if ($this->debug > 1) {
786
+        if ($this->debug>1) {
787 787
             $this->getLogger()->debugMessage("---SENDING---\n$op\n---END---");
788 788
         }
789 789
 
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 
811 811
         $context = stream_context_create($contextOptions);
812 812
 
813
-        if ($timeout <= 0) {
813
+        if ($timeout<=0) {
814 814
             $connectTimeout = ini_get('default_socket_timeout');
815 815
         } else {
816 816
             $connectTimeout = $timeout;
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
         $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout,
823 823
             STREAM_CLIENT_CONNECT, $context);
824 824
         if ($fp) {
825
-            if ($timeout > 0) {
825
+            if ($timeout>0) {
826 826
                 stream_set_timeout($fp, $timeout, 0);
827 827
             }
828 828
         } else {
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
                 $this->errstr = $err['message'];
832 832
             }
833 833
 
834
-            $this->errstr = 'Connect error: ' . $this->errstr;
835
-            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')');
834
+            $this->errstr = 'Connect error: '.$this->errstr;
835
+            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')');
836 836
 
837 837
             return $r;
838 838
         }
@@ -921,18 +921,18 @@  discard block
 block discarded – undo
921 921
             $keyPass, $sslVersion);
922 922
 
923 923
         if (!$curl) {
924
-            return new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': error during curl initialization. Check php error log for details');
924
+            return new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': error during curl initialization. Check php error log for details');
925 925
         }
926 926
 
927 927
         $result = curl_exec($curl);
928 928
 
929
-        if ($this->debug > 1) {
929
+        if ($this->debug>1) {
930 930
             $message = "---CURL INFO---\n";
931 931
             foreach (curl_getinfo($curl) as $name => $val) {
932 932
                 if (is_array($val)) {
933 933
                     $val = implode("\n", $val);
934 934
                 }
935
-                $message .= $name . ': ' . $val . "\n";
935
+                $message .= $name.': '.$val."\n";
936 936
             }
937 937
             $message .= '---END---';
938 938
             $this->getLogger()->debugMessage($message);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             /// @todo we should use a better check here - what if we get back '' or '0'?
943 943
 
944 944
             $this->errstr = 'no response';
945
-            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl));
945
+            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl));
946 946
             curl_close($curl);
947 947
             if ($keepAlive) {
948 948
                 $this->xmlrpc_curl_handle = null;
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
                     // http, https
1013 1013
                     $protocol = $method;
1014 1014
                     if (strpos($protocol, ':') !== false) {
1015
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'");
1015
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'");
1016 1016
                         return false;
1017 1017
                     }
1018 1018
                 }
1019 1019
             }
1020
-            $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path);
1020
+            $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path);
1021 1021
             if (!$curl) {
1022 1022
                 return false;
1023 1023
             }
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
         // results into variable
1032 1032
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
1033 1033
 
1034
-        if ($this->debug > 1) {
1034
+        if ($this->debug>1) {
1035 1035
             curl_setopt($curl, CURLOPT_VERBOSE, true);
1036 1036
             /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered
1037 1037
         }
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
             }
1057 1057
         }
1058 1058
         // extra headers
1059
-        $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
1059
+        $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings));
1060 1060
         // if no keepalive is wanted, let the server know it in advance
1061 1061
         if (!$keepAlive) {
1062 1062
             $headers[] = 'Connection: close';
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
1074 1074
         // timeout is borked
1075 1075
         if ($timeout) {
1076
-            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
1076
+            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1);
1077 1077
         }
1078 1078
 
1079 1079
         switch ($method) {
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
                     curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
1089 1089
                 } else {
1090 1090
                     /// @todo make this a proper error, ie. return a failure
1091
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install');
1091
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. HTTP2 is not supported by the current PHP/curl install');
1092 1092
                 }
1093 1093
                 break;
1094 1094
             case 'h2':
@@ -1097,12 +1097,12 @@  discard block
 block discarded – undo
1097 1097
         }
1098 1098
 
1099 1099
         if ($username && $password) {
1100
-            curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
1100
+            curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
1101 1101
             if (defined('CURLOPT_HTTPAUTH')) {
1102 1102
                 curl_setopt($curl, CURLOPT_HTTPAUTH, $authType);
1103 1103
             } elseif ($authType != 1) {
1104 1104
                 /// @todo make this a proper error, ie. return a failure
1105
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
1105
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
1106 1106
             }
1107 1107
         }
1108 1108
 
@@ -1145,14 +1145,14 @@  discard block
 block discarded – undo
1145 1145
             if ($proxyPort == 0) {
1146 1146
                 $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080
1147 1147
             }
1148
-            curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
1148
+            curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort);
1149 1149
             if ($proxyUsername) {
1150
-                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword);
1150
+                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword);
1151 1151
                 if (defined('CURLOPT_PROXYAUTH')) {
1152 1152
                     curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType);
1153 1153
                 } elseif ($proxyAuthType != 1) {
1154 1154
                     /// @todo make this a proper error, ie. return a failure
1155
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1155
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1156 1156
                 }
1157 1157
             }
1158 1158
         }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
         if (count($this->cookies)) {
1163 1163
             $cookieHeader = '';
1164 1164
             foreach ($this->cookies as $name => $cookie) {
1165
-                $cookieHeader .= $name . '=' . $cookie['value'] . '; ';
1165
+                $cookieHeader .= $name.'='.$cookie['value'].'; ';
1166 1166
             }
1167 1167
             curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2));
1168 1168
         }
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
             curl_setopt($curl, $opt, $val);
1172 1172
         }
1173 1173
 
1174
-        if ($this->debug > 1) {
1174
+        if ($this->debug>1) {
1175 1175
             $this->getLogger()->debugMessage("---SENDING---\n$payload\n---END---");
1176 1176
         }
1177 1177
 
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
             $call['methodName'] = new Value($req->method(), 'string');
1272 1272
             $numParams = $req->getNumParams();
1273 1273
             $params = array();
1274
-            for ($i = 0; $i < $numParams; $i++) {
1274
+            for ($i = 0; $i<$numParams; $i++) {
1275 1275
                 $params[$i] = $req->getParam($i);
1276 1276
             }
1277 1277
             $call['params'] = new Value($params, 'array');
@@ -1296,15 +1296,15 @@  discard block
 block discarded – undo
1296 1296
         } elseif ($this->return_type == 'phpvals') {
1297 1297
             /// @todo test this code branch...
1298 1298
             if (!is_array($rets)) {
1299
-                return false;       // bad return type from system.multicall
1299
+                return false; // bad return type from system.multicall
1300 1300
             }
1301 1301
             $numRets = count($rets);
1302 1302
             if ($numRets != count($reqs)) {
1303
-                return false;       // wrong number of return values.
1303
+                return false; // wrong number of return values.
1304 1304
             }
1305 1305
 
1306 1306
             $response = array();
1307
-            for ($i = 0; $i < $numRets; $i++) {
1307
+            for ($i = 0; $i<$numRets; $i++) {
1308 1308
                 $val = $rets[$i];
1309 1309
                 if (!is_array($val)) {
1310 1310
                     return false;
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
                 switch (count($val)) {
1313 1313
                     case 1:
1314 1314
                         if (!isset($val[0])) {
1315
-                            return false;       // Bad value
1315
+                            return false; // Bad value
1316 1316
                         }
1317 1317
                         // Normal return value
1318 1318
                         $response[$i] = new Response($val[0], 0, '', 'phpvals');
@@ -1338,11 +1338,11 @@  discard block
 block discarded – undo
1338 1338
         } else {
1339 1339
             // return type == 'xmlrpcvals'
1340 1340
             if ($rets->kindOf() != 'array') {
1341
-                return false;       // bad return type from system.multicall
1341
+                return false; // bad return type from system.multicall
1342 1342
             }
1343 1343
             $numRets = $rets->count();
1344 1344
             if ($numRets != count($reqs)) {
1345
-                return false;       // wrong number of return values.
1345
+                return false; // wrong number of return values.
1346 1346
             }
1347 1347
 
1348 1348
             $response = array();
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
                 switch ($val->kindOf()) {
1351 1351
                     case 'array':
1352 1352
                         if ($val->count() != 1) {
1353
-                            return false;       // Bad value
1353
+                            return false; // Bad value
1354 1354
                         }
1355 1355
                         // Normal return value
1356 1356
                         $response[] = new Response($val[0]);
Please login to merge, or discard this patch.