Passed
Push — master ( 577871...2d5b6d )
by Gaetano
07:53
created
demo/server/proxy.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @license code licensed under the BSD License: see file license.txt
16 16
  */
17 17
 
18
-require_once __DIR__ . "/_prepend.php";
18
+require_once __DIR__."/_prepend.php";
19 19
 
20 20
 // *** NB: WE BLOCK THIS FROM RUNNING BY DEFAULT IN CASE ACCESS IS GRANTED TO IT IN PRODUCTION BY MISTAKE ***
21 21
 // Comment out the following safeguard if you want to use it as is, but remember: this is an open relay !!!
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     //            fe. any url using the 'file://' protocol might be considered a hacking attempt
47 47
     $client = new Client($url);
48 48
 
49
-    if ($req->getNumParams() > 3) {
49
+    if ($req->getNumParams()>3) {
50 50
         // we have to set some options onto the client.
51 51
         // Note that if we do not untaint the received values, warnings might be generated...
52 52
         $options = $encoder->decode($req->getParam(3));
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     $client->setSSLVerifyPeer($val);
69 69
                     break;
70 70
                 case 'Timeout':
71
-                    $timeout = (integer)$val;
71
+                    $timeout = (integer) $val;
72 72
                     break;
73 73
             } // switch
74 74
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     ///         X-forwarded-for anyway, unless they consider this server as trusted...)
82 82
     $reqMethod = $req->getParam(1)->scalarval();
83 83
     $req = new Request($reqMethod);
84
-    if ($req->getNumParams() > 1) {
84
+    if ($req->getNumParams()>1) {
85 85
         $pars = $req->getParam(2);
86 86
         foreach ($pars as $par) {
87 87
             $req->addParam($par);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     }
90 90
 
91 91
     // add debug info into response we give back to caller
92
-    Server::xmlrpc_debugmsg("Sending to server $url the payload: " . $req->serialize());
92
+    Server::xmlrpc_debugmsg("Sending to server $url the payload: ".$req->serialize());
93 93
 
94 94
     return $client->send($req, $timeout);
95 95
 }
Please login to merge, or discard this patch.
demo/server/discuss.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  *   `$functions_parameters_type` and `$exception_handling`
10 10
  */
11 11
 
12
-require_once __DIR__ . "/_prepend.php";
12
+require_once __DIR__."/_prepend.php";
13 13
 
14 14
 use PhpXmlRpc\Response;
15 15
 use PhpXmlRpc\Server;
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 $addComment_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString));
93 93
 
94
-$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, ' .
94
+$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, '.
95 95
     'and the third is the comment itself. Returns the number of comments against that ID.';
96 96
 
97 97
 $getComments_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcString));
98 98
 
99
-$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct ' .
99
+$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct '.
100 100
     'containing name and comment text.';
101 101
 
102 102
 // NB: take care not to output anything else after this call, as it will mess up the responses and it will be hard to
Please login to merge, or discard this patch.
src/Server.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     public static function xmlrpc_debugmsg($msg)
235 235
     {
236
-        static::$_xmlrpc_debuginfo .= $msg . "\n";
236
+        static::$_xmlrpc_debuginfo .= $msg."\n";
237 237
     }
238 238
 
239 239
     /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      */
246 246
     public static function error_occurred($msg)
247 247
     {
248
-        static::$_xmlrpcs_occurred_errors .= $msg . "\n";
248
+        static::$_xmlrpcs_occurred_errors .= $msg."\n";
249 249
     }
250 250
 
251 251
     /**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
         // user debug info should be encoded by the end user using the INTERNAL_ENCODING
267 267
         $out = '';
268 268
         if ($this->debug_info != '') {
269
-            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n" . base64_encode($this->debug_info) . "\n-->\n";
269
+            $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n";
270 270
         }
271 271
         if (static::$_xmlrpc_debuginfo != '') {
272
-            $out .= "<!-- DEBUG INFO:\n" . $this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n-->\n";
272
+            $out .= "<!-- DEBUG INFO:\n".$this->getCharsetEncoder()->encodeEntities(str_replace('--', '_-', static::$_xmlrpc_debuginfo), PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."\n-->\n";
273 273
             // NB: a better solution MIGHT be to use CDATA, but we need to insert it
274 274
             // into return payload AFTER the beginning tag
275 275
             //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', static::$_xmlrpc_debuginfo) . "\n]]>\n";
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
         $this->debug_info = '';
299 299
 
300 300
         // Save what we received, before parsing it
301
-        if ($this->debug > 1) {
302
-            $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
301
+        if ($this->debug>1) {
302
+            $this->debugmsg("+++GOT+++\n".$data."\n+++END+++");
303 303
         }
304 304
 
305 305
         $r = $this->parseRequestHeaders($data, $reqCharset, $respCharset, $respEncoding);
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
             $r->raw_data = $rawData;
314 314
         }
315 315
 
316
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') {
317
-            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
318
-                static::$_xmlrpcs_occurred_errors . "+++END+++");
316
+        if ($this->debug>2 && static::$_xmlrpcs_occurred_errors != '') {
317
+            $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n".
318
+                static::$_xmlrpcs_occurred_errors."+++END+++");
319 319
         }
320 320
 
321 321
         $payload = $this->xml_header($respCharset);
322
-        if ($this->debug > 0) {
323
-            $payload = $payload . $this->serializeDebug($respCharset);
322
+        if ($this->debug>0) {
323
+            $payload = $payload.$this->serializeDebug($respCharset);
324 324
         }
325 325
 
326 326
         // Do not create response serialization if it has already happened. Helps building json magic
327 327
         if (empty($r->payload)) {
328 328
             $r->serialize($respCharset);
329 329
         }
330
-        $payload = $payload . $r->payload;
330
+        $payload = $payload.$r->payload;
331 331
 
332 332
         if ($returnPayload) {
333 333
             return $payload;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         // if we get a warning/error that has output some text before here, then we cannot
337 337
         // add a new header. We cannot say we are sending xml, either...
338 338
         if (!headers_sent()) {
339
-            header('Content-Type: ' . $r->content_type);
339
+            header('Content-Type: '.$r->content_type);
340 340
             // we do not know if client actually told us an accepted charset, but if it did we have to tell it what we did
341 341
             header("Vary: Accept-Charset");
342 342
 
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
             // Note that Apache/mod_php will add (and even alter!) the Content-Length header on its own, but only for
360 360
             // responses up to 8000 bytes
361 361
             if ($phpNoSelfCompress) {
362
-                header('Content-Length: ' . (int)strlen($payload));
362
+                header('Content-Length: '.(int) strlen($payload));
363 363
             }
364 364
         } else {
365
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
365
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages');
366 366
         }
367 367
 
368 368
         print $payload;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
             $numParams = count($in);
418 418
         }
419 419
         foreach ($sigs as $curSig) {
420
-            if (count($curSig) == $numParams + 1) {
420
+            if (count($curSig) == $numParams+1) {
421 421
                 $itsOK = 1;
422
-                for ($n = 0; $n < $numParams; $n++) {
422
+                for ($n = 0; $n<$numParams; $n++) {
423 423
                     if (is_object($in)) {
424 424
                         $p = $in->getParam($n);
425 425
                         if ($p->kindOf() == 'scalar') {
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
                     }
433 433
 
434 434
                     // param index is $n+1, as first member of sig is return type
435
-                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
435
+                    if ($pt != $curSig[$n+1] && $curSig[$n+1] != Value::$xmlrpcValue) {
436 436
                         $itsOK = 0;
437
-                        $pno = $n + 1;
438
-                        $wanted = $curSig[$n + 1];
437
+                        $pno = $n+1;
438
+                        $wanted = $curSig[$n+1];
439 439
                         $got = $pt;
440 440
                         break;
441 441
                     }
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
         // check if $_SERVER is populated: it might have been disabled via ini file
463 463
         // (this is true even when in CLI mode)
464 464
         if (count($_SERVER) == 0) {
465
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
465
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated');
466 466
         }
467 467
 
468
-        if ($this->debug > 1) {
468
+        if ($this->debug>1) {
469 469
             if (function_exists('getallheaders')) {
470 470
                 $this->debugmsg(''); // empty line
471 471
                 foreach (getallheaders() as $name => $val) {
@@ -490,13 +490,13 @@  discard block
 block discarded – undo
490 490
                 if (function_exists('gzinflate') && in_array($contentEncoding, $this->accepted_compression)) {
491 491
                     if ($contentEncoding == 'deflate' && $degzdata = @gzuncompress($data)) {
492 492
                         $data = $degzdata;
493
-                        if ($this->debug > 1) {
494
-                            $this->debugmsg("\n+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
493
+                        if ($this->debug>1) {
494
+                            $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
495 495
                         }
496 496
                     } elseif ($contentEncoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
497 497
                         $data = $degzdata;
498
-                        if ($this->debug > 1) {
499
-                            $this->debugmsg("+++INFLATED REQUEST+++[" . strlen($data) . " chars]+++\n" . $data . "\n+++END+++");
498
+                        if ($this->debug>1) {
499
+                            $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++");
500 500
                         }
501 501
                     } else {
502 502
                         $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_decompress_fail'],
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
                     if ($reqEncoding == 'ISO-8859-1') {
590 590
                         $data = utf8_encode($data);
591 591
                     } else {
592
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding);
592
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$reqEncoding);
593 593
                     }
594 594
                 }
595 595
             }
@@ -608,18 +608,18 @@  discard block
 block discarded – undo
608 608
 
609 609
         $xmlRpcParser = $this->getParser();
610 610
         $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST, $options);
611
-        if ($xmlRpcParser->_xh['isf'] > 2) {
611
+        if ($xmlRpcParser->_xh['isf']>2) {
612 612
             // (BC) we return XML error as a faultCode
613 613
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
614 614
             $r = new Response(
615 615
                 0,
616
-                PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1],
616
+                PhpXmlRpc::$xmlrpcerrxml+(int) $matches[1],
617 617
                 $xmlRpcParser->_xh['isf_reason']);
618 618
         } elseif ($xmlRpcParser->_xh['isf']) {
619 619
             $r = new Response(
620 620
                 0,
621 621
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
622
-                PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
622
+                PhpXmlRpc::$xmlrpcstr['invalid_request'].' '.$xmlRpcParser->_xh['isf_reason']);
623 623
         } else {
624 624
             // small layering violation in favor of speed and memory usage:
625 625
             // we should allow the 'execute' method handle this, but in the
@@ -631,20 +631,20 @@  discard block
 block discarded – undo
631 631
                     ($this->dmap[$xmlRpcParser->_xh['method']]['parameters_type'] != 'xmlrpcvals')
632 632
                 )
633 633
             ) {
634
-                if ($this->debug > 1) {
635
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($xmlRpcParser->_xh['params'], true) . "\n+++END+++");
634
+                if ($this->debug>1) {
635
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($xmlRpcParser->_xh['params'], true)."\n+++END+++");
636 636
                 }
637 637
                 $r = $this->execute($xmlRpcParser->_xh['method'], $xmlRpcParser->_xh['params'], $xmlRpcParser->_xh['pt']);
638 638
             } else {
639 639
                 // build a Request object with data parsed from xml
640 640
                 $req = new Request($xmlRpcParser->_xh['method']);
641 641
                 // now add parameters in
642
-                for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
642
+                for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) {
643 643
                     $req->addParam($xmlRpcParser->_xh['params'][$i]);
644 644
                 }
645 645
 
646
-                if ($this->debug > 1) {
647
-                    $this->debugmsg("\n+++PARSED+++\n" . var_export($req, true) . "\n+++END+++");
646
+                if ($this->debug>1) {
647
+                    $this->debugmsg("\n+++PARSED+++\n".var_export($req, true)."\n+++END+++");
648 648
                 }
649 649
                 $r = $this->execute($req);
650 650
             }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
                 return new Response(
697 697
                     0,
698 698
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
699
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}"
699
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": {$errStr}"
700 700
                 );
701 701
             }
702 702
         }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 
710 710
         if (is_array($func)) {
711 711
             if (is_object($func[0])) {
712
-                $funcName = get_class($func[0]) . '->' . $func[1];
712
+                $funcName = get_class($func[0]).'->'.$func[1];
713 713
             } else {
714 714
                 $funcName = implode('::', $func);
715 715
             }
@@ -721,17 +721,17 @@  discard block
 block discarded – undo
721 721
 
722 722
         // verify that function to be invoked is in fact callable
723 723
         if (!is_callable($func)) {
724
-            $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
724
+            $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler is not callable");
725 725
             return new Response(
726 726
                 0,
727 727
                 PhpXmlRpc::$xmlrpcerr['server_error'],
728
-                PhpXmlRpc::$xmlrpcstr['server_error'] . ": no function matches method"
728
+                PhpXmlRpc::$xmlrpcstr['server_error'].": no function matches method"
729 729
             );
730 730
         }
731 731
 
732 732
         // If debug level is 3, we should catch all errors generated during
733 733
         // processing of user function, and log them as part of response
734
-        if ($this->debug > 2) {
734
+        if ($this->debug>2) {
735 735
             self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
736 736
         }
737 737
 
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
                     $r = call_user_func($func, $req);
745 745
                 }
746 746
                 if (!is_a($r, 'PhpXmlRpc\Response')) {
747
-                    $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
747
+                    $this->getLogger()->errorLog("XML-RPC: ".__METHOD__.": function '$funcName' registered as method handler does not return an xmlrpc response object but a ".gettype($r));
748 748
                     if (is_a($r, 'PhpXmlRpc\Value')) {
749 749
                         $r = new Response($r);
750 750
                     } else {
751 751
                         $r = new Response(
752 752
                             0,
753 753
                             PhpXmlRpc::$xmlrpcerr['server_error'],
754
-                            PhpXmlRpc::$xmlrpcstr['server_error'] . ": function does not return xmlrpc response object"
754
+                            PhpXmlRpc::$xmlrpcstr['server_error'].": function does not return xmlrpc response object"
755 755
                         );
756 756
                     }
757 757
                 }
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
                         // mimic EPI behaviour: if we get an array that looks like an error, make it
768 768
                         // an error response
769 769
                         if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
770
-                            $r = new Response(0, (integer)$r['faultCode'], (string)$r['faultString']);
770
+                            $r = new Response(0, (integer) $r['faultCode'], (string) $r['faultString']);
771 771
                         } else {
772 772
                             // functions using EPI api should NOT return resp objects,
773 773
                             // so make sure we encode the return type correctly
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
             // proper error-response
791 791
             switch ($this->exception_handling) {
792 792
                 case 2:
793
-                    if ($this->debug > 2) {
793
+                    if ($this->debug>2) {
794 794
                         if (self::$_xmlrpcs_prev_ehandler) {
795 795
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
796 796
                         } else {
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
             // proper error-response
814 814
             switch ($this->exception_handling) {
815 815
                 case 2:
816
-                    if ($this->debug > 2) {
816
+                    if ($this->debug>2) {
817 817
                         if (self::$_xmlrpcs_prev_ehandler) {
818 818
                             set_error_handler(self::$_xmlrpcs_prev_ehandler);
819 819
                         } else {
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
                     $r = new Response(0, PhpXmlRpc::$xmlrpcerr['server_error'], PhpXmlRpc::$xmlrpcstr['server_error']);
833 833
             }
834 834
         }
835
-        if ($this->debug > 2) {
835
+        if ($this->debug>2) {
836 836
             // note: restore the error handler we found before calling the
837 837
             // user func, even if it has been changed inside the func itself
838 838
             if (self::$_xmlrpcs_prev_ehandler) {
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
      */
854 854
     protected function debugmsg($string)
855 855
     {
856
-        $this->debug_info .= $string . "\n";
856
+        $this->debug_info .= $string."\n";
857 857
     }
858 858
 
859 859
     /**
@@ -863,9 +863,9 @@  discard block
 block discarded – undo
863 863
     protected function xml_header($charsetEncoding = '')
864 864
     {
865 865
         if ($charsetEncoding != '') {
866
-            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
866
+            return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?".">\n";
867 867
         } else {
868
-            return "<?xml version=\"1.0\"?" . ">\n";
868
+            return "<?xml version=\"1.0\"?".">\n";
869 869
         }
870 870
     }
871 871
 
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
                 $i++; // for error message, we count params from 1
1137 1137
                 return static::_xmlrpcs_multicall_error(new Response(0,
1138 1138
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
1139
-                    PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
1139
+                    PhpXmlRpc::$xmlrpcstr['incorrect_params'].": probable xml error in param ".$i));
1140 1140
             }
1141 1141
         }
1142 1142
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
             }
1218 1218
         } else {
1219 1219
             $numCalls = count($req);
1220
-            for ($i = 0; $i < $numCalls; $i++) {
1220
+            for ($i = 0; $i<$numCalls; $i++) {
1221 1221
                 $result[$i] = static::_xmlrpcs_multicall_do_call_phpvals($server, $req[$i]);
1222 1222
             }
1223 1223
         }
Please login to merge, or discard this patch.