Completed
Push — master ( b37706...ce870f )
by Gaetano
04:10
created
demo/vardemo.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  discard block
 block discarded – undo
3 3
 <body>
4 4
 <?php
5 5
 
6
-include_once __DIR__ . "/../vendor/autoload.php";
6
+include_once __DIR__."/../vendor/autoload.php";
7 7
 
8 8
 $req = new PhpXmlRpc\Request('examples.getStateName');
9 9
 
10 10
 print "<h3>Testing value serialization</h3>\n";
11 11
 
12 12
 $v = new PhpXmlRpc\Value(23, "int");
13
-print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
13
+print "<PRE>".htmlentities($v->serialize())."</PRE>";
14 14
 $v = new PhpXmlRpc\Value("What are you saying? >> << &&");
15
-print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
15
+print "<PRE>".htmlentities($v->serialize())."</PRE>";
16 16
 
17 17
 $v = new PhpXmlRpc\Value(
18 18
     array(
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     "array"
24 24
 );
25 25
 
26
-print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
26
+print "<PRE>".htmlentities($v->serialize())."</PRE>";
27 27
 
28 28
 $v = new PhpXmlRpc\Value(
29 29
     array(
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
     "struct"
52 52
 );
53 53
 
54
-print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
54
+print "<PRE>".htmlentities($v->serialize())."</PRE>";
55 55
 
56 56
 $w = new PhpXmlRpc\Value(array($v, new PhpXmlRpc\Value("That was the struct!")), "array");
57 57
 
58
-print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
58
+print "<PRE>".htmlentities($w->serialize())."</PRE>";
59 59
 
60 60
 $w = new PhpXmlRpc\Value("Mary had a little lamb,
61 61
 Whose fleece was white as snow,
@@ -67,26 +67,26 @@  discard block
 block discarded – undo
67 67
 Ten thousand volts went down its back
68 68
 And turned it into nylon", "base64"
69 69
 );
70
-print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
71
-print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
70
+print "<PRE>".htmlentities($w->serialize())."</PRE>";
71
+print "<PRE>Value of base64 string is: '".$w->scalarval()."'</PRE>";
72 72
 
73 73
 $req->method('');
74 74
 $req->addParam(new PhpXmlRpc\Value("41", "int"));
75 75
 
76 76
 print "<h3>Testing request serialization</h3>\n";
77 77
 $op = $req->serialize();
78
-print "<PRE>" . htmlentities($op) . "</PRE>";
78
+print "<PRE>".htmlentities($op)."</PRE>";
79 79
 
80 80
 print "<h3>Testing ISO date format</h3><pre>\n";
81 81
 
82 82
 $t = time();
83 83
 $date = PhpXmlRpc\Helper\Date::iso8601Encode($t);
84 84
 print "Now is $t --> $date\n";
85
-print "Or in UTC, that is " . PhpXmlRpc\Helper\Date::iso8601Encode($t, 1) . "\n";
85
+print "Or in UTC, that is ".PhpXmlRpc\Helper\Date::iso8601Encode($t, 1)."\n";
86 86
 $tb = PhpXmlRpc\Helper\Date::iso8601Decode($date);
87 87
 print "That is to say $date --> $tb\n";
88
-print "Which comes out at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb) . "\n";
89
-print "Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($date, 1) . "\n";
88
+print "Which comes out at ".PhpXmlRpc\Helper\Date::iso8601Encode($tb)."\n";
89
+print "Which was the time in UTC at ".PhpXmlRpc\Helper\Date::iso8601Encode($date, 1)."\n";
90 90
 
91 91
 print "</pre>\n";
92 92
 
Please login to merge, or discard this patch.
src/Helper/XMLParser.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)
67 67
     {
68 68
         // if invalid xmlrpc already detected, skip all processing
69
-        if ($this->_xh['isf'] < 2) {
69
+        if ($this->_xh['isf']<2) {
70 70
             // check for correct element nesting
71 71
             // top level element can only be of 2 types
72 72
             /// @todo optimization creep: save this check into a bool variable, instead of using count() every time:
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                     $this->_xh['isf'] = 1;
172 172
                     break;
173 173
                 case 'MEMBER':
174
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = ''; // set member name to null, in case we do not find in the xml later on
174
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = ''; // set member name to null, in case we do not find in the xml later on
175 175
                     //$this->_xh['ac']='';
176 176
                 // Drop trough intentionally
177 177
                 case 'PARAM':
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true)
225 225
     {
226
-        if ($this->_xh['isf'] < 2) {
226
+        if ($this->_xh['isf']<2) {
227 227
             // push this element name from stack
228 228
             // NB: if XML validates, correct opening/closing is guaranteed and
229 229
             // we do not have to check for $name == $currElem.
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
                         // check if we are inside an array or struct:
250 250
                         // if value just built is inside an array, let's move it into array on the stack
251 251
                         $vscount = count($this->_xh['valuestack']);
252
-                        if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
253
-                            $this->_xh['valuestack'][$vscount - 1]['values'][] = $temp;
252
+                        if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
253
+                            $this->_xh['valuestack'][$vscount-1]['values'][] = $temp;
254 254
                         } else {
255 255
                             $this->_xh['value'] = $temp;
256 256
                         }
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
                         // check if we are inside an array or struct:
265 265
                         // if value just built is inside an array, let's move it into array on the stack
266 266
                         $vscount = count($this->_xh['valuestack']);
267
-                        if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
268
-                            $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value'];
267
+                        if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
268
+                            $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value'];
269 269
                         }
270 270
                     }
271 271
                     break;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                         $this->_xh['value'] = $this->_xh['ac'];
286 286
                     } elseif ($name == 'DATETIME.ISO8601') {
287 287
                         if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) {
288
-                            error_log('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']);
288
+                            error_log('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']);
289 289
                         }
290 290
                         $this->_xh['vt'] = Value::$xmlrpcDateTime;
291 291
                         $this->_xh['value'] = $this->_xh['ac'];
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                         } else {
305 305
                             // log if receiving something strange, even though we set the value to false anyway
306 306
                             if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) {
307
-                                error_log('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']);
307
+                                error_log('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']);
308 308
                             }
309 309
                             $this->_xh['value'] = false;
310 310
                         }
@@ -314,37 +314,37 @@  discard block
 block discarded – undo
314 314
                         // NOTE: regexp could be much stricter than this...
315 315
                         if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) {
316 316
                             /// @todo: find a better way of throwing an error than this!
317
-                            error_log('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']);
317
+                            error_log('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']);
318 318
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
319 319
                         } else {
320 320
                             // it's ok, add it on
321
-                            $this->_xh['value'] = (double)$this->_xh['ac'];
321
+                            $this->_xh['value'] = (double) $this->_xh['ac'];
322 322
                         }
323 323
                     } else {
324 324
                         // we have an I4/I8/INT
325 325
                         // we must check that only 0123456789-<space> are characters here
326 326
                         if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) {
327 327
                             /// @todo find a better way of throwing an error than this!
328
-                            error_log('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']);
328
+                            error_log('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']);
329 329
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
330 330
                         } else {
331 331
                             // it's ok, add it on
332
-                            $this->_xh['value'] = (int)$this->_xh['ac'];
332
+                            $this->_xh['value'] = (int) $this->_xh['ac'];
333 333
                         }
334 334
                     }
335 335
                     $this->_xh['lv'] = 3; // indicate we've found a value
336 336
                     break;
337 337
                 case 'NAME':
338
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac'];
338
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac'];
339 339
                     break;
340 340
                 case 'MEMBER':
341 341
                     // add to array in the stack the last element built,
342 342
                     // unless no VALUE was found
343 343
                     if ($this->_xh['vt']) {
344 344
                         $vscount = count($this->_xh['valuestack']);
345
-                        $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value'];
345
+                        $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value'];
346 346
                     } else {
347
-                        error_log('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
347
+                        error_log('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml');
348 348
                     }
349 349
                     break;
350 350
                 case 'DATA':
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
                         $this->_xh['params'][] = $this->_xh['value'];
368 368
                         $this->_xh['pt'][] = $this->_xh['vt'];
369 369
                     } else {
370
-                        error_log('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
370
+                        error_log('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml');
371 371
                     }
372 372
                     break;
373 373
                 case 'METHODNAME':
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     public function xmlrpc_cd($parser, $data)
410 410
     {
411 411
         // skip processing if xml fault already detected
412
-        if ($this->_xh['isf'] < 2) {
412
+        if ($this->_xh['isf']<2) {
413 413
             // "lookforvalue==3" means that we've found an entire value
414 414
             // and should discard any further character data
415 415
             if ($this->_xh['lv'] != 3) {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
     public function xmlrpc_dh($parser, $data)
426 426
     {
427 427
         // skip processing if xml fault already detected
428
-        if ($this->_xh['isf'] < 2) {
428
+        if ($this->_xh['isf']<2) {
429 429
             if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') {
430 430
                 $this->_xh['ac'] .= $data;
431 431
             }
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
         // Details:
497 497
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
498 498
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
499
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
500
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
499
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
500
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
501 501
             $xmlChunk, $matches)) {
502 502
             return strtoupper(substr($matches[2], 1, -1));
503 503
         }
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
             // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
516 516
             // IANA also likes better US-ASCII, so go with it
517 517
             if ($enc == 'ASCII') {
518
-                $enc = 'US-' . $enc;
518
+                $enc = 'US-'.$enc;
519 519
             }
520 520
 
521 521
             return $enc;
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
         // Details:
551 551
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
552 552
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
553
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
554
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
553
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
554
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
555 555
             $xmlChunk, $matches)) {
556 556
             return true;
557 557
         }
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
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                 return $xmlrpcVal->scalarval();
76 76
             case 'array':
77 77
                 $arr = array();
78
-                foreach($xmlrpcVal as $value) {
78
+                foreach ($xmlrpcVal as $value) {
79 79
                     $arr[] = $this->decode($value, $options);
80 80
                 }
81 81
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             case 'msg':
106 106
                 $paramCount = $xmlrpcVal->getNumParams();
107 107
                 $arr = array();
108
-                for ($i = 0; $i < $paramCount; $i++) {
108
+                for ($i = 0; $i<$paramCount; $i++) {
109 109
                     $arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
110 110
                 }
111 111
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                     $xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
184 184
                 } else {
185 185
                     $arr = array();
186
-                    foreach($phpVal as $k => $v) {
186
+                    foreach ($phpVal as $k => $v) {
187 187
                         $arr[$k] = $this->encode($v, $options);
188 188
                     }
189 189
                     $xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
                 break;
206 206
             case 'resource':
207 207
                 if (in_array('extension_api', $options)) {
208
-                    $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt);
208
+                    $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt);
209 209
                 } else {
210 210
                     $xmlrpcVal = new Value();
211 211
                 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                     if (extension_loaded('mbstring')) {
249 249
                         $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding);
250 250
                     } else {
251
-                        error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
251
+                        error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding);
252 252
                     }
253 253
                 }
254 254
             }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             return false;
281 281
         }
282 282
         xml_parser_free($parser);
283
-        if ($xmlRpcParser->_xh['isf'] > 1) {
283
+        if ($xmlRpcParser->_xh['isf']>1) {
284 284
             // test that $xmlrpc->_xh['value'] is an obj, too???
285 285
 
286 286
             error_log($xmlRpcParser->_xh['isf_reason']);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                 return $r;
302 302
             case 'methodcall':
303 303
                 $req = new Request($xmlRpcParser->_xh['method']);
304
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
304
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
305 305
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
306 306
                 }
307 307
 
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
-                error_log('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
+                error_log('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
-            error_log('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
+            error_log('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
-                    error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
221
+                    error_log('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
-                            error_log('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
244
+                            error_log('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
-                        error_log('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
248
+                        error_log('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.
tests/4LocalhostMultiTest.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/../lib/xmlrpc.inc';
4
-include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
3
+include_once __DIR__.'/../lib/xmlrpc.inc';
4
+include_once __DIR__.'/../lib/xmlrpc_wrappers.inc';
5 5
 
6
-include_once __DIR__ . '/parse_args.php';
6
+include_once __DIR__.'/parse_args.php';
7 7
 
8
-include_once __DIR__ . '/3LocalhostTest.php';
8
+include_once __DIR__.'/3LocalhostTest.php';
9 9
 
10 10
 /**
11 11
  * Tests which stress http features of the library.
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
         );
29 29
 
30 30
         $methods = array();
31
-        foreach(get_class_methods('LocalhostTest') as $method)
31
+        foreach (get_class_methods('LocalhostTest') as $method)
32 32
         {
33
-            if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
33
+            if (strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
34 34
             {
35 35
                 if (!isset(self::$failed_tests[$method])) {
36 36
                     $methods[$method] = array($method);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function testDeflate($method)
49 49
     {
50
-        if(!function_exists('gzdeflate'))
50
+        if (!function_exists('gzdeflate'))
51 51
         {
52 52
             $this->markTestSkipped('Zlib missing: cannot test deflate functionality');
53 53
             return;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function testGzip($method)
67 67
     {
68
-        if(!function_exists('gzdeflate'))
68
+        if (!function_exists('gzdeflate'))
69 69
         {
70 70
             $this->markTestSkipped('Zlib missing: cannot test gzip functionality');
71 71
             return;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
     public function testKeepAlives()
81 81
     {
82
-        if(!function_exists('curl_init'))
82
+        if (!function_exists('curl_init'))
83 83
         {
84 84
             $this->markTestSkipped('CURL missing: cannot test http 1.1');
85 85
             return;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function testHttp11($method)
121 121
     {
122
-        if(!function_exists('curl_init'))
122
+        if (!function_exists('curl_init'))
123 123
         {
124 124
             $this->markTestSkipped('CURL missing: cannot test http 1.1');
125 125
             return;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function testHttp11Gzip($method)
140 140
     {
141
-        if(!function_exists('curl_init'))
141
+        if (!function_exists('curl_init'))
142 142
         {
143 143
             $this->markTestSkipped('CURL missing: cannot test http 1.1');
144 144
             return;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function testHttp11Deflate($method)
160 160
     {
161
-        if(!function_exists('curl_init'))
161
+        if (!function_exists('curl_init'))
162 162
         {
163 163
             $this->markTestSkipped('CURL missing: cannot test http 1.1');
164 164
             return;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function testHttp11Proxy($method)
180 180
     {
181
-        if(!function_exists('curl_init'))
181
+        if (!function_exists('curl_init'))
182 182
         {
183 183
             $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
184 184
             return;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function testHttps($method)
205 205
     {
206
-        if(!function_exists('curl_init'))
206
+        if (!function_exists('curl_init'))
207 207
         {
208 208
             $this->markTestSkipped('CURL missing: cannot test https functionality');
209 209
             return;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function testHttpsProxy($method)
233 233
     {
234
-        if(!function_exists('curl_init'))
234
+        if (!function_exists('curl_init'))
235 235
         {
236 236
             $this->markTestSkipped('CURL missing: cannot test https w. proxy');
237 237
             return;
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
         {
183 183
             $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
184 184
             return;
185
-        }
186
-        else if ($this->args['PROXYSERVER'] == '')
185
+        } else if ($this->args['PROXYSERVER'] == '')
187 186
         {
188 187
             $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
189 188
             return;
@@ -207,8 +206,7 @@  discard block
 block discarded – undo
207 206
         {
208 207
             $this->markTestSkipped('CURL missing: cannot test https functionality');
209 208
             return;
210
-        }
211
-        else if ($this->args['HTTPSSERVER'] == '')
209
+        } else if ($this->args['HTTPSSERVER'] == '')
212 210
         {
213 211
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
214 212
             return;
@@ -235,13 +233,11 @@  discard block
 block discarded – undo
235 233
         {
236 234
             $this->markTestSkipped('CURL missing: cannot test https w. proxy');
237 235
             return;
238
-        }
239
-        else if ($this->args['PROXYSERVER'] == '')
236
+        } else if ($this->args['PROXYSERVER'] == '')
240 237
         {
241 238
             $this->markTestSkipped('PROXY definition missing: cannot test proxy w. https');
242 239
             return;
243
-        }
244
-        else if ($this->args['HTTPSSERVER'] == '')
240
+        } else if ($this->args['HTTPSSERVER'] == '')
245 241
         {
246 242
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
247 243
             return;
Please login to merge, or discard this patch.