Completed
Push — master ( 3167db...70e3fd )
by Gaetano
07:00
created
src/Helper/Logger.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -59,6 +59,7 @@
 block discarded – undo
59 59
 
60 60
     /**
61 61
      * Writes a message to the error log
62
+     * @param string $message
62 63
      */
63 64
     public function errorLog($message)
64 65
     {
Please login to merge, or discard this patch.
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/XMLParser.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
         $this->accept = $accept;
134 134
 
135 135
         // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors
136
-        for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) {
136
+        for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) {
137 137
             $chunk = substr($data, $offset, $this->maxChunkLength);
138 138
             // error handling: xml not well formed
139
-            if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) {
139
+            if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) {
140 140
                 $errCode = xml_get_error_code($parser);
141 141
                 $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode),
142 142
                     xml_get_current_line_number($parser), xml_get_current_column_number($parser));
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)
161 161
     {
162 162
         // if invalid xmlrpc already detected, skip all processing
163
-        if ($this->_xh['isf'] < 2) {
163
+        if ($this->_xh['isf']<2) {
164 164
 
165 165
             // check for correct element nesting
166 166
             if (count($this->_xh['stack']) == 0) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                     $this->_xh['rt'] = strtolower($name);
180 180
                 } else {
181 181
                     $this->_xh['isf'] = 2;
182
-                    $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name;
182
+                    $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name;
183 183
 
184 184
                     return;
185 185
                 }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                     break;
274 274
                 case 'MEMBER':
275 275
                     // set member name to null, in case we do not find in the xml later on
276
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = '';
276
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = '';
277 277
                     //$this->_xh['ac']='';
278 278
                 // Drop trough intentionally
279 279
                 case 'PARAM':
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true)
335 335
     {
336
-        if ($this->_xh['isf'] < 2) {
336
+        if ($this->_xh['isf']<2) {
337 337
             // push this element name from stack
338 338
             // NB: if XML validates, correct opening/closing is guaranteed and
339 339
             // we do not have to check for $name == $currElem.
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
                         // check if we are inside an array or struct:
360 360
                         // if value just built is inside an array, let's move it into array on the stack
361 361
                         $vscount = count($this->_xh['valuestack']);
362
-                        if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
363
-                            $this->_xh['valuestack'][$vscount - 1]['values'][] = $temp;
362
+                        if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
363
+                            $this->_xh['valuestack'][$vscount-1]['values'][] = $temp;
364 364
                         } else {
365 365
                             $this->_xh['value'] = $temp;
366 366
                         }
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
                         // check if we are inside an array or struct:
375 375
                         // if value just built is inside an array, let's move it into array on the stack
376 376
                         $vscount = count($this->_xh['valuestack']);
377
-                        if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
378
-                            $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value'];
377
+                        if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
378
+                            $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value'];
379 379
                         }
380 380
                     }
381 381
                     break;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
                         $this->_xh['value'] = $this->_xh['ac'];
396 396
                     } elseif ($name == 'DATETIME.ISO8601') {
397 397
                         if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) {
398
-                            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']);
398
+                            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']);
399 399
                         }
400 400
                         $this->_xh['vt'] = Value::$xmlrpcDateTime;
401 401
                         $this->_xh['value'] = $this->_xh['ac'];
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
                         } else {
415 415
                             // log if receiving something strange, even though we set the value to false anyway
416 416
                             if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) {
417
-                                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']);
417
+                                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']);
418 418
                             }
419 419
                             $this->_xh['value'] = false;
420 420
                         }
@@ -424,37 +424,37 @@  discard block
 block discarded – undo
424 424
                         // NOTE: regexp could be much stricter than this...
425 425
                         if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) {
426 426
                             /// @todo: find a better way of throwing an error than this!
427
-                            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']);
427
+                            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']);
428 428
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
429 429
                         } else {
430 430
                             // it's ok, add it on
431
-                            $this->_xh['value'] = (double)$this->_xh['ac'];
431
+                            $this->_xh['value'] = (double) $this->_xh['ac'];
432 432
                         }
433 433
                     } else {
434 434
                         // we have an I4/I8/INT
435 435
                         // we must check that only 0123456789-<space> are characters here
436 436
                         if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) {
437 437
                             /// @todo find a better way of throwing an error than this!
438
-                            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']);
438
+                            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']);
439 439
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
440 440
                         } else {
441 441
                             // it's ok, add it on
442
-                            $this->_xh['value'] = (int)$this->_xh['ac'];
442
+                            $this->_xh['value'] = (int) $this->_xh['ac'];
443 443
                         }
444 444
                     }
445 445
                     $this->_xh['lv'] = 3; // indicate we've found a value
446 446
                     break;
447 447
                 case 'NAME':
448
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac'];
448
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac'];
449 449
                     break;
450 450
                 case 'MEMBER':
451 451
                     // add to array in the stack the last element built,
452 452
                     // unless no VALUE was found
453 453
                     if ($this->_xh['vt']) {
454 454
                         $vscount = count($this->_xh['valuestack']);
455
-                        $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value'];
455
+                        $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value'];
456 456
                     } else {
457
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
457
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml');
458 458
                     }
459 459
                     break;
460 460
                 case 'DATA':
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                         $this->_xh['params'][] = $this->_xh['value'];
478 478
                         $this->_xh['pt'][] = $this->_xh['vt'];
479 479
                     } else {
480
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
480
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml');
481 481
                     }
482 482
                     break;
483 483
                 case 'METHODNAME':
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
     public function xmlrpc_cd($parser, $data)
524 524
     {
525 525
         // skip processing if xml fault already detected
526
-        if ($this->_xh['isf'] < 2) {
526
+        if ($this->_xh['isf']<2) {
527 527
             // "lookforvalue==3" means that we've found an entire value
528 528
             // and should discard any further character data
529 529
             if ($this->_xh['lv'] != 3) {
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     public function xmlrpc_dh($parser, $data)
542 542
     {
543 543
         // skip processing if xml fault already detected
544
-        if ($this->_xh['isf'] < 2) {
544
+        if ($this->_xh['isf']<2) {
545 545
             if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') {
546 546
                 $this->_xh['ac'] .= $data;
547 547
             }
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
         // Details:
613 613
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
614 614
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
615
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
616
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
615
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
616
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
617 617
             $xmlChunk, $matches)) {
618 618
             return strtoupper(substr($matches[2], 1, -1));
619 619
         }
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
632 632
             // IANA also likes better US-ASCII, so go with it
633 633
             if ($enc == 'ASCII') {
634
-                $enc = 'US-' . $enc;
634
+                $enc = 'US-'.$enc;
635 635
             }
636 636
 
637 637
             return $enc;
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
         // Details:
667 667
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
668 668
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
669
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
670
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
669
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
670
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
671 671
             $xmlChunk, $matches)) {
672 672
             return true;
673 673
         }
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/Server.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public static function xmlrpc_debugmsg($msg)
153 153
     {
154
-        static::$_xmlrpc_debuginfo .= $msg . "\n";
154
+        static::$_xmlrpc_debuginfo .= $msg."\n";
155 155
     }
156 156
 
157 157
     /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public static function error_occurred($msg)
161 161
     {
162
-        static::$_xmlrpcs_occurred_errors .= $msg . "\n";
162
+        static::$_xmlrpcs_occurred_errors .= $msg."\n";
163 163
     }
164 164
 
165 165
     /**
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         // user debug info should be encoded by the end user using the INTERNAL_ENCODING
179 179
         $out = '';
180 180
         if ($this->debug_info != '') {
181
-            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n";
181
+            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
182 182
         }
183 183
         if (static::$_xmlrpc_debuginfo != '') {
184
-            $out .= "<!-- DEBUG INFO:\n" . Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n";
184
+            $out .= "<!-- DEBUG INFO:\n".Charset::instance()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n";
185 185
             // NB: a better solution MIGHT be to use CDATA, but we need to insert it
186 186
             // into return payload AFTER the beginning tag
187 187
             //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n";
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
         $this->debug_info = '';
212 212
 
213 213
         // Save what we received, before parsing it
214
-        if ($this->debug > 1) {
215
-            $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
214
+        if ($this->debug>1) {
215
+            $this->debugmsg("+++GOT+++\n".$data."\n+++END+++");
216 216
         }
217 217
 
218 218
         $r = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding);
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
         // save full body of request into response, for more debugging usages
225 225
         $r->raw_data = $rawData;
226 226
 
227
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors) {
228
-            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
229
-                static::$_xmlrpcs_occurred_errors . "+++END+++");
227
+        if ($this->debug>2 && static::$_xmlrpcs_occurred_errors) {
228
+            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n".
229
+                static::$_xmlrpcs_occurred_errors."+++END+++");
230 230
         }
231 231
 
232 232
         $payload = $this->xml_header($respCharset);
233
-        if ($this->debug > 0) {
234
-            $payload = $payload . $this->serializeDebug($respCharset);
233
+        if ($this->debug>0) {
234
+            $payload = $payload.$this->serializeDebug($respCharset);
235 235
         }
236 236
 
237 237
         // Do not create response serialization if it has already happened. Helps building json magic
238 238
         if (empty($r->payload)) {
239 239
             $r->serialize($respCharset);
240 240
         }
241
-        $payload = $payload . $r->payload;
241
+        $payload = $payload.$r->payload;
242 242
 
243 243
         if ($returnPayload) {
244 244
             return $payload;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         // if we get a warning/error that has output some text before here, then we cannot
248 248
         // add a new header. We cannot say we are sending xml, either...
249 249
         if (!headers_sent()) {
250
-            header('Content-Type: ' . $r->content_type);
250
+            header('Content-Type: '.$r->content_type);
251 251
             // we do not know if client actually told us an accepted charset, but if he did
252 252
             // we have to tell him what we did
253 253
             header("Vary: Accept-Charset");
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
             // do not output content-length header if php is compressing output for us:
274 274
             // it will mess up measurements
275 275
             if ($phpNoSelfCompress) {
276
-                header('Content-Length: ' . (int)strlen($payload));
276
+                header('Content-Length: '.(int) strlen($payload));
277 277
             }
278 278
         } else {
279
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
279
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
280 280
         }
281 281
 
282 282
         print $payload;
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
             $numParams = count($in);
326 326
         }
327 327
         foreach ($sigs as $curSig) {
328
-            if (count($curSig) == $numParams + 1) {
328
+            if (count($curSig) == $numParams+1) {
329 329
                 $itsOK = 1;
330
-                for ($n = 0; $n < $numParams; $n++) {
330
+                for ($n = 0; $n<$numParams; $n++) {
331 331
                     if (is_object($in)) {
332 332
                         $p = $in->getParam($n);
333 333
                         if ($p->kindOf() == 'scalar') {
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
                     }
341 341
 
342 342
                     // param index is $n+1, as first member of sig is return type
343
-                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
343
+                    if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) {
344 344
                         $itsOK = 0;
345
-                        $pno = $n + 1;
346
-                        $wanted = $curSig[$n + 1];
345
+                        $pno = $n+1;
346
+                        $wanted = $curSig[$n+1];
347 347
                         $got = $pt;
348 348
                         break;
349 349
                     }
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
         // check if $_SERVER is populated: it might have been disabled via ini file
371 371
         // (this is true even when in CLI mode)
372 372
         if (count($_SERVER) == 0) {
373
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
373
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
374 374
         }
375 375
 
376
-        if ($this->debug > 1) {
376
+        if ($this->debug>1) {
377 377
             if (function_exists('getallheaders')) {
378 378
                 $this->debugmsg(''); // empty line
379 379
                 foreach (getallheaders() as $name => $val) {
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
                 if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) {
396 396
                     if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) {
397 397
                         $data = $degzdata;
398
-                        if ($this->debug > 1) {
399
-                            $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
398
+                        if ($this->debug>1) {
399
+                            $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
400 400
                         }
401 401
                     } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
402 402
                         $data = $degzdata;
403
-                        if ($this->debug > 1) {
404
-                            $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
403
+                        if ($this->debug>1) {
404
+                            $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
405 405
                         }
406 406
                     } else {
407 407
                         $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'], PhpXmlRpc::$xmlrpcstr['server_decompress_fail']);
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
                     if (extension_loaded('mbstring')) {
486 486
                         $data = mb_convert_encoding($data, 'UTF-8', $reqEncoding);
487 487
                     } else {
488
-                        Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding);
488
+                        Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$reqEncoding);
489 489
                     }
490 490
                 }
491 491
             }
@@ -503,16 +503,16 @@  discard block
 block discarded – undo
503 503
 
504 504
         $xmlRpcParser = new XMLParser($options);
505 505
         $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST);
506
-        if ($xmlRpcParser->_xh['isf'] > 2) {
506
+        if ($xmlRpcParser->_xh['isf']>2) {
507 507
             // (BC) we return XML error as a faultCode
508 508
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
509 509
             $r = new Response(0,
510
-                PhpXmlRpc::$xmlrpcerrxml + $matches[1],
510
+                PhpXmlRpc::$xmlrpcerrxml+$matches[1],
511 511
                 $xmlRpcParser->_xh['isf_reason']);
512 512
         } elseif ($xmlRpcParser->_xh['isf']) {
513 513
             $r = new Response(0,
514 514
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
515
-                PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
515
+                PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']);
516 516
         } else {
517 517
             // small layering violation in favor of speed and memory usage:
518 518
             // we should allow the 'execute' method handle this, but in the
@@ -523,20 +523,20 @@  discard block
 block discarded – undo
523 523
                     ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] == 'phpvals')
524 524
                 )
525 525
             ) {
526
-                if ($this->debug > 1) {
527
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++");
526
+                if ($this->debug>1) {
527
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++");
528 528
                 }
529 529
                 $r = $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']);
530 530
             } else {
531 531
                 // build a Request object with data parsed from xml
532 532
                 $req = new Request($xmlRpcParser->_xh['method']);
533 533
                 // now add parameters in
534
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
534
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
535 535
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
536 536
                 }
537 537
 
538
-                if ($this->debug > 1) {
539
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++");
538
+                if ($this->debug>1) {
539
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++");
540 540
                 }
541 541
                 $r = $this->execute($req);
542 542
             }
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
                 return new Response(
590 590
                     0,
591 591
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
592
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": ${errStr}"
592
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": ${errStr}"
593 593
                 );
594 594
             }
595 595
         }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
         if (is_array($func)) {
604 604
             if (is_object($func[0])) {
605
-                $funcName = get_class($func[0]) . '->' . $func[1];
605
+                $funcName = get_class($func[0]).'->'.$func[1];
606 606
             } else {
607 607
                 $funcName = implode('::', $func);
608 608
             }
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 
615 615
         // verify that function to be invoked is in fact callable
616 616
         if (!is_callable($func)) {
617
-            Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
617
+            Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable");
618 618
             return new Response(
619 619
                 0,
620 620
                 PhpXmlRpc::$xmlrpcerr['server_error'],
621
-                PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method"
621
+                PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method"
622 622
             );
623 623
         }
624 624
 
625 625
         // If debug level is 3, we should catch all errors generated during
626 626
         // processing of user function, and log them as part of response
627
-        if ($this->debug > 2) {
627
+        if ($this->debug>2) {
628 628
             self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
629 629
         }
630 630
 
@@ -637,14 +637,14 @@  discard block
 block discarded – undo
637 637
                     $r = call_user_func($func, $req);
638 638
                 }
639 639
                 if (!is_a($r, 'PhpXmlRpc\Response')) {
640
-                    Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
640
+                    Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r));
641 641
                     if (is_a($r, 'PhpXmlRpc\Value')) {
642 642
                         $r = new Response($r);
643 643
                     } else {
644 644
                         $r = new Response(
645 645
                             0,
646 646
                             PhpXmlRpc::$xmlrpcerr['server_error'],
647
-                            PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object"
647
+                            PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object"
648 648
                         );
649 649
                     }
650 650
                 }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
                         // mimic EPI behaviour: if we get an array that looks like an error, make it
661 661
                         // an eror response
662 662
                         if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
663
-                            $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']);
663
+                            $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']);
664 664
                         } else {
665 665
                             // functions using EPI api should NOT return resp objects,
666 666
                             // so make sure we encode the return type correctly
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
             // in the called function, we wrap it in a proper error-response
685 685
             switch ($this->exception_handling) {
686 686
                 case 2:
687
-                    if ($this->debug > 2) {
687
+                    if ($this->debug>2) {
688 688
                         if (self::$_xmlrpcs_prev_ehandler) {
689 689
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
690 690
                         } else {
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                     $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_error'], PhpXmlRpc::$xmlrpcstr['server_error']);
701 701
             }
702 702
         }
703
-        if ($this->debug > 2) {
703
+        if ($this->debug>2) {
704 704
             // note: restore the error handler we found before calling the
705 705
             // user func, even if it has been changed inside the func itself
706 706
             if (self::$_xmlrpcs_prev_ehandler) {
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      */
721 721
     protected function debugmsg($string)
722 722
     {
723
-        $this->debug_info .= $string . "\n";
723
+        $this->debug_info .= $string."\n";
724 724
     }
725 725
 
726 726
     /**
@@ -730,9 +730,9 @@  discard block
 block discarded – undo
730 730
     protected function xml_header($charsetEncoding = '')
731 731
     {
732 732
         if ($charsetEncoding != '') {
733
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
733
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n";
734 734
         } else {
735
-            return "<?xml version=\"1.0\"?" . ">\n";
735
+            return "<?xml version=\"1.0\"?".">\n";
736 736
         }
737 737
     }
738 738
 
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
         }
966 966
 
967 967
         $req = new Request($methName->scalarval());
968
-        foreach($params as $i => $param) {
968
+        foreach ($params as $i => $param) {
969 969
             if (!$req->addParam($param)) {
970 970
                 $i++; // for error message, we count params from 1
971 971
                 return static::_xmlrpcs_multicall_error(new Response(0,
972 972
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
973
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
973
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i));
974 974
             }
975 975
         }
976 976
 
@@ -1037,12 +1037,12 @@  discard block
 block discarded – undo
1037 1037
         // let accept a plain list of php parameters, beside a single xmlrpc msg object
1038 1038
         if (is_object($req)) {
1039 1039
             $calls = $req->getParam(0);
1040
-            foreach($calls as $call) {
1040
+            foreach ($calls as $call) {
1041 1041
                 $result[] = static::_xmlrpcs_multicall_do_call($server, $call);
1042 1042
             }
1043 1043
         } else {
1044 1044
             $numCalls = count($req);
1045
-            for ($i = 0; $i < $numCalls; $i++) {
1045
+            for ($i = 0; $i<$numCalls; $i++) {
1046 1046
                 $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]);
1047 1047
             }
1048 1048
         }
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/Value.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                     $this->me['struct'] = $val;
84 84
                     break;
85 85
                 default:
86
-                    Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": not a known type ($type)");
86
+                    Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": not a known type ($type)");
87 87
             }
88 88
         }
89 89
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
         if ($typeOf !== 1) {
111
-            Logger::instance()->errorLog("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)");
111
+            Logger::instance()->errorLog("XML-RPC: ".__METHOD__.": not a scalar type ($type)");
112 112
             return 0;
113 113
         }
114 114
 
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 
126 126
         switch ($this->mytype) {
127 127
             case 1:
128
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value');
128
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value');
129 129
                 return 0;
130 130
             case 3:
131
-                Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value');
131
+                Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value');
132 132
                 return 0;
133 133
             case 2:
134 134
                 // we're adding a scalar value to an array here
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
             return 1;
172 172
         } else {
173
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
173
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']');
174 174
             return 0;
175 175
         }
176 176
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
             return 1;
203 203
         } else {
204
-            Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
204
+            Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']');
205 205
             return 0;
206 206
         }
207 207
     }
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
             case 1:
241 241
                 switch ($typ) {
242 242
                     case static::$xmlrpcBase64:
243
-                        $rs .= "<${typ}>" . base64_encode($val) . "</${typ}>";
243
+                        $rs .= "<${typ}>".base64_encode($val)."</${typ}>";
244 244
                         break;
245 245
                     case static::$xmlrpcBoolean:
246
-                        $rs .= "<${typ}>" . ($val ? '1' : '0') . "</${typ}>";
246
+                        $rs .= "<${typ}>".($val ? '1' : '0')."</${typ}>";
247 247
                         break;
248 248
                     case static::$xmlrpcString:
249 249
                         // Do NOT use htmlentities, since it will produce named html entities, which are invalid xml
250
-                        $rs .= "<${typ}>" . Charset::instance()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</${typ}>";
250
+                        $rs .= "<${typ}>".Charset::instance()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</${typ}>";
251 251
                         break;
252 252
                     case static::$xmlrpcInt:
253 253
                     case static::$xmlrpcI4:
254 254
                     case static::$xmlrpcI8:
255
-                        $rs .= "<${typ}>" . (int)$val . "</${typ}>";
255
+                        $rs .= "<${typ}>".(int) $val."</${typ}>";
256 256
                         break;
257 257
                     case static::$xmlrpcDouble:
258 258
                         // avoid using standard conversion of float to string because it is locale-dependent,
@@ -260,15 +260,15 @@  discard block
 block discarded – undo
260 260
                         // sprintf('%F') could be most likely ok but it fails eg. on 2e-14.
261 261
                         // The code below tries its best at keeping max precision while avoiding exp notation,
262 262
                         // but there is of course no limit in the number of decimal places to be used...
263
-                        $rs .= "<${typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, 128, '.', '')) . "</${typ}>";
263
+                        $rs .= "<${typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, 128, '.', ''))."</${typ}>";
264 264
                         break;
265 265
                     case static::$xmlrpcDateTime:
266 266
                         if (is_string($val)) {
267 267
                             $rs .= "<${typ}>${val}</${typ}>";
268 268
                         } elseif (is_a($val, 'DateTime')) {
269
-                            $rs .= "<${typ}>" . $val->format('Ymd\TH:i:s') . "</${typ}>";
269
+                            $rs .= "<${typ}>".$val->format('Ymd\TH:i:s')."</${typ}>";
270 270
                         } elseif (is_int($val)) {
271
-                            $rs .= "<${typ}>" . strftime("%Y%m%dT%H:%M:%S", $val) . "</${typ}>";
271
+                            $rs .= "<${typ}>".strftime("%Y%m%dT%H:%M:%S", $val)."</${typ}>";
272 272
                         } else {
273 273
                             // not really a good idea here: but what shall we output anyway? left for backward compat...
274 274
                             $rs .= "<${typ}>${val}</${typ}>";
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
             case 3:
291 291
                 // struct
292 292
                 if ($this->_php_class) {
293
-                    $rs .= '<struct php_class="' . $this->_php_class . "\">\n";
293
+                    $rs .= '<struct php_class="'.$this->_php_class."\">\n";
294 294
                 } else {
295 295
                     $rs .= "<struct>\n";
296 296
                 }
297 297
                 $charsetEncoder = Charset::instance();
298 298
                 /** @var Value $val2 */
299 299
                 foreach ($val as $key2 => $val2) {
300
-                    $rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n";
300
+                    $rs .= '<member><name>'.$charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</name>\n";
301 301
                     //$rs.=$this->serializeval($val2);
302 302
                     $rs .= $val2->serialize($charsetEncoding);
303 303
                     $rs .= "</member>\n";
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         $val = reset($this->me);
334 334
         $typ = key($this->me);
335 335
 
336
-        return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n";
336
+        return '<value>'.$this->serializedata($typ, $val, $charsetEncoding)."</value>\n";
337 337
     }
338 338
 
339 339
     /**
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.