Completed
Push — master ( 3167db...70e3fd )
by Gaetano
07:00
created
src/Helper/Charset.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 
52 52
     private function __construct()
53 53
     {
54
-        for ($i = 0; $i < 32; $i++) {
54
+        for ($i = 0; $i<32; $i++) {
55 55
             $this->xml_iso88591_Entities["in"][] = chr($i);
56 56
             $this->xml_iso88591_Entities["out"][] = "&#{$i};";
57 57
         }
58 58
 
59
-        for ($i = 160; $i < 256; $i++) {
59
+        for ($i = 160; $i<256; $i++) {
60 60
             $this->xml_iso88591_Entities["in"][] = chr($i);
61 61
             $this->xml_iso88591_Entities["out"][] = "&#{$i};";
62 62
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding;
94 94
         }
95 95
 
96
-        $conversion = strtoupper($srcEncoding . '_' . $destEncoding);
96
+        $conversion = strtoupper($srcEncoding.'_'.$destEncoding);
97 97
         switch ($conversion) {
98 98
             case 'ISO-8859-1_':
99 99
             case 'ISO-8859-1_US-ASCII':
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
                 // NB: this will choke on invalid UTF-8, going most likely beyond EOF
123 123
                 $escapedData = '';
124 124
                 // be kind to users creating string xmlrpc values out of different php types
125
-                $data = (string)$data;
125
+                $data = (string) $data;
126 126
                 $ns = strlen($data);
127
-                for ($nn = 0; $nn < $ns; $nn++) {
127
+                for ($nn = 0; $nn<$ns; $nn++) {
128 128
                     $ch = $data[$nn];
129 129
                     $ii = ord($ch);
130 130
                     // 7 bits: 0bbbbbbb (127)
131
-                    if ($ii < 128) {
131
+                    if ($ii<128) {
132 132
                         /// @todo shall we replace this with a (supposedly) faster str_replace?
133 133
                         switch ($ii) {
134 134
                             case 34:
@@ -152,33 +152,33 @@  discard block
 block discarded – undo
152 152
                     } // 11 bits: 110bbbbb 10bbbbbb (2047)
153 153
                     elseif ($ii >> 5 == 6) {
154 154
                         $b1 = ($ii & 31);
155
-                        $ii = ord($data[$nn + 1]);
155
+                        $ii = ord($data[$nn+1]);
156 156
                         $b2 = ($ii & 63);
157
-                        $ii = ($b1 * 64) + $b2;
157
+                        $ii = ($b1 * 64)+$b2;
158 158
                         $ent = sprintf('&#%d;', $ii);
159 159
                         $escapedData .= $ent;
160 160
                         $nn += 1;
161 161
                     } // 16 bits: 1110bbbb 10bbbbbb 10bbbbbb
162 162
                     elseif ($ii >> 4 == 14) {
163 163
                         $b1 = ($ii & 15);
164
-                        $ii = ord($data[$nn + 1]);
164
+                        $ii = ord($data[$nn+1]);
165 165
                         $b2 = ($ii & 63);
166
-                        $ii = ord($data[$nn + 2]);
166
+                        $ii = ord($data[$nn+2]);
167 167
                         $b3 = ($ii & 63);
168
-                        $ii = ((($b1 * 64) + $b2) * 64) + $b3;
168
+                        $ii = ((($b1 * 64)+$b2) * 64)+$b3;
169 169
                         $ent = sprintf('&#%d;', $ii);
170 170
                         $escapedData .= $ent;
171 171
                         $nn += 2;
172 172
                     } // 21 bits: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
173 173
                     elseif ($ii >> 3 == 30) {
174 174
                         $b1 = ($ii & 7);
175
-                        $ii = ord($data[$nn + 1]);
175
+                        $ii = ord($data[$nn+1]);
176 176
                         $b2 = ($ii & 63);
177
-                        $ii = ord($data[$nn + 2]);
177
+                        $ii = ord($data[$nn+2]);
178 178
                         $b3 = ($ii & 63);
179
-                        $ii = ord($data[$nn + 3]);
179
+                        $ii = ord($data[$nn+3]);
180 180
                         $b4 = ($ii & 63);
181
-                        $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
181
+                        $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4;
182 182
                         $ent = sprintf('&#%d;', $ii);
183 183
                         $escapedData .= $ent;
184 184
                         $nn += 3;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
             default:
215 215
                 $escapedData = '';
216
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
216
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported...");
217 217
         }
218 218
 
219 219
         return $escapedData;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             case 'iso88591':
268 268
                 return $this->xml_iso88591_Entities;
269 269
             default:
270
-                throw new \Exception('Unsupported charset: ' . $charset);
270
+                throw new \Exception('Unsupported charset: '.$charset);
271 271
         }
272 272
     }
273 273
 
Please login to merge, or discard this patch.
src/Helper/Http.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 
23 23
         // read chunk-size, chunk-extension (if any) and crlf
24 24
         // get the position of the linebreak
25
-        $chunkEnd = strpos($buffer, "\r\n") + 2;
25
+        $chunkEnd = strpos($buffer, "\r\n")+2;
26 26
         $temp = substr($buffer, 0, $chunkEnd);
27 27
         $chunkSize = hexdec(trim($temp));
28 28
         $chunkStart = $chunkEnd;
29
-        while ($chunkSize > 0) {
30
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize);
29
+        while ($chunkSize>0) {
30
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize);
31 31
 
32 32
             // just in case we got a broken connection
33 33
             if ($chunkEnd == false) {
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
             }
40 40
 
41 41
             // read chunk-data and crlf
42
-            $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
42
+            $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
43 43
             // append chunk-data to entity-body
44 44
             $new .= $chunk;
45 45
             // length := length + chunk-size
46 46
             $length += strlen($chunk);
47 47
             // read chunk-size and crlf
48
-            $chunkStart = $chunkEnd + 2;
48
+            $chunkStart = $chunkEnd+2;
49 49
 
50
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2;
50
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2;
51 51
             if ($chunkEnd == false) {
52 52
                 break; //just in case we got a broken connection
53 53
             }
54
-            $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
54
+            $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
55 55
             $chunkSize = hexdec(trim($temp));
56 56
             $chunkStart = $chunkEnd;
57 57
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @return array with keys 'headers' and 'cookies'
69 69
      * @throws \Exception
70 70
      */
71
-    public function parseResponseHeaders(&$data, $headersProcessed = false, $debug=0)
71
+    public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0)
72 72
     {
73 73
         $httpResponse = array('raw_data' => $data, 'headers'=> array(), 'cookies' => array());
74 74
 
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
             // (even though it is not valid http)
79 79
             $pos = strpos($data, "\r\n\r\n");
80 80
             if ($pos || is_int($pos)) {
81
-                $bd = $pos + 4;
81
+                $bd = $pos+4;
82 82
             } else {
83 83
                 $pos = strpos($data, "\n\n");
84 84
                 if ($pos || is_int($pos)) {
85
-                    $bd = $pos + 2;
85
+                    $bd = $pos+2;
86 86
                 } else {
87 87
                     // No separation between response headers and body: fault?
88 88
                     $bd = 0;
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                 // maybe we could take them into account, too?
94 94
                 $data = substr($data, $bd);
95 95
             } else {
96
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
97
-                throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
96
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
97
+                throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
98 98
             }
99 99
         }
100 100
 
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
         }
121 121
 
122 122
         if (!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) {
123
-            $errstr = substr($data, 0, strpos($data, "\n") - 1);
124
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
125
-            throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error']);
123
+            $errstr = substr($data, 0, strpos($data, "\n")-1);
124
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr);
125
+            throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error']);
126 126
         }
127 127
 
128 128
         // be tolerant to usage of \n instead of \r\n to separate headers and data
129 129
         // (even though it is not valid http)
130 130
         $pos = strpos($data, "\r\n\r\n");
131 131
         if ($pos || is_int($pos)) {
132
-            $bd = $pos + 4;
132
+            $bd = $pos+4;
133 133
         } else {
134 134
             $pos = strpos($data, "\n\n");
135 135
             if ($pos || is_int($pos)) {
136
-                $bd = $pos + 2;
136
+                $bd = $pos+2;
137 137
             } else {
138 138
                 // No separation between response headers and body: fault?
139 139
                 // we could take some action here instead of going on...
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         // be tolerant to line endings, and extra empty lines
145 145
         $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
146 146
 
147
-        foreach($ar as $line) {
147
+        foreach ($ar as $line) {
148 148
             // take care of multi-line headers and cookies
149 149
             $arr = explode(':', $line, 2);
150
-            if (count($arr) > 1) {
150
+            if (count($arr)>1) {
151 151
                 $headerName = strtolower(trim($arr[0]));
152 152
                 /// @todo some other headers (the ones that allow a CSV list of values)
153 153
                 /// do allow many values to be passed using multiple header lines.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                         // glue together all received cookies, using a comma to separate them
166 166
                         // (same as php does with getallheaders())
167 167
                         if (isset($httpResponse['headers'][$headerName])) {
168
-                            $httpResponse['headers'][$headerName] .= ', ' . trim($cookie);
168
+                            $httpResponse['headers'][$headerName] .= ', '.trim($cookie);
169 169
                         } else {
170 170
                             $httpResponse['headers'][$headerName] = trim($cookie);
171 171
                         }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 }
195 195
             } elseif (isset($headerName)) {
196 196
                 /// @todo version1 cookies might span multiple lines, thus breaking the parsing above
197
-                $httpResponse['headers'][$headerName] .= ' ' . trim($line);
197
+                $httpResponse['headers'][$headerName] .= ' '.trim($line);
198 198
             }
199 199
         }
200 200
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             // Decode chunked encoding sent by http 1.1 servers
219 219
             if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') {
220 220
                 if (!$data = Http::decodeChunked($data)) {
221
-                    Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
221
+                    Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server');
222 222
                     throw new \Exception(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail']);
223 223
                 }
224 224
             }
@@ -233,19 +233,19 @@  discard block
 block discarded – undo
233 233
                         if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
234 234
                             $data = $degzdata;
235 235
                             if ($debug) {
236
-                                Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
236
+                                Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
237 237
                             }
238 238
                         } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
239 239
                             $data = $degzdata;
240 240
                             if ($debug) {
241
-                                Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
241
+                                Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
242 242
                             }
243 243
                         } else {
244
-                            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
244
+                            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
245 245
                             throw new \Exception(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail']);
246 246
                         }
247 247
                     } else {
248
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
248
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
249 249
                         throw new \Exception(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress']);
250 250
                     }
251 251
                 }
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
     public function xml_header($charsetEncoding = '')
39 39
     {
40 40
         if ($charsetEncoding != '') {
41
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n";
41
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n";
42 42
         } else {
43
-            return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
43
+            return "<?xml version=\"1.0\"?".">\n<methodCall>\n";
44 44
         }
45 45
     }
46 46
 
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
     public function createPayload($charsetEncoding = '')
53 53
     {
54 54
         if ($charsetEncoding != '') {
55
-            $this->content_type = 'text/xml; charset=' . $charsetEncoding;
55
+            $this->content_type = 'text/xml; charset='.$charsetEncoding;
56 56
         } else {
57 57
             $this->content_type = 'text/xml';
58 58
         }
59 59
         $this->payload = $this->xml_header($charsetEncoding);
60
-        $this->payload .= '<methodName>' . Charset::instance()->encodeEntities(
61
-            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n";
60
+        $this->payload .= '<methodName>'.Charset::instance()->encodeEntities(
61
+            $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n";
62 62
         $this->payload .= "<params>\n";
63 63
         foreach ($this->params as $p) {
64
-            $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) .
64
+            $this->payload .= "<param>\n".$p->serialize($charsetEncoding).
65 65
                 "</param>\n";
66 66
         }
67 67
         $this->payload .= "</params>\n";
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array());
187 187
 
188 188
         if ($data == '') {
189
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': no response received from server.');
189
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': no response received from server.');
190 190
             return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']);
191 191
         }
192 192
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             $httpParser = new Http();
196 196
             try {
197 197
                 $this->httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug);
198
-            } catch(\Exception $e) {
198
+            } catch (\Exception $e) {
199 199
                 $r = new Response(0, $e->getCode(), $e->getMessage());
200 200
                 // failed processing of HTTP response headers
201 201
                 // save into response obj the full payload received, for debugging
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib
215 215
         $pos = strrpos($data, '</methodResponse>');
216 216
         if ($pos !== false) {
217
-            $data = substr($data, 0, $pos + 17);
217
+            $data = substr($data, 0, $pos+17);
218 218
         }
219 219
 
220 220
         // try to 'guestimate' the character encoding of the received response
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
             if ($start) {
226 226
                 $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
227 227
                 $end = strpos($data, '-->', $start);
228
-                $comments = substr($data, $start, $end - $start);
229
-                Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" .
230
-                    str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding);
228
+                $comments = substr($data, $start, $end-$start);
229
+                Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t".
230
+                    str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", $respEncoding);
231 231
             }
232 232
         }
233 233
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     if (extension_loaded('mbstring')) {
255 255
                         $data = mb_convert_encoding($data, 'UTF-8', $respEncoding);
256 256
                     } else {
257
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received response: ' . $respEncoding);
257
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$respEncoding);
258 258
                     }
259 259
                 }
260 260
             }
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
         $xmlRpcParser->parse($data, $returnType, XMLParser::ACCEPT_RESPONSE);
275 275
 
276 276
         // first error check: xml not well formed
277
-        if ($xmlRpcParser->_xh['isf'] > 2) {
277
+        if ($xmlRpcParser->_xh['isf']>2) {
278 278
 
279 279
             // BC break: in the past for some cases we used the error message: 'XML error at line 1, check URL'
280 280
 
281 281
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
282
-                PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
282
+                PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']);
283 283
 
284 284
             if ($this->debug) {
285 285
                 print $xmlRpcParser->_xh['isf_reason'];
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             }
293 293
 
294 294
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
295
-                PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
295
+                PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']);
296 296
         }
297 297
         // third error check: parsing of the response has somehow gone boink.
298 298
         // NB: shall we omit this check, since we trust the parsing code?
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
304 304
                 PhpXmlRpc::$xmlrpcstr['invalid_return']);
305 305
         } else {
306
-            if ($this->debug > 1) {
306
+            if ($this->debug>1) {
307 307
                 Logger::instance()->debugMessage(
308 308
                     "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---"
309 309
                 );
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
             $server = $parts['host'];
136 136
             $path = isset($parts['path']) ? $parts['path'] : '';
137 137
             if (isset($parts['query'])) {
138
-                $path .= '?' . $parts['query'];
138
+                $path .= '?'.$parts['query'];
139 139
             }
140 140
             if (isset($parts['fragment'])) {
141
-                $path .= '#' . $parts['fragment'];
141
+                $path .= '#'.$parts['fragment'];
142 142
             }
143 143
             if (isset($parts['port'])) {
144 144
                 $port = $parts['port'];
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             }
155 155
         }
156 156
         if ($path == '' || $path[0] != '/') {
157
-            $this->path = '/' . $path;
157
+            $this->path = '/'.$path;
158 158
         } else {
159 159
             $this->path = $path;
160 160
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         }*/
193 193
 
194 194
         // initialize user_agent string
195
-        $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion;
195
+        $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion;
196 196
     }
197 197
 
198 198
     /**
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
      */
565 565
     protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '',
566 566
         $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1,
567
-        $method='http')
567
+        $method = 'http')
568 568
     {
569 569
         //trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED);
570 570
 
@@ -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)
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
      */
634 634
     protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '',
635 635
         $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0,
636
-        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '',
636
+        $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '',
637 637
         $sslVersion = 0)
638 638
     {
639 639
         if ($port == 0) {
640
-            $port = ( $method === 'https' ) ? 443 : 80;
640
+            $port = ($method === 'https') ? 443 : 80;
641 641
         }
642 642
 
643 643
         // Only create the payload if it was not created previously
@@ -667,15 +667,15 @@  discard block
 block discarded – undo
667 667
         // thanks to Grant Rauscher <[email protected]> for this
668 668
         $credentials = '';
669 669
         if ($username != '') {
670
-            $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
670
+            $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n";
671 671
             if ($authType != 1) {
672
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
672
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0');
673 673
             }
674 674
         }
675 675
 
676 676
         $acceptedEncoding = '';
677 677
         if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
678
-            $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
678
+            $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n";
679 679
         }
680 680
 
681 681
         $proxyCredentials = '';
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
             $connectServer = $proxyHost;
687 687
             $connectPort = $proxyPort;
688 688
             $transport = 'tcp';
689
-            $uri = 'http://' . $server . ':' . $port . $this->path;
689
+            $uri = 'http://'.$server.':'.$port.$this->path;
690 690
             if ($proxyUsername != '') {
691 691
                 if ($proxyAuthType != 1) {
692
-                    Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
692
+                    Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0');
693 693
                 }
694
-                $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n";
694
+                $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n";
695 695
             }
696 696
         } else {
697 697
             $connectServer = $server;
698 698
             $connectPort = $port;
699
-            $transport = ( $method === 'https' ) ? 'tls' : 'tcp';
699
+            $transport = ($method === 'https') ? 'tls' : 'tcp';
700 700
             $uri = $this->path;
701 701
         }
702 702
 
@@ -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;
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout,
783 783
             STREAM_CLIENT_CONNECT, $context);
784 784
         if ($fp) {
785
-            if ($timeout > 0) {
785
+            if ($timeout>0) {
786 786
                 stream_set_timeout($fp, $timeout);
787 787
             }
788 788
         } else {
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
                 $err = error_get_last();
791 791
                 $this->errstr = $err['message'];
792 792
             }
793
-            $this->errstr = 'Connect error: ' . $this->errstr;
794
-            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')');
793
+            $this->errstr = 'Connect error: '.$this->errstr;
794
+            $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')');
795 795
 
796 796
             return $r;
797 797
         }
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
             $encodingHdr = '';
899 899
         }
900 900
 
901
-        if ($this->debug > 1) {
901
+        if ($this->debug>1) {
902 902
             Logger::instance()->debugMessage("---SENDING---\n$payload\n---END---");
903 903
         }
904 904
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
             } else {
909 909
                 $protocol = $method;
910 910
             }
911
-            $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path);
911
+            $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path);
912 912
             if ($keepAlive) {
913 913
                 $this->xmlrpc_curl_handle = $curl;
914 914
             }
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
         // results into variable
920 920
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
921 921
 
922
-        if ($this->debug > 1) {
922
+        if ($this->debug>1) {
923 923
             curl_setopt($curl, CURLOPT_VERBOSE, true);
924 924
             /// @todo allow callers to redirect curlopt_stderr to some stream which can be buffered
925 925
         }
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
             }
945 945
         }
946 946
         // extra headers
947
-        $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
947
+        $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings));
948 948
         // if no keepalive is wanted, let the server know it in advance
949 949
         if (!$keepAlive) {
950 950
             $headers[] = 'Connection: close';
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
962 962
         // timeout is borked
963 963
         if ($timeout) {
964
-            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
964
+            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1);
965 965
         }
966 966
 
967 967
         if ($method == 'http10') {
@@ -971,11 +971,11 @@  discard block
 block discarded – undo
971 971
         }
972 972
 
973 973
         if ($username && $password) {
974
-            curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
974
+            curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
975 975
             if (defined('CURLOPT_HTTPAUTH')) {
976 976
                 curl_setopt($curl, CURLOPT_HTTPAUTH, $authType);
977 977
             } elseif ($authType != 1) {
978
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
978
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
979 979
             }
980 980
         }
981 981
 
@@ -1017,13 +1017,13 @@  discard block
 block discarded – undo
1017 1017
             if ($proxyPort == 0) {
1018 1018
                 $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080
1019 1019
             }
1020
-            curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
1020
+            curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort);
1021 1021
             if ($proxyUsername) {
1022
-                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword);
1022
+                curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword);
1023 1023
                 if (defined('CURLOPT_PROXYAUTH')) {
1024 1024
                     curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType);
1025 1025
                 } elseif ($proxyAuthType != 1) {
1026
-                    Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1026
+                    Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
1027 1027
                 }
1028 1028
             }
1029 1029
         }
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
         if (count($this->cookies)) {
1034 1034
             $cookieHeader = '';
1035 1035
             foreach ($this->cookies as $name => $cookie) {
1036
-                $cookieHeader .= $name . '=' . $cookie['value'] . '; ';
1036
+                $cookieHeader .= $name.'='.$cookie['value'].'; ';
1037 1037
             }
1038 1038
             curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2));
1039 1039
         }
@@ -1044,13 +1044,13 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
         $result = curl_exec($curl);
1046 1046
 
1047
-        if ($this->debug > 1) {
1047
+        if ($this->debug>1) {
1048 1048
             $message = "---CURL INFO---\n";
1049 1049
             foreach (curl_getinfo($curl) as $name => $val) {
1050 1050
                 if (is_array($val)) {
1051 1051
                     $val = implode("\n", $val);
1052 1052
                 }
1053
-                $message .= $name . ': ' . $val . "\n";
1053
+                $message .= $name.': '.$val."\n";
1054 1054
             }
1055 1055
             $message .= '---END---';
1056 1056
             Logger::instance()->debugMessage($message);
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
             /// @todo we should use a better check here - what if we get back '' or '0'?
1061 1061
 
1062 1062
             $this->errstr = 'no response';
1063
-            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl));
1063
+            $resp = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl));
1064 1064
             curl_close($curl);
1065 1065
             if ($keepAlive) {
1066 1066
                 $this->xmlrpc_curl_handle = null;
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
             $call['methodName'] = new Value($req->method(), 'string');
1171 1171
             $numParams = $req->getNumParams();
1172 1172
             $params = array();
1173
-            for ($i = 0; $i < $numParams; $i++) {
1173
+            for ($i = 0; $i<$numParams; $i++) {
1174 1174
                 $params[$i] = $req->getParam($i);
1175 1175
             }
1176 1176
             $call['params'] = new Value($params, 'array');
@@ -1196,15 +1196,15 @@  discard block
 block discarded – undo
1196 1196
             /// @todo test this code branch...
1197 1197
             $rets = $result->value();
1198 1198
             if (!is_array($rets)) {
1199
-                return false;       // bad return type from system.multicall
1199
+                return false; // bad return type from system.multicall
1200 1200
             }
1201 1201
             $numRets = count($rets);
1202 1202
             if ($numRets != count($reqs)) {
1203
-                return false;       // wrong number of return values.
1203
+                return false; // wrong number of return values.
1204 1204
             }
1205 1205
 
1206 1206
             $response = array();
1207
-            for ($i = 0; $i < $numRets; $i++) {
1207
+            for ($i = 0; $i<$numRets; $i++) {
1208 1208
                 $val = $rets[$i];
1209 1209
                 if (!is_array($val)) {
1210 1210
                     return false;
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
                 switch (count($val)) {
1213 1213
                     case 1:
1214 1214
                         if (!isset($val[0])) {
1215
-                            return false;       // Bad value
1215
+                            return false; // Bad value
1216 1216
                         }
1217 1217
                         // Normal return value
1218 1218
                         $response[$i] = new Response($val[0], 0, '', 'phpvals');
@@ -1240,19 +1240,19 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
             $rets = $result->value();
1242 1242
             if ($rets->kindOf() != 'array') {
1243
-                return false;       // bad return type from system.multicall
1243
+                return false; // bad return type from system.multicall
1244 1244
             }
1245 1245
             $numRets = $rets->count();
1246 1246
             if ($numRets != count($reqs)) {
1247
-                return false;       // wrong number of return values.
1247
+                return false; // wrong number of return values.
1248 1248
             }
1249 1249
 
1250 1250
             $response = array();
1251
-            foreach($rets as $val) {
1251
+            foreach ($rets as $val) {
1252 1252
                 switch ($val->kindOf()) {
1253 1253
                     case 'array':
1254 1254
                         if ($val->count() != 1) {
1255
-                            return false;       // Bad value
1255
+                            return false; // Bad value
1256 1256
                         }
1257 1257
                         // Normal return value
1258 1258
                         $response[] = new Response($val[0]);
Please login to merge, or discard this patch.
src/Encoder.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 return $xmlrpcVal->scalarval();
75 75
             case 'array':
76 76
                 $arr = array();
77
-                foreach($xmlrpcVal as $value) {
77
+                foreach ($xmlrpcVal as $value) {
78 78
                     $arr[] = $this->decode($value, $options);
79 79
                 }
80 80
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             case 'msg':
105 105
                 $paramCount = $xmlrpcVal->getNumParams();
106 106
                 $arr = array();
107
-                for ($i = 0; $i < $paramCount; $i++) {
107
+                for ($i = 0; $i<$paramCount; $i++) {
108 108
                     $arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
109 109
                 }
110 110
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                     $xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
180 180
                 } else {
181 181
                     $arr = array();
182
-                    foreach($phpVal as $k => $v) {
182
+                    foreach ($phpVal as $k => $v) {
183 183
                         $arr[$k] = $this->encode($v, $options);
184 184
                     }
185 185
                     $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 break;
202 202
             case 'resource':
203 203
                 if (in_array('extension_api', $options)) {
204
-                    $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt);
204
+                    $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt);
205 205
                 } else {
206 206
                     $xmlrpcVal = new Value();
207 207
                 }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                     if (extension_loaded('mbstring')) {
247 247
                         $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding);
248 248
                     } else {
249
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
249
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding);
250 250
                     }
251 251
                 }
252 252
             }
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         $xmlRpcParser = new XMLParser($options);
263 263
         $xmlRpcParser->parse($xmlVal, XMLParser::RETURN_XMLRPCVALS, XMLParser::ACCEPT_REQUEST | XMLParser::ACCEPT_RESPONSE | XMLParser::ACCEPT_VALUE);
264 264
 
265
-        if ($xmlRpcParser->_xh['isf'] > 1) {
265
+        if ($xmlRpcParser->_xh['isf']>1) {
266 266
             // test that $xmlrpc->_xh['value'] is an obj, too???
267 267
 
268 268
             Logger::instance()->errorLog($xmlRpcParser->_xh['isf_reason']);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                 return $r;
287 287
             case 'methodcall':
288 288
                 $req = new Request($xmlRpcParser->_xh['method']);
289
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
289
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
290 290
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
291 291
                 }
292 292
 
Please login to merge, or discard this patch.