Passed
Push — master ( 424db6...327b5e )
by Gaetano
05:43
created
demo/server/_prepend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
 }
9 9
 
10 10
 // Use the custom class autoloader. These two lines are not needed when the phpxmlrpc library is installed using Composer
11
-include_once __DIR__ . '/../../src/Autoloader.php';
11
+include_once __DIR__.'/../../src/Autoloader.php';
12 12
 PhpXmlRpc\Autoloader::register();
Please login to merge, or discard this patch.
demo/client/_prepend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 }
9 9
 
10 10
 // Use the custom class autoloader. These two lines are not needed when the phpxmlrpc library is installed using Composer
11
-include_once __DIR__ . '/../../src/Autoloader.php';
11
+include_once __DIR__.'/../../src/Autoloader.php';
12 12
 PhpXmlRpc\Autoloader::register();
13 13
 
14 14
 // Let unit tests run against localhost, 'plain' demos against a known public server
Please login to merge, or discard this patch.
src/Helper/Http.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 
47 47
         // read chunk-size, chunk-extension (if any) and crlf
48 48
         // get the position of the linebreak
49
-        $chunkEnd = strpos($buffer, "\r\n") + 2;
49
+        $chunkEnd = strpos($buffer, "\r\n")+2;
50 50
         $temp = substr($buffer, 0, $chunkEnd);
51 51
         $chunkSize = hexdec(trim($temp));
52 52
         $chunkStart = $chunkEnd;
53
-        while ($chunkSize > 0) {
54
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize);
53
+        while ($chunkSize>0) {
54
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize);
55 55
 
56 56
             // just in case we got a broken connection
57 57
             if ($chunkEnd == false) {
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
             }
64 64
 
65 65
             // read chunk-data and crlf
66
-            $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
66
+            $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
67 67
             // append chunk-data to entity-body
68 68
             $new .= $chunk;
69 69
             // length := length + chunk-size
70 70
             $length += strlen($chunk);
71 71
             // read chunk-size and crlf
72
-            $chunkStart = $chunkEnd + 2;
72
+            $chunkStart = $chunkEnd+2;
73 73
 
74
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2;
74
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2;
75 75
             if ($chunkEnd == false) {
76 76
                 break; // just in case we got a broken connection
77 77
             }
78
-            $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
78
+            $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
79 79
             $chunkSize = hexdec(trim($temp));
80 80
             $chunkStart = $chunkEnd;
81 81
         }
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
             // Look for CR/LF or simple LF as line separator (even though it is not valid http)
105 105
             $pos = strpos($data, "\r\n\r\n");
106 106
             if ($pos || is_int($pos)) {
107
-                $bd = $pos + 4;
107
+                $bd = $pos+4;
108 108
             } else {
109 109
                 $pos = strpos($data, "\n\n");
110 110
                 if ($pos || is_int($pos)) {
111
-                    $bd = $pos + 2;
111
+                    $bd = $pos+2;
112 112
                 } else {
113 113
                     // No separation between response headers and body: fault?
114 114
                     $bd = 0;
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
                 // this filters out all http headers from proxy. maybe we could take them into account, too?
119 119
                 $data = substr($data, $bd);
120 120
             } else {
121
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
122
-                throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
121
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
122
+                throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
123 123
             }
124 124
         }
125 125
 
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
         if ($httpResponse['status_code'] !== '200') {
155
-            $errstr = substr($data, 0, strpos($data, "\n") - 1);
156
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
157
-            throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
155
+            $errstr = substr($data, 0, strpos($data, "\n")-1);
156
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr);
157
+            throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
158 158
         }
159 159
 
160 160
         // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http)
161 161
         $pos = strpos($data, "\r\n\r\n");
162 162
         if ($pos || is_int($pos)) {
163
-            $bd = $pos + 4;
163
+            $bd = $pos+4;
164 164
         } else {
165 165
             $pos = strpos($data, "\n\n");
166 166
             if ($pos || is_int($pos)) {
167
-                $bd = $pos + 2;
167
+                $bd = $pos+2;
168 168
             } else {
169 169
                 // No separation between response headers and body: fault?
170 170
                 // we could take some action here instead of going on...
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         foreach ($ar as $line) {
179 179
             // take care of multi-line headers and cookies
180 180
             $arr = explode(':', $line, 2);
181
-            if (count($arr) > 1) {
181
+            if (count($arr)>1) {
182 182
                 $headerName = strtolower(trim($arr[0]));
183 183
                 /// @todo some other headers (the ones that allow a CSV list of values) do allow many values to be
184 184
                 ///       passed using multiple header lines.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                     foreach ($cookies as $cookie) {
196 196
                         // glue together all received cookies, using a comma to separate them (same as php does with getallheaders())
197 197
                         if (isset($httpResponse['headers'][$headerName])) {
198
-                            $httpResponse['headers'][$headerName] .= ', ' . trim($cookie);
198
+                            $httpResponse['headers'][$headerName] .= ', '.trim($cookie);
199 199
                         } else {
200 200
                             $httpResponse['headers'][$headerName] = trim($cookie);
201 201
                         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                 }
225 225
             } elseif (isset($headerName)) {
226 226
                 /// @todo version1 cookies might span multiple lines, thus breaking the parsing above
227
-                $httpResponse['headers'][$headerName] .= ' ' . trim($line);
227
+                $httpResponse['headers'][$headerName] .= ' '.trim($line);
228 228
             }
229 229
         }
230 230
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             // Decode chunked encoding sent by http 1.1 servers
248 248
             if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') {
249 249
                 if (!$data = static::decodeChunked($data)) {
250
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
250
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server');
251 251
                     throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']);
252 252
                 }
253 253
             }
@@ -262,19 +262,19 @@  discard block
 block discarded – undo
262 262
                         if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
263 263
                             $data = $degzdata;
264 264
                             if ($debug) {
265
-                                $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
265
+                                $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
266 266
                             }
267 267
                         } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
268 268
                             $data = $degzdata;
269 269
                             if ($debug) {
270
-                                $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
270
+                                $this->getLogger()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
271 271
                             }
272 272
                         } else {
273
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
273
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
274 274
                             throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']);
275 275
                         }
276 276
                     } else {
277
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
277
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
278 278
                         throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']);
279 279
                     }
280 280
                 }
Please login to merge, or discard this patch.
src/Helper/XMLParser.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
         $this->accept = $accept;
176 176
 
177 177
         // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors
178
-        for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) {
178
+        for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) {
179 179
             $chunk = substr($data, $offset, $this->maxChunkLength);
180 180
             // error handling: xml not well formed
181
-            if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) {
181
+            if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) {
182 182
                 $errCode = xml_get_error_code($parser);
183 183
                 $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode),
184 184
                     xml_get_current_line_number($parser), xml_get_current_column_number($parser));
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)
206 206
     {
207 207
         // if invalid xmlrpc already detected, skip all processing
208
-        if ($this->_xh['isf'] < 2) {
208
+        if ($this->_xh['isf']<2) {
209 209
 
210 210
             // check for correct element nesting
211 211
             if (count($this->_xh['stack']) == 0) {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
                     $this->_xh['rt'] = strtolower($name);
226 226
                 } else {
227 227
                     $this->_xh['isf'] = 2;
228
-                    $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name;
228
+                    $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name;
229 229
 
230 230
                     return;
231 231
                 }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                     break;
320 320
                 case 'MEMBER':
321 321
                     // set member name to null, in case we do not find in the xml later on
322
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = '';
322
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = '';
323 323
                     //$this->_xh['ac']='';
324 324
                 // Drop trough intentionally
325 325
                 case 'PARAM':
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1)
385 385
     {
386
-        if ($this->_xh['isf'] < 2) {
386
+        if ($this->_xh['isf']<2) {
387 387
             // push this element name from stack
388 388
             // NB: if XML validates, correct opening/closing is guaranteed and
389 389
             // we do not have to check for $name == $currElem.
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
                         $this->_xh['vt'] = Value::$xmlrpcString;
399 399
                     }
400 400
 
401
-                    if ($rebuildXmlrpcvals > 0) {
401
+                    if ($rebuildXmlrpcvals>0) {
402 402
                         // build the xmlrpc val out of the data received, and substitute it
403 403
                         $temp = new Value($this->_xh['value'], $this->_xh['vt']);
404 404
                         // in case we got info about underlying php class, save it
@@ -407,15 +407,15 @@  discard block
 block discarded – undo
407 407
                             $temp->_php_class = $this->_xh['php_class'];
408 408
                         }
409 409
                         $this->_xh['value'] = $temp;
410
-                    } elseif ($rebuildXmlrpcvals < 0) {
410
+                    } elseif ($rebuildXmlrpcvals<0) {
411 411
                         if ($this->_xh['vt'] == Value::$xmlrpcDateTime) {
412
-                            $this->_xh['value'] = (object)array(
412
+                            $this->_xh['value'] = (object) array(
413 413
                                 'xmlrpc_type' => 'datetime',
414 414
                                 'scalar' => $this->_xh['value'],
415 415
                                 'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value'])
416 416
                             );
417 417
                         } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) {
418
-                            $this->_xh['value'] = (object)array(
418
+                            $this->_xh['value'] = (object) array(
419 419
                                 'xmlrpc_type' => 'base64',
420 420
                                 'scalar' => $this->_xh['value']
421 421
                             );
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
                     // check if we are inside an array or struct:
432 432
                     // if value just built is inside an array, let's move it into array on the stack
433 433
                     $vscount = count($this->_xh['valuestack']);
434
-                    if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
435
-                        $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value'];
434
+                    if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
435
+                        $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value'];
436 436
                     }
437 437
                     break;
438 438
                 case 'BOOLEAN':
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
                         $this->_xh['value'] = $this->_xh['ac'];
452 452
                     } elseif ($name == 'DATETIME.ISO8601') {
453 453
                         if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) {
454
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']);
454
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']);
455 455
                         }
456 456
                         $this->_xh['vt'] = Value::$xmlrpcDateTime;
457 457
                         $this->_xh['value'] = $this->_xh['ac'];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         } else {
471 471
                             // log if receiving something strange, even though we set the value to false anyway
472 472
                             if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) {
473
-                                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']);
473
+                                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']);
474 474
                             }
475 475
                             $this->_xh['value'] = false;
476 476
                         }
@@ -480,37 +480,37 @@  discard block
 block discarded – undo
480 480
                         // NOTE: regexp could be much stricter than this...
481 481
                         if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) {
482 482
                             /// @todo: find a better way of throwing an error than this!
483
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']);
483
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']);
484 484
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
485 485
                         } else {
486 486
                             // it's ok, add it on
487
-                            $this->_xh['value'] = (double)$this->_xh['ac'];
487
+                            $this->_xh['value'] = (double) $this->_xh['ac'];
488 488
                         }
489 489
                     } else {
490 490
                         // we have an I4/I8/INT
491 491
                         // we must check that only 0123456789-<space> are characters here
492 492
                         if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) {
493 493
                             /// @todo find a better way of throwing an error than this!
494
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']);
494
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']);
495 495
                             $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
496 496
                         } else {
497 497
                             // it's ok, add it on
498
-                            $this->_xh['value'] = (int)$this->_xh['ac'];
498
+                            $this->_xh['value'] = (int) $this->_xh['ac'];
499 499
                         }
500 500
                     }
501 501
                     $this->_xh['lv'] = 3; // indicate we've found a value
502 502
                     break;
503 503
                 case 'NAME':
504
-                    $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac'];
504
+                    $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac'];
505 505
                     break;
506 506
                 case 'MEMBER':
507 507
                     // add to array in the stack the last element built,
508 508
                     // unless no VALUE was found
509 509
                     if ($this->_xh['vt']) {
510 510
                         $vscount = count($this->_xh['valuestack']);
511
-                        $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value'];
511
+                        $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value'];
512 512
                     } else {
513
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
513
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml');
514 514
                     }
515 515
                     break;
516 516
                 case 'DATA':
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                         $this->_xh['params'][] = $this->_xh['value'];
534 534
                         $this->_xh['pt'][] = $this->_xh['vt'];
535 535
                     } else {
536
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
536
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml');
537 537
                     }
538 538
                     break;
539 539
                 case 'METHODNAME':
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     public function xmlrpc_cd($parser, $data)
599 599
     {
600 600
         // skip processing if xml fault already detected
601
-        if ($this->_xh['isf'] < 2) {
601
+        if ($this->_xh['isf']<2) {
602 602
             // "lookforvalue==3" means that we've found an entire value
603 603
             // and should discard any further character data
604 604
             if ($this->_xh['lv'] != 3) {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     public function xmlrpc_dh($parser, $data)
620 620
     {
621 621
         // skip processing if xml fault already detected
622
-        if ($this->_xh['isf'] < 2) {
622
+        if ($this->_xh['isf']<2) {
623 623
             if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') {
624 624
                 $this->_xh['ac'] .= $data;
625 625
             }
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
         // Details:
694 694
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
695 695
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
696
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
697
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
696
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
697
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
698 698
             $xmlChunk, $matches)) {
699 699
             return strtoupper(substr($matches[2], 1, -1));
700 700
         }
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
             // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
713 713
             // IANA also likes better US-ASCII, so go with it
714 714
             if ($enc == 'ASCII') {
715
-                $enc = 'US-' . $enc;
715
+                $enc = 'US-'.$enc;
716 716
             }
717 717
 
718 718
             return $enc;
@@ -747,8 +747,8 @@  discard block
 block discarded – undo
747 747
         // Details:
748 748
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
749 749
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
750
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
751
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
750
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
751
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
752 752
             $xmlChunk, $matches)) {
753 753
             return true;
754 754
         }
Please login to merge, or discard this patch.
demo/server/methodProviders/validator1.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
             array(Value::$xmlrpcInt, Value::$xmlrpcArray)
18 18
         ),
19 19
         "docstring" => 'This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.',
20
-        "function" => function ($req)
20
+        "function" => function($req)
21 21
         {
22 22
             $sno = $req->getParam(0);
23 23
             $numCurly = 0;
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
             array(Value::$xmlrpcInt, Value::$xmlrpcStruct)
39 39
         ),
40 40
         "docstring" => 'This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.',
41
-        "function" => function ($req)
41
+        "function" => function($req)
42 42
         {
43 43
             $sno = $req->getParam(0);
44 44
             $moe = $sno["moe"];
45 45
             $larry = $sno["larry"];
46 46
             $curly = $sno["curly"];
47
-            $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval();
47
+            $num = $moe->scalarval()+$larry->scalarval()+$curly->scalarval();
48 48
 
49 49
             return new Response(new Value($num, Value::$xmlrpcInt));
50 50
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             array(Value::$xmlrpcStruct, Value::$xmlrpcStruct)
56 56
         ),
57 57
         "docstring" => 'This handler takes a single parameter, a struct. Your handler must return the struct.',
58
-        "function" => function ($req)
58
+        "function" => function($req)
59 59
         {
60 60
             $sno = $req->getParam(0);
61 61
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             )
72 72
         ),
73 73
         "docstring" => 'This handler takes six parameters, and returns an array containing all the parameters.',
74
-        "function" => function ($req)
74
+        "function" => function($req)
75 75
         {
76 76
             return new Response(new Value(
77 77
                 array(
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
             array(Value::$xmlrpcString, Value::$xmlrpcArray)
93 93
         ),
94 94
         "docstring" => 'This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.',
95
-        "function" => function ($req)
95
+        "function" => function($req)
96 96
         {
97 97
             $ar = $req->getParam(0);
98 98
             $sz = $ar->count();
99 99
             $first = $ar[0];
100
-            $last = $ar[$sz - 1];
100
+            $last = $ar[$sz-1];
101 101
 
102
-            return new Response(new Value($first->scalarval() . $last->scalarval(), Value::$xmlrpcString));
102
+            return new Response(new Value($first->scalarval().$last->scalarval(), Value::$xmlrpcString));
103 103
         }
104 104
     ),
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             array(Value::$xmlrpcStruct, Value::$xmlrpcInt)
109 109
         ),
110 110
         "docstring" => 'This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.',
111
-        "function" => function ($req)
111
+        "function" => function($req)
112 112
         {
113 113
             $sno = $req->getParam(0);
114 114
             $v = $sno->scalarval();
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             array(Value::$xmlrpcInt, Value::$xmlrpcStruct)
130 130
         ),
131 131
         "docstring" => 'This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.',
132
-        "function" => function ($req)
132
+        "function" => function($req)
133 133
         {
134 134
             $sno = $req->getParam(0);
135 135
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $larry = $fools["larry"];
141 141
             $moe = $fools["moe"];
142 142
 
143
-            return new Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), Value::$xmlrpcInt));
143
+            return new Response(new Value($curly->scalarval()+$larry->scalarval()+$moe->scalarval(), Value::$xmlrpcInt));
144 144
         }
145 145
     ),
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             array(Value::$xmlrpcStruct, Value::$xmlrpcString)
150 150
         ),
151 151
         "docstring" => 'This handler takes a single parameter, a string, that contains any number of predefined entities, namely &lt;, &gt;, &amp; \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.',
152
-        "function" => function ($req)
152
+        "function" => function($req)
153 153
         {
154 154
             $sno = $req->getParam(0);
155 155
             $str = $sno->scalarval();
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $ap = 0;
159 159
             $qu = 0;
160 160
             $amp = 0;
161
-            for ($i = 0; $i < strlen($str); $i++) {
161
+            for ($i = 0; $i<strlen($str); $i++) {
162 162
                 $c = substr($str, $i, 1);
163 163
                 switch ($c) {
164 164
                     case ">":
Please login to merge, or discard this patch.