Passed
Push — master ( 8b94c5...6f0f8c )
by Gaetano
15:08 queued 05:13
created
src/Server.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public static function xmlrpc_debugmsg($msg)
196 196
     {
197
-        static::$_xmlrpc_debuginfo .= $msg . "\n";
197
+        static::$_xmlrpc_debuginfo .= $msg."\n";
198 198
     }
199 199
 
200 200
     /**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public static function error_occurred($msg)
208 208
     {
209
-        static::$_xmlrpcs_occurred_errors .= $msg . "\n";
209
+        static::$_xmlrpcs_occurred_errors .= $msg."\n";
210 210
     }
211 211
 
212 212
     /**
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
         // user debug info should be encoded by the end user using the INTERNAL_ENCODING
228 228
         $out = '';
229 229
         if ($this->debug_info != '') {
230
-            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n";
230
+            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
231 231
         }
232 232
         if (static::$_xmlrpc_debuginfo != '') {
233
-            $out .= "<!-- DEBUG INFO:\n" . $this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n";
233
+            $out .= "<!-- DEBUG INFO:\n".$this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n";
234 234
             // NB: a better solution MIGHT be to use CDATA, but we need to insert it
235 235
             // into return payload AFTER the beginning tag
236 236
             //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n";
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
         $this->debug_info = '';
260 260
 
261 261
         // Save what we received, before parsing it
262
-        if ($this->debug > 1) {
263
-            $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
262
+        if ($this->debug>1) {
263
+            $this->debugmsg("+++GOT+++\n".$data."\n+++END+++");
264 264
         }
265 265
 
266 266
         $resp = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding);
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
             $resp->raw_data = $rawData;
278 278
         }
279 279
 
280
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') {
281
-            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
282
-                static::$_xmlrpcs_occurred_errors . "+++END+++");
280
+        if ($this->debug>2 && static::$_xmlrpcs_occurred_errors != '') {
281
+            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n".
282
+                static::$_xmlrpcs_occurred_errors."+++END+++");
283 283
         }
284 284
 
285 285
         $payload = $this->xml_header($respCharset);
286
-        if ($this->debug > 0) {
287
-            $payload = $payload . $this->serializeDebug($respCharset);
286
+        if ($this->debug>0) {
287
+            $payload = $payload.$this->serializeDebug($respCharset);
288 288
         }
289 289
 
290 290
         // Do not create response serialization if it has already happened. Helps to build json magic
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         if (empty($resp->payload)) {
293 293
             $resp->serialize($respCharset);
294 294
         }
295
-        $payload = $payload . $resp->payload;
295
+        $payload = $payload.$resp->payload;
296 296
 
297 297
         if ($returnPayload) {
298 298
             return $payload;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         // if we get a warning/error that has output some text before here, then we cannot
302 302
         // add a new header. We cannot say we are sending xml, either...
303 303
         if (!headers_sent()) {
304
-            header('Content-Type: ' . $resp->content_type);
304
+            header('Content-Type: '.$resp->content_type);
305 305
             // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did
306 306
             header("Vary: Accept-Charset");
307 307
 
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
             // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for
325 325
             // responses up to 8000 bytes
326 326
             if ($phpNoSelfCompress) {
327
-                header('Content-Length: ' . (int)strlen($payload));
327
+                header('Content-Length: '.(int) strlen($payload));
328 328
             }
329 329
         } else {
330
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
330
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
331 331
         }
332 332
 
333 333
         print $payload;
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
             $numParams = count($in);
391 391
         }
392 392
         foreach ($sigs as $curSig) {
393
-            if (count($curSig) == $numParams + 1) {
393
+            if (count($curSig) == $numParams+1) {
394 394
                 $itsOK = 1;
395
-                for ($n = 0; $n < $numParams; $n++) {
395
+                for ($n = 0; $n<$numParams; $n++) {
396 396
                     if (is_object($in)) {
397 397
                         $p = $in->getParam($n);
398 398
                         if ($p->kindOf() == 'scalar') {
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
                     }
406 406
 
407 407
                     // param index is $n+1, as first member of sig is return type
408
-                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
408
+                    if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) {
409 409
                         $itsOK = 0;
410
-                        $pno = $n + 1;
411
-                        $wanted = $curSig[$n + 1];
410
+                        $pno = $n+1;
411
+                        $wanted = $curSig[$n+1];
412 412
                         $got = $pt;
413 413
                         break;
414 414
                     }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
         // check if $_SERVER is populated: it might have been disabled via ini file
436 436
         // (this is true even when in CLI mode)
437 437
         if (count($_SERVER) == 0) {
438
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
438
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
439 439
         }
440 440
 
441
-        if ($this->debug > 1) {
441
+        if ($this->debug>1) {
442 442
             if (function_exists('getallheaders')) {
443 443
                 $this->debugmsg(''); // empty line
444 444
                 foreach (getallheaders() as $name => $val) {
@@ -463,13 +463,13 @@  discard block
 block discarded – undo
463 463
                 if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) {
464 464
                     if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) {
465 465
                         $data = $degzdata;
466
-                        if ($this->debug > 1) {
467
-                            $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
466
+                        if ($this->debug>1) {
467
+                            $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
468 468
                         }
469 469
                     } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
470 470
                         $data = $degzdata;
471
-                        if ($this->debug > 1) {
472
-                            $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
471
+                        if ($this->debug>1) {
472
+                            $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
473 473
                         }
474 474
                     } else {
475 475
                         $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'],
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                     if ($reqEncoding == 'ISO-8859-1') {
557 557
                         $data = utf8_encode($data);
558 558
                     } else {
559
-                        $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received request: ' . $reqEncoding);
559
+                        $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received request: '.$reqEncoding);
560 560
                     }
561 561
                 }
562 562
             }
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
584 584
             return new Response(
585 585
                 0,
586
-                PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1],
586
+                PhpXmlRpc::$xmlrpcerrxml+(int) $matches[1],
587 587
                 $xmlRpcParser->_xh['isf_reason']);
588 588
         } elseif ($xmlRpcParser->_xh['isf']) {
589 589
             /// @todo separate better the various cases, as we have done in Request::parseResponse: invalid xml-rpc vs.
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
             return new Response(
592 592
                 0,
593 593
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
594
-                PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
594
+                PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']);
595 595
         } else {
596 596
             // small layering violation in favor of speed and memory usage: we should allow the 'execute' method handle
597 597
             // this, but in the most common scenario (xml-rpc values type server with some methods registered as phpvals)
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
                     ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals')
602 602
                 )
603 603
             ) {
604
-                if ($this->debug > 1) {
605
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++");
604
+                if ($this->debug>1) {
605
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++");
606 606
                 }
607 607
 
608 608
                 return $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']);
609 609
             } else {
610 610
                 // build a Request object with data parsed from xml and add parameters in
611 611
                 $req = new Request($xmlRpcParser->_xh['method']);
612
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
612
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
613 613
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
614 614
                 }
615 615
 
616
-                if ($this->debug > 1) {
617
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++");
616
+                if ($this->debug>1) {
617
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++");
618 618
                 }
619 619
 
620 620
                 return $this->execute($req);
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                 return new Response(
667 667
                     0,
668 668
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
669
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}"
669
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": {$errStr}"
670 670
                 );
671 671
             }
672 672
         }
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
         // build string representation of function 'name'
682 682
         if (is_array($func)) {
683 683
             if (is_object($func[0])) {
684
-                $funcName = get_class($func[0]) . '->' . $func[1];
684
+                $funcName = get_class($func[0]).'->'.$func[1];
685 685
             } else {
686 686
                 $funcName = implode('::', $func);
687 687
             }
@@ -693,23 +693,23 @@  discard block
 block discarded – undo
693 693
 
694 694
         // verify that function to be invoked is in fact callable
695 695
         if (!is_callable($func)) {
696
-            $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
696
+            $this->getLogger()->error("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable");
697 697
             return new Response(
698 698
                 0,
699 699
                 PhpXmlRpc::$xmlrpcerr['server_error'],
700
-                PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method"
700
+                PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method"
701 701
             );
702 702
         }
703 703
 
704 704
         if (isset($dmap[$methodName]['exception_handling'])) {
705
-            $exception_handling = (int)$dmap[$methodName]['exception_handling'];
705
+            $exception_handling = (int) $dmap[$methodName]['exception_handling'];
706 706
         } else {
707 707
             $exception_handling = $this->exception_handling;
708 708
         }
709 709
 
710 710
         // If debug level is 3, we should catch all errors generated during processing of user function, and log them
711 711
         // as part of response
712
-        if ($this->debug > 2) {
712
+        if ($this->debug>2) {
713 713
             self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
714 714
         }
715 715
 
@@ -723,14 +723,14 @@  discard block
 block discarded – undo
723 723
                     $r = call_user_func($func, $req);
724 724
                 }
725 725
                 if (!is_a($r, 'PhpXmlRpc\Response')) {
726
-                    $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
726
+                    $this->getLogger()->error("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r));
727 727
                     if (is_a($r, 'PhpXmlRpc\Value')) {
728 728
                         $r = new Response($r);
729 729
                     } else {
730 730
                         $r = new Response(
731 731
                             0,
732 732
                             PhpXmlRpc::$xmlrpcerr['server_error'],
733
-                            PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object"
733
+                            PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object"
734 734
                         );
735 735
                     }
736 736
                 }
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
                         $r = call_user_func_array($func, array($methodName, $params, $this->user_data));
746 746
                         // mimic EPI behaviour: if we get an array that looks like an error, make it an error response
747 747
                         if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
748
-                            $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']);
748
+                            $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']);
749 749
                         } else {
750 750
                             // functions using EPI api should NOT return resp objects, so make sure we encode the
751 751
                             // return type correctly
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
             // proper error-response
771 771
             switch ($exception_handling) {
772 772
                 case 2:
773
-                    if ($this->debug > 2) {
773
+                    if ($this->debug>2) {
774 774
                         if (self::$_xmlrpcs_prev_ehandler) {
775 775
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
776 776
                         } else {
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
             // proper error-response
794 794
             switch ($exception_handling) {
795 795
                 case 2:
796
-                    if ($this->debug > 2) {
796
+                    if ($this->debug>2) {
797 797
                         if (self::$_xmlrpcs_prev_ehandler) {
798 798
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
799 799
                         } else {
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
             }
814 814
         }
815 815
 
816
-        if ($this->debug > 2) {
816
+        if ($this->debug>2) {
817 817
             // note: restore the error handler we found before calling the user func, even if it has been changed
818 818
             // inside the func itself
819 819
             if (self::$_xmlrpcs_prev_ehandler) {
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
      */
880 880
     protected function debugmsg($string)
881 881
     {
882
-        $this->debug_info .= $string . "\n";
882
+        $this->debug_info .= $string."\n";
883 883
     }
884 884
 
885 885
     /**
@@ -889,9 +889,9 @@  discard block
 block discarded – undo
889 889
     protected function xml_header($charsetEncoding = '')
890 890
     {
891 891
         if ($charsetEncoding != '') {
892
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
892
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n";
893 893
         } else {
894
-            return "<?xml version=\"1.0\"?" . ">\n";
894
+            return "<?xml version=\"1.0\"?".">\n";
895 895
         }
896 896
     }
897 897
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
                 $i++; // for error message, we count params from 1
1185 1185
                 return static::_xmlrpcs_multicall_error(new Response(0,
1186 1186
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
1187
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
1187
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i));
1188 1188
             }
1189 1189
         }
1190 1190
 
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
             }
1266 1266
         } else {
1267 1267
             $numCalls = count($req);
1268
-            for ($i = 0; $i < $numCalls; $i++) {
1268
+            for ($i = 0; $i<$numCalls; $i++) {
1269 1269
                 $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]);
1270 1270
             }
1271 1271
         }
Please login to merge, or discard this patch.