Passed
Push — master ( 5987e0...fe1d88 )
by Gaetano
09:19
created
src/Server.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public static function xmlrpc_debugmsg($msg)
239 239
     {
240
-        static::$_xmlrpc_debuginfo .= $msg . "\n";
240
+        static::$_xmlrpc_debuginfo .= $msg."\n";
241 241
     }
242 242
 
243 243
     /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public static function error_occurred($msg)
251 251
     {
252
-        static::$_xmlrpcs_occurred_errors .= $msg . "\n";
252
+        static::$_xmlrpcs_occurred_errors .= $msg."\n";
253 253
     }
254 254
 
255 255
     /**
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
         // user debug info should be encoded by the end user using the INTERNAL_ENCODING
271 271
         $out = '';
272 272
         if ($this->debug_info != '') {
273
-            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n";
273
+            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
274 274
         }
275 275
         if (static::$_xmlrpc_debuginfo != '') {
276
-            $out .= "<!-- DEBUG INFO:\n" . $this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n";
276
+            $out .= "<!-- DEBUG INFO:\n".$this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n";
277 277
             // NB: a better solution MIGHT be to use CDATA, but we need to insert it
278 278
             // into return payload AFTER the beginning tag
279 279
             //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n";
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
         $this->debug_info = '';
303 303
 
304 304
         // Save what we received, before parsing it
305
-        if ($this->debug > 1) {
306
-            $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
305
+        if ($this->debug>1) {
306
+            $this->debugmsg("+++GOT+++\n".$data."\n+++END+++");
307 307
         }
308 308
 
309 309
         $resp = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding);
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
             $resp->raw_data = $rawData;
321 321
         }
322 322
 
323
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') {
324
-            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
325
-                static::$_xmlrpcs_occurred_errors . "+++END+++");
323
+        if ($this->debug>2 && static::$_xmlrpcs_occurred_errors != '') {
324
+            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n".
325
+                static::$_xmlrpcs_occurred_errors."+++END+++");
326 326
         }
327 327
 
328 328
         $payload = $this->xml_header($respCharset);
329
-        if ($this->debug > 0) {
330
-            $payload = $payload . $this->serializeDebug($respCharset);
329
+        if ($this->debug>0) {
330
+            $payload = $payload.$this->serializeDebug($respCharset);
331 331
         }
332 332
 
333 333
         // Do not create response serialization if it has already happened. Helps to build json magic
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         if (empty($resp->payload)) {
336 336
             $resp->serialize($respCharset);
337 337
         }
338
-        $payload = $payload . $resp->payload;
338
+        $payload = $payload.$resp->payload;
339 339
 
340 340
         if ($returnPayload) {
341 341
             return $payload;
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         // if we get a warning/error that has output some text before here, then we cannot
345 345
         // add a new header. We cannot say we are sending xml, either...
346 346
         if (!headers_sent()) {
347
-            header('Content-Type: ' . $resp->content_type);
347
+            header('Content-Type: '.$resp->content_type);
348 348
             // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did
349 349
             header("Vary: Accept-Charset");
350 350
 
@@ -367,10 +367,10 @@  discard block
 block discarded – undo
367 367
             // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for
368 368
             // responses up to 8000 bytes
369 369
             if ($phpNoSelfCompress) {
370
-                header('Content-Length: ' . (int)strlen($payload));
370
+                header('Content-Length: '.(int) strlen($payload));
371 371
             }
372 372
         } else {
373
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
373
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
374 374
         }
375 375
 
376 376
         print $payload;
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
             $numParams = count($in);
429 429
         }
430 430
         foreach ($sigs as $curSig) {
431
-            if (count($curSig) == $numParams + 1) {
431
+            if (count($curSig) == $numParams+1) {
432 432
                 $itsOK = 1;
433
-                for ($n = 0; $n < $numParams; $n++) {
433
+                for ($n = 0; $n<$numParams; $n++) {
434 434
                     if (is_object($in)) {
435 435
                         $p = $in->getParam($n);
436 436
                         if ($p->kindOf() == 'scalar') {
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
                     }
444 444
 
445 445
                     // param index is $n+1, as first member of sig is return type
446
-                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
446
+                    if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) {
447 447
                         $itsOK = 0;
448
-                        $pno = $n + 1;
449
-                        $wanted = $curSig[$n + 1];
448
+                        $pno = $n+1;
449
+                        $wanted = $curSig[$n+1];
450 450
                         $got = $pt;
451 451
                         break;
452 452
                     }
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
         // check if $_SERVER is populated: it might have been disabled via ini file
474 474
         // (this is true even when in CLI mode)
475 475
         if (count($_SERVER) == 0) {
476
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
476
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
477 477
         }
478 478
 
479
-        if ($this->debug > 1) {
479
+        if ($this->debug>1) {
480 480
             if (function_exists('getallheaders')) {
481 481
                 $this->debugmsg(''); // empty line
482 482
                 foreach (getallheaders() as $name => $val) {
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
                 if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) {
502 502
                     if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) {
503 503
                         $data = $degzdata;
504
-                        if ($this->debug > 1) {
505
-                            $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
504
+                        if ($this->debug>1) {
505
+                            $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
506 506
                         }
507 507
                     } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
508 508
                         $data = $degzdata;
509
-                        if ($this->debug > 1) {
510
-                            $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
509
+                        if ($this->debug>1) {
510
+                            $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
511 511
                         }
512 512
                     } else {
513 513
                         $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'],
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
                 // here we check if we can match the client-requested encoding with the encodings we know we can generate.
535 535
                 // we parse q=0.x preferences instead of preferring the first charset specified
536 536
                 $clientAcceptedCharsets = array();
537
-                foreach(explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])) as $c) {
537
+                foreach (explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])) as $c) {
538 538
                     if (preg_match('/^([^;]+);Q=([0-9.]+)/', $c, $matches)) {
539 539
                         $c = $matches[1];
540 540
                         $w = $matches[2];
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
                     if ($reqEncoding == 'ISO-8859-1') {
614 614
                         $data = utf8_encode($data);
615 615
                     } else {
616
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received request: ' . $reqEncoding);
616
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': unsupported charset encoding of received request: '.$reqEncoding);
617 617
                     }
618 618
                 }
619 619
             }
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
641 641
             return new Response(
642 642
                 0,
643
-                PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1],
643
+                PhpXmlRpc::$xmlrpcerrxml+(int) $matches[1],
644 644
                 $xmlRpcParser->_xh['isf_reason']);
645 645
         } elseif ($xmlRpcParser->_xh['isf']) {
646 646
             /// @todo separate better the various cases, as we have done in Request::parseResponse: invalid xml-rpc,
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
             return new Response(
649 649
                 0,
650 650
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
651
-                PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
651
+                PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']);
652 652
         } else {
653 653
             // small layering violation in favor of speed and memory usage: we should allow the 'execute' method handle
654 654
             // this, but in the most common scenario (xmlrpc values type server with some methods registered as phpvals)
@@ -658,20 +658,20 @@  discard block
 block discarded – undo
658 658
                     ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals')
659 659
                 )
660 660
             ) {
661
-                if ($this->debug > 1) {
662
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++");
661
+                if ($this->debug>1) {
662
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++");
663 663
                 }
664 664
 
665 665
                 return $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']);
666 666
             } else {
667 667
                 // build a Request object with data parsed from xml and add parameters in
668 668
                 $req = new Request($xmlRpcParser->_xh['method']);
669
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
669
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
670 670
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
671 671
                 }
672 672
 
673
-                if ($this->debug > 1) {
674
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++");
673
+                if ($this->debug>1) {
674
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++");
675 675
                 }
676 676
 
677 677
                 return $this->execute($req);
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
                 return new Response(
724 724
                     0,
725 725
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
726
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}"
726
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": {$errStr}"
727 727
                 );
728 728
             }
729 729
         }
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         // build string representation of function 'name'
739 739
         if (is_array($func)) {
740 740
             if (is_object($func[0])) {
741
-                $funcName = get_class($func[0]) . '->' . $func[1];
741
+                $funcName = get_class($func[0]).'->'.$func[1];
742 742
             } else {
743 743
                 $funcName = implode('::', $func);
744 744
             }
@@ -750,17 +750,17 @@  discard block
 block discarded – undo
750 750
 
751 751
         // verify that function to be invoked is in fact callable
752 752
         if (!is_callable($func)) {
753
-            $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
753
+            $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable");
754 754
             return new Response(
755 755
                 0,
756 756
                 PhpXmlRpc::$xmlrpcerr['server_error'],
757
-                PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method"
757
+                PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method"
758 758
             );
759 759
         }
760 760
 
761 761
         // If debug level is 3, we should catch all errors generated during processing of user function, and log them
762 762
         // as part of response
763
-        if ($this->debug > 2) {
763
+        if ($this->debug>2) {
764 764
             self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
765 765
         }
766 766
 
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
                     $r = call_user_func($func, $req);
775 775
                 }
776 776
                 if (!is_a($r, 'PhpXmlRpc\Response')) {
777
-                    $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
777
+                    $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r));
778 778
                     if (is_a($r, 'PhpXmlRpc\Value')) {
779 779
                         $r = new Response($r);
780 780
                     } else {
781 781
                         $r = new Response(
782 782
                             0,
783 783
                             PhpXmlRpc::$xmlrpcerr['server_error'],
784
-                            PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object"
784
+                            PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object"
785 785
                         );
786 786
                     }
787 787
                 }
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
                         $r = call_user_func_array($func, array($methodName, $params, $this->user_data));
797 797
                         // mimic EPI behaviour: if we get an array that looks like an error, make it an error response
798 798
                         if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
799
-                            $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']);
799
+                            $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']);
800 800
                         } else {
801 801
                             // functions using EPI api should NOT return resp objects, so make sure we encode the
802 802
                             // return type correctly
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
             // proper error-response
821 821
             switch ($this->exception_handling) {
822 822
                 case 2:
823
-                    if ($this->debug > 2) {
823
+                    if ($this->debug>2) {
824 824
                         if (self::$_xmlrpcs_prev_ehandler) {
825 825
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
826 826
                         } else {
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
             // proper error-response
844 844
             switch ($this->exception_handling) {
845 845
                 case 2:
846
-                    if ($this->debug > 2) {
846
+                    if ($this->debug>2) {
847 847
                         if (self::$_xmlrpcs_prev_ehandler) {
848 848
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
849 849
                         } else {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             }
864 864
         }
865 865
 
866
-        if ($this->debug > 2) {
866
+        if ($this->debug>2) {
867 867
             // note: restore the error handler we found before calling the user func, even if it has been changed
868 868
             // inside the func itself
869 869
             if (self::$_xmlrpcs_prev_ehandler) {
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
      */
930 930
     protected function debugmsg($string)
931 931
     {
932
-        $this->debug_info .= $string . "\n";
932
+        $this->debug_info .= $string."\n";
933 933
     }
934 934
 
935 935
     /**
@@ -939,9 +939,9 @@  discard block
 block discarded – undo
939 939
     protected function xml_header($charsetEncoding = '')
940 940
     {
941 941
         if ($charsetEncoding != '') {
942
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
942
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n";
943 943
         } else {
944
-            return "<?xml version=\"1.0\"?" . ">\n";
944
+            return "<?xml version=\"1.0\"?".">\n";
945 945
         }
946 946
     }
947 947
 
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
                 $i++; // for error message, we count params from 1
1235 1235
                 return static::_xmlrpcs_multicall_error(new Response(0,
1236 1236
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
1237
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
1237
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i));
1238 1238
             }
1239 1239
         }
1240 1240
 
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
             }
1316 1316
         } else {
1317 1317
             $numCalls = count($req);
1318
-            for ($i = 0; $i < $numCalls; $i++) {
1318
+            for ($i = 0; $i<$numCalls; $i++) {
1319 1319
                 $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]);
1320 1320
             }
1321 1321
         }
Please login to merge, or discard this patch.