Passed
Push — master ( ebcf65...c803c8 )
by Gaetano
06:00
created
demo/server/server.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     die();
22 22
 }
23 23
 
24
-require_once __DIR__ . "/_prepend.php";
24
+require_once __DIR__."/_prepend.php";
25 25
 
26 26
 use PhpXmlRpc\PhpXmlRpc;
27 27
 use PhpXmlRpc\Server;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         } elseif ($_GET['FORCE_AUTH'] == 'Digest') {
81 81
             if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
82 82
                 header('HTTP/1.1 401 Unauthorized');
83
-                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"');
83
+                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="'.uniqid().'",opaque="'.md5('Phpxmlrpc Digest Realm').'"');
84 84
                 die('Text visible if user hits Cancel button');
85 85
             }
86 86
         }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     if (isset($_GET['FORCE_REDIRECT'])) {
89 89
         header('HTTP/1.0 302 Found');
90 90
         unset($_GET['FORCE_REDIRECT']);
91
-        header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : ''));
91
+        header('Location: '.$_SERVER['REQUEST_URI'].(count($_GET) ? '?'.http_build_query($_GET) : ''));
92 92
         die();
93 93
     }
94 94
 }
Please login to merge, or discard this patch.
src/Helper/XMLParser.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
         foreach ($mergedOptions as $key => $val) {
183 183
             // q: can php be built without ctype? should we use a regexp?
184 184
             if (is_string($key) && !ctype_digit($key)) {
185
-                switch($key) {
185
+                switch ($key) {
186 186
                     case 'target_charset':
187 187
                         if (function_exists('mb_convert_encoding')) {
188 188
                             $this->current_parsing_options['target_charset'] = $val;
189 189
                         } else {
190
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": 'target_charset' option is unsupported without mbstring");
190
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": 'target_charset' option is unsupported without mbstring");
191 191
                         }
192 192
                         break;
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                             //$this->_xh['isf'] = 4;
199 199
                             //$this->_xh['isf_reason'] = "Callback passed as 'methodname_callback' is not callable";
200 200
                             //return;
201
-                            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Callback passed as 'methodname_callback' is not callable");
201
+                            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Callback passed as 'methodname_callback' is not callable");
202 202
                         }
203 203
                         break;
204 204
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                         break;
210 210
 
211 211
                     default:
212
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": unsupported option: $key");
212
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": unsupported option: $key");
213 213
                 }
214 214
                 unset($mergedOptions[$key]);
215 215
             }
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 
256 256
         try {
257 257
             // @see ticket #70 - we have to parse big xml docs in chunks to avoid errors
258
-            for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) {
258
+            for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) {
259 259
                 $chunk = substr($data, $offset, $this->maxChunkLength);
260 260
                 // error handling: xml not well formed
261
-                if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) {
261
+                if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) {
262 262
                     $errCode = xml_get_error_code($parser);
263 263
                     $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode),
264 264
                         xml_get_current_line_number($parser), xml_get_current_column_number($parser));
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                     break;
269 269
                 }
270 270
                 // no need to parse further if we already have a fatal error
271
-                if ($this->_xh['isf'] >= 2) {
271
+                if ($this->_xh['isf']>=2) {
272 272
                     break;
273 273
                 }
274 274
             }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)
301 301
     {
302 302
         // if invalid xml-rpc already detected, skip all processing
303
-        if ($this->_xh['isf'] >= 2) {
303
+        if ($this->_xh['isf']>=2) {
304 304
             return;
305 305
         }
306 306
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                 $this->_xh['rt'] = strtolower($name);
324 324
             } else {
325 325
                 $this->_xh['isf'] = 2;
326
-                $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name;
326
+                $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name;
327 327
 
328 328
                 return;
329 329
             }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
             case 'MEMBER':
427 427
                 // set member name to null, in case we do not find in the xml later on
428 428
                 /// @todo we could reject structs missing a NAME in the MEMBER element
429
-                $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = '';
429
+                $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = '';
430 430
                 //$this->_xh['ac']='';
431 431
                 // Drop trough intentionally
432 432
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
      */
499 499
     public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1)
500 500
     {
501
-        if ($this->_xh['isf'] >= 2) {
501
+        if ($this->_xh['isf']>=2) {
502 502
             return;
503 503
 
504 504
         }
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
                     $this->_xh['value'] = mb_convert_encoding($this->_xh['value'], $this->current_parsing_options['target_charset'], 'UTF-8');
521 521
                 }
522 522
 
523
-                if ($rebuildXmlrpcvals > 0) {
523
+                if ($rebuildXmlrpcvals>0) {
524 524
                     // build the xml-rpc val out of the data received, and substitute it
525 525
                     $temp = new Value($this->_xh['value'], $this->_xh['vt']);
526 526
                     // in case we got info about underlying php class, save it in the object we're rebuilding
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
                         $temp->_php_class = $this->_xh['php_class'];
529 529
                     }
530 530
                     $this->_xh['value'] = $temp;
531
-                } elseif ($rebuildXmlrpcvals < 0) {
531
+                } elseif ($rebuildXmlrpcvals<0) {
532 532
                     if ($this->_xh['vt'] == Value::$xmlrpcDateTime) {
533
-                        $this->_xh['value'] = (object)array(
533
+                        $this->_xh['value'] = (object) array(
534 534
                             'xmlrpc_type' => 'datetime',
535 535
                             'scalar' => $this->_xh['value'],
536 536
                             'timestamp' => \PhpXmlRpc\Helper\Date::iso8601Decode($this->_xh['value'])
537 537
                         );
538 538
                     } elseif ($this->_xh['vt'] == Value::$xmlrpcBase64) {
539
-                        $this->_xh['value'] = (object)array(
539
+                        $this->_xh['value'] = (object) array(
540 540
                             'xmlrpc_type' => 'base64',
541 541
                             'scalar' => $this->_xh['value']
542 542
                         );
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
                 // check if we are inside an array or struct:
552 552
                 // if value just built is inside an array, let's move it into array on the stack
553 553
                 $vscount = count($this->_xh['valuestack']);
554
-                if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') {
555
-                    $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value'];
554
+                if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') {
555
+                    $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value'];
556 556
                 }
557 557
                 break;
558 558
 
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
                     // log if receiving something strange, even though we set the value to false anyway
580 580
                     /// @todo to be consistent with the other types, we should return a value outside the good-value domain, e.g. NULL
581 581
                     if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') !== 0) {
582
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BOOLEAN value: ' . $this->_xh['ac']);
582
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid data received in BOOLEAN value: '.$this->_xh['ac']);
583 583
                         if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
584 584
                         {
585 585
                             $this->_xh['isf'] = 2;
586
-                            $this->_xh['isf_reason'] = 'Invalid data received in BOOLEAN value: ' . $this->_xh['ac'];
586
+                            $this->_xh['isf_reason'] = 'Invalid data received in BOOLEAN value: '.$this->_xh['ac'];
587 587
                             return;
588 588
                         }
589 589
                     }
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
                 $this->_xh['vt'] = strtolower($name);
603 603
                 $this->_xh['lv'] = 3; // indicate we've found a value
604 604
                 if (!preg_match(PhpXmlRpc::$xmlrpc_int_format, $this->_xh['ac'])) {
605
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric data received in INT: ' . $this->_xh['ac']);
605
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric data received in INT: '.$this->_xh['ac']);
606 606
                     if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
607 607
                     {
608 608
                         $this->_xh['isf'] = 2;
609
-                        $this->_xh['isf_reason'] = 'Non numeric data received in INT value: ' . $this->_xh['ac'];
609
+                        $this->_xh['isf_reason'] = 'Non numeric data received in INT value: '.$this->_xh['ac'];
610 610
                         return;
611 611
                     }
612 612
                     /// @todo: find a better way of reporting an error value than this! Use NaN?
613 613
                     $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
614 614
                 } else {
615 615
                     // it's ok, add it on
616
-                    $this->_xh['value'] = (int)$this->_xh['ac'];
616
+                    $this->_xh['value'] = (int) $this->_xh['ac'];
617 617
                 }
618 618
                 break;
619 619
 
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
                 $this->_xh['vt'] = Value::$xmlrpcDouble;
622 622
                 $this->_xh['lv'] = 3; // indicate we've found a value
623 623
                 if (!preg_match(PhpXmlRpc::$xmlrpc_double_format, $this->_xh['ac'])) {
624
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric data received in DOUBLE value: ' . $this->_xh['ac']);
624
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': non numeric data received in DOUBLE value: '.$this->_xh['ac']);
625 625
                     if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
626 626
                     {
627 627
                         $this->_xh['isf'] = 2;
628
-                        $this->_xh['isf_reason'] = 'Non numeric data received in DOUBLE value: ' . $this->_xh['ac'];
628
+                        $this->_xh['isf_reason'] = 'Non numeric data received in DOUBLE value: '.$this->_xh['ac'];
629 629
                         return;
630 630
                     }
631 631
 
632 632
                     $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND';
633 633
                 } else {
634 634
                     // it's ok, add it on
635
-                    $this->_xh['value'] = (double)$this->_xh['ac'];
635
+                    $this->_xh['value'] = (double) $this->_xh['ac'];
636 636
                 }
637 637
                 break;
638 638
 
@@ -640,20 +640,20 @@  discard block
 block discarded – undo
640 640
                 $this->_xh['vt'] = Value::$xmlrpcDateTime;
641 641
                 $this->_xh['lv'] = 3; // indicate we've found a value
642 642
                 if (!preg_match(PhpXmlRpc::$xmlrpc_datetime_format, $this->_xh['ac'])) {
643
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in DATETIME value: ' . $this->_xh['ac']);
643
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid data received in DATETIME value: '.$this->_xh['ac']);
644 644
                     if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
645 645
                     {
646 646
                         $this->_xh['isf'] = 2;
647
-                        $this->_xh['isf_reason'] = 'Invalid data received in DATETIME value: ' . $this->_xh['ac'];
647
+                        $this->_xh['isf_reason'] = 'Invalid data received in DATETIME value: '.$this->_xh['ac'];
648 648
                         return;
649 649
                     }
650 650
                 }
651 651
                 if ($this->current_parsing_options['xmlrpc_return_datetimes']) {
652 652
                     try {
653 653
                         $this->_xh['value'] = new \DateTime($this->_xh['ac']);
654
-                    } catch(\Exception $e) {
654
+                    } catch (\Exception $e) {
655 655
                         // q: what to do? we can not guarantee that a valid date can be created. Return null or throw?
656
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': ' . $e->getMessage());
656
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': '.$e->getMessage());
657 657
                         $this->_xh['value'] = null;
658 658
                     }
659 659
                 } else {
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
                 if ($this->current_parsing_options['xmlrpc_reject_invalid_values']) {
668 668
                     $v = base64_decode($this->_xh['ac'], true);
669 669
                     if ($v === false) {
670
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value');
670
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid data received in BASE64 value');
671 671
                         $this->_xh['isf'] = 2;
672 672
                         $this->_xh['isf_reason'] = 'Invalid data received in BASE64 value';
673 673
                         return;
@@ -676,14 +676,14 @@  discard block
 block discarded – undo
676 676
                     $v = base64_decode($this->_xh['ac']);
677 677
                     if ($v === '' && $this->_xh['ac'] !== '') {
678 678
                         // only the empty string should decode to the empty string
679
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value');
679
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': invalid data received in BASE64 value');
680 680
                     }
681 681
                 }
682 682
                 $this->_xh['value'] = $v;
683 683
                 break;
684 684
 
685 685
             case 'NAME':
686
-                $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac'];
686
+                $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac'];
687 687
                 break;
688 688
 
689 689
             case 'MEMBER':
@@ -693,14 +693,14 @@  discard block
 block discarded – undo
693 693
                     // NB: atm we always initialize members with an empty name in xmlrpc__ee, so no need for this check.
694 694
                     // We could make parsing stricter though...
695 695
                     //if (isset($this->_xh['valuestack'][$vscount - 1]['name'])) {
696
-                        $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value'];
696
+                        $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value'];
697 697
                     //} else {
698 698
                     //    /// @todo return a parsing error if $this->current_parsing_options['xmlrpc_reject_invalid_values']?
699 699
                     //    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing NAME inside STRUCT in received xml');
700 700
                     //}
701 701
                 } else {
702 702
                     /// @todo return a parsing error $this->current_parsing_options['xmlrpc_reject_invalid_values']?
703
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
703
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml');
704 704
                 }
705 705
                 break;
706 706
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
                     $this->_xh['pt'][] = $this->_xh['vt'];
727 727
                 } else {
728 728
                     /// @todo return a parsing error? esp. if if ($this->current_parsing_options['xmlrpc_reject_invalid_values'])
729
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
729
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml');
730 730
                 }
731 731
                 break;
732 732
 
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
     public function xmlrpc_cd($parser, $data)
806 806
     {
807 807
         // skip processing if xml fault already detected
808
-        if ($this->_xh['isf'] >= 2) {
808
+        if ($this->_xh['isf']>=2) {
809 809
             return;
810 810
         }
811 811
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     public function xmlrpc_dh($parser, $data)
828 828
     {
829 829
         // skip processing if xml fault already detected
830
-        if ($this->_xh['isf'] >= 2) {
830
+        if ($this->_xh['isf']>=2) {
831 831
             return;
832 832
         }
833 833
 
@@ -901,8 +901,8 @@  discard block
 block discarded – undo
901 901
         // Details:
902 902
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
903 903
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
904
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
905
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
904
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
905
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
906 906
             $xmlChunk, $matches)) {
907 907
             return strtoupper(substr($matches[2], 1, -1));
908 908
         }
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
             // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
921 921
             // IANA also likes better US-ASCII, so go with it
922 922
             if ($enc == 'ASCII') {
923
-                $enc = 'US-' . $enc;
923
+                $enc = 'US-'.$enc;
924 924
             }
925 925
 
926 926
             return $enc;
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
         // Details:
958 958
         // SPACE:         (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
959 959
         // EQ:            SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
960
-        if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
961
-            '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
960
+        if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
961
+            '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
962 962
             $xmlChunk)) {
963 963
             return true;
964 964
         }
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
                 break;
979 979
             default:
980 980
                 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
981
-                trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING);
981
+                trigger_error('Undefined property via __set(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING);
982 982
         }
983 983
     }
984 984
 
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                 break;
1003 1003
             default:
1004 1004
                 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
1005
-                trigger_error('Undefined property via __unset(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING);
1005
+                trigger_error('Undefined property via __unset(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING);
1006 1006
         }
1007 1007
     }
1008 1008
 }
Please login to merge, or discard this patch.