Completed
Push — master ( 7c04cb...320bc7 )
by Gaetano
06:16
created
src/Client.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
             $server = $parts['host'];
137 137
             $path = isset($parts['path']) ? $parts['path'] : '';
138 138
             if (isset($parts['query'])) {
139
-                $path .= '?' . $parts['query'];
139
+                $path .= '?'.$parts['query'];
140 140
             }
141 141
             if (isset($parts['fragment'])) {
142
-                $path .= '#' . $parts['fragment'];
142
+                $path .= '#'.$parts['fragment'];
143 143
             }
144 144
             if (isset($parts['port'])) {
145 145
                 $port = $parts['port'];
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             }
156 156
         }
157 157
         if ($path == '' || $path[0] != '/') {
158
-            $this->path = '/' . $path;
158
+            $this->path = '/'.$path;
159 159
         } else {
160 160
             $this->path = $path;
161 161
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         }*/
194 194
 
195 195
         // initialize user_agent string
196
-        $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion;
196
+        $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion;
197 197
     }
198 198
 
199 199
     /**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
      */
567 567
     protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '',
568 568
         $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1,
569
-        $method='http')
569
+        $method = 'http')
570 570
     {
571 571
         return $this->sendPayloadSocket($req, $server, $port, $timeout, $username, $password, $authType, null, null,
572 572
             null, null, $proxyHost, $proxyPort, $proxyUsername, $proxyPassword, $proxyAuthType);
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      * @param int $sslVersion
597 597
      * @return Response
598 598
      */
599
-    protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '',  $password = '',
599
+    protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '',
600 600
         $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
601 601
         $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '',
602 602
         $sslVersion = 0)
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
      */
632 632
     protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '',
633 633
         $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
634
-        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '',
634
+        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '',
635 635
         $sslVersion = 0)
636 636
     {
637 637
         if ($port == 0) {
638
-            $port = ( $method === 'https' ) ? 443 : 80;
638
+            $port = ($method === 'https') ? 443 : 80;
639 639
         }
640 640
 
641 641
         // Only create the payload if it was not created previously
@@ -666,15 +666,15 @@  discard block
 block discarded – undo
666 666
         // thanks to Grant Rauscher <[email protected]> for this
667 667
         $credentials = '';
668 668
         if ($username != '') {
669
-            $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
669
+            $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n";
670 670
             if ($authType != 1) {
671
-                error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
671
+                error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
672 672
             }
673 673
         }
674 674
 
675 675
         $acceptedEncoding = '';
676 676
         if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
677
-            $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
677
+            $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n";
678 678
         }
679 679
 
680 680
         $proxyCredentials = '';
@@ -685,17 +685,17 @@  discard block
 block discarded – undo
685 685
             $connectServer = $proxyHost;
686 686
             $connectPort = $proxyPort;
687 687
             $transport = 'tcp';
688
-            $uri = 'http://' . $server . ':' . $port . $this->path;
688
+            $uri = 'http://'.$server.':'.$port.$this->path;
689 689
             if ($proxyUsername != '') {
690 690
                 if ($proxyAuthType != 1) {
691
-                    error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
691
+                    error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
692 692
                 }
693
-                $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n";
693
+                $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n";
694 694
             }
695 695
         } else {
696 696
             $connectServer = $server;
697 697
             $connectPort = $port;
698
-            $transport = ( $method === 'https' ) ? 'tls' : 'tcp';
698
+            $transport = ($method === 'https') ? 'tls' : 'tcp';
699 699
             $uri = $this->path;
700 700
         }
701 701
 
@@ -706,45 +706,45 @@  discard block
 block discarded – undo
706 706
             $version = '';
707 707
             foreach ($this->cookies as $name => $cookie) {
708 708
                 if ($cookie['version']) {
709
-                    $version = ' $Version="' . $cookie['version'] . '";';
710
-                    $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";';
709
+                    $version = ' $Version="'.$cookie['version'].'";';
710
+                    $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";';
711 711
                     if ($cookie['path']) {
712
-                        $cookieHeader .= ' $Path="' . $cookie['path'] . '";';
712
+                        $cookieHeader .= ' $Path="'.$cookie['path'].'";';
713 713
                     }
714 714
                     if ($cookie['domain']) {
715
-                        $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";';
715
+                        $cookieHeader .= ' $Domain="'.$cookie['domain'].'";';
716 716
                     }
717 717
                     if ($cookie['port']) {
718
-                        $cookieHeader .= ' $Port="' . $cookie['port'] . '";';
718
+                        $cookieHeader .= ' $Port="'.$cookie['port'].'";';
719 719
                     }
720 720
                 } else {
721
-                    $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";";
721
+                    $cookieHeader .= ' '.$name.'='.$cookie['value'].";";
722 722
                 }
723 723
             }
724
-            $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n";
724
+            $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n";
725 725
         }
726 726
 
727 727
         // omit port if default
728 728
         if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) {
729
-            $port =  '';
729
+            $port = '';
730 730
         } else {
731
-            $port = ':' . $port;
731
+            $port = ':'.$port;
732 732
         }
733 733
 
734
-        $op = 'POST ' . $uri . " HTTP/1.0\r\n" .
735
-            'User-Agent: ' . $this->user_agent . "\r\n" .
736
-            'Host: ' . $server . $port . "\r\n" .
737
-            $credentials .
738
-            $proxyCredentials .
739
-            $acceptedEncoding .
740
-            $encodingHdr .
741
-            'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
742
-            $cookieHeader .
743
-            'Content-Type: ' . $req->content_type . "\r\nContent-Length: " .
744
-            strlen($payload) . "\r\n\r\n" .
734
+        $op = 'POST '.$uri." HTTP/1.0\r\n".
735
+            'User-Agent: '.$this->user_agent."\r\n".
736
+            'Host: '.$server.$port."\r\n".
737
+            $credentials.
738
+            $proxyCredentials.
739
+            $acceptedEncoding.
740
+            $encodingHdr.
741
+            'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n".
742
+            $cookieHeader.
743
+            'Content-Type: '.$req->content_type."\r\nContent-Length: ".
744
+            strlen($payload)."\r\n\r\n".
745 745
             $payload;
746 746
 
747
-        if ($this->debug > 1) {
747
+        if ($this->debug>1) {
748 748
             Logger::instance()->debugMessage("---SENDING---\n$op\n---END---");
749 749
         }
750 750
 
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
         }
771 771
         $context = stream_context_create($contextOptions);
772 772
 
773
-        if ($timeout <= 0) {
773
+        if ($timeout<=0) {
774 774
             $connectTimeout = ini_get('default_socket_timeout');
775 775
         } else {
776 776
             $connectTimeout = $timeout;
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
         $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout,
780 780
             STREAM_CLIENT_CONNECT, $context);
781 781
         if ($fp) {
782
-            if ($timeout > 0) {
782
+            if ($timeout>0) {
783 783
                 stream_set_timeout($fp, $timeout);
784 784
             }
785 785
         } else {
786
-            $this->errstr = 'Connect error: ' . $this->errstr;
787
-            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')');
786
+            $this->errstr = 'Connect error: '.$this->errstr;
787
+            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')');
788 788
 
789 789
             return $r;
790 790
         }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             $encodingHdr = '';
893 893
         }
894 894
 
895
-        if ($this->debug > 1) {
895
+        if ($this->debug>1) {
896 896
             Logger::instance()->debugMessage("---SENDING---\n$payload\n---END---");
897 897
         }
898 898
 
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
             } else {
903 903
                 $protocol = $method;
904 904
             }
905
-            $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path);
905
+            $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path);
906 906
             if ($keepAlive) {
907 907
                 $this->xmlrpc_curl_handle = $curl;
908 908
             }
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
         // results into variable
914 914
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
915 915
 
916
-        if ($this->debug > 1) {
916
+        if ($this->debug>1) {
917 917
             curl_setopt($curl, CURLOPT_VERBOSE, true);
918 918
             /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered
919 919
         }
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
             }
940 940
         }
941 941
         // extra headers
942
-        $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
942
+        $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings));
943 943
         // if no keepalive is wanted, let the server know it in advance
944 944
         if (!$keepAlive) {
945 945
             $headers[] = 'Connection: close';
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
957 957
         // timeout is borked
958 958
         if ($timeout) {
959
-            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
959
+            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1);
960 960
         }
961 961
 
962 962
         if ($method == 'http10') {
@@ -966,11 +966,11 @@  discard block
 block discarded – undo
966 966
         }
967 967
 
968 968
         if ($username && $password) {
969
-            curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
969
+            curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
970 970
             if (defined('CURLOPT_HTTPAUTH')) {
971 971
                 curl_setopt($curl, CURLOPT_HTTPAUTH, $authType);
972 972
             } elseif ($authType != 1) {
973
-                error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
973
+                error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
974 974
             }
975 975
         }
976 976
 
@@ -1011,13 +1011,13 @@  discard block
 block discarded – undo
1011 1011
             if ($proxyPort == 0) {
1012 1012
                 $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080
1013 1013
             }
1014
-            curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
1014
+            curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort);
1015 1015
             if ($proxyUsername) {
1016
-                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword);
1016
+                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword);
1017 1017
                 if (defined('CURLOPT_PROXYAUTH')) {
1018 1018
                     curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType);
1019 1019
                 } elseif ($proxyAuthType != 1) {
1020
-                    error_log('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1020
+                    error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1021 1021
                 }
1022 1022
             }
1023 1023
         }
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
         if (count($this->cookies)) {
1029 1029
             $cookieHeader = '';
1030 1030
             foreach ($this->cookies as $name => $cookie) {
1031
-                $cookieHeader .= $name . '=' . $cookie['value'] . '; ';
1031
+                $cookieHeader .= $name.'='.$cookie['value'].'; ';
1032 1032
             }
1033 1033
             curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2));
1034 1034
         }
@@ -1039,13 +1039,13 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
         $result = curl_exec($curl);
1041 1041
 
1042
-        if ($this->debug > 1) {
1042
+        if ($this->debug>1) {
1043 1043
             $message = "---CURL INFO---\n";
1044 1044
             foreach (curl_getinfo($curl) as $name => $val) {
1045 1045
                 if (is_array($val)) {
1046 1046
                     $val = implode("\n", $val);
1047 1047
                 }
1048
-                $message .= $name . ': ' . $val . "\n";
1048
+                $message .= $name.': '.$val."\n";
1049 1049
             }
1050 1050
             $message .= '---END---';
1051 1051
             Logger::instance()->debugMessage($message);
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
             /// @todo we should use a better check here - what if we get back '' or '0'?
1056 1056
 
1057 1057
             $this->errstr = 'no response';
1058
-            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl));
1058
+            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl));
1059 1059
             curl_close($curl);
1060 1060
             if ($keepAlive) {
1061 1061
                 $this->xmlrpc_curl_handle = null;
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
             $call['methodName'] = new Value($req->method(), 'string');
1166 1166
             $numParams = $req->getNumParams();
1167 1167
             $params = array();
1168
-            for ($i = 0; $i < $numParams; $i++) {
1168
+            for ($i = 0; $i<$numParams; $i++) {
1169 1169
                 $params[$i] = $req->getParam($i);
1170 1170
             }
1171 1171
             $call['params'] = new Value($params, 'array');
@@ -1191,15 +1191,15 @@  discard block
 block discarded – undo
1191 1191
             /// @todo test this code branch...
1192 1192
             $rets = $result->value();
1193 1193
             if (!is_array($rets)) {
1194
-                return false;       // bad return type from system.multicall
1194
+                return false; // bad return type from system.multicall
1195 1195
             }
1196 1196
             $numRets = count($rets);
1197 1197
             if ($numRets != count($reqs)) {
1198
-                return false;       // wrong number of return values.
1198
+                return false; // wrong number of return values.
1199 1199
             }
1200 1200
 
1201 1201
             $response = array();
1202
-            for ($i = 0; $i < $numRets; $i++) {
1202
+            for ($i = 0; $i<$numRets; $i++) {
1203 1203
                 $val = $rets[$i];
1204 1204
                 if (!is_array($val)) {
1205 1205
                     return false;
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
                 switch (count($val)) {
1208 1208
                     case 1:
1209 1209
                         if (!isset($val[0])) {
1210
-                            return false;       // Bad value
1210
+                            return false; // Bad value
1211 1211
                         }
1212 1212
                         // Normal return value
1213 1213
                         $response[$i] = new Response($val[0], 0, '', 'phpvals');
@@ -1235,19 +1235,19 @@  discard block
 block discarded – undo
1235 1235
 
1236 1236
             $rets = $result->value();
1237 1237
             if ($rets->kindOf() != 'array') {
1238
-                return false;       // bad return type from system.multicall
1238
+                return false; // bad return type from system.multicall
1239 1239
             }
1240 1240
             $numRets = $rets->count();
1241 1241
             if ($numRets != count($reqs)) {
1242
-                return false;       // wrong number of return values.
1242
+                return false; // wrong number of return values.
1243 1243
             }
1244 1244
 
1245 1245
             $response = array();
1246
-            foreach($rets as $val) {
1246
+            foreach ($rets as $val) {
1247 1247
                 switch ($val->kindOf()) {
1248 1248
                     case 'array':
1249 1249
                         if ($val->count() != 1) {
1250
-                            return false;       // Bad value
1250
+                            return false; // Bad value
1251 1251
                         }
1252 1252
                         // Normal return value
1253 1253
                         $response[] = new Response($val[0]);
Please login to merge, or discard this patch.