Passed
Push — master ( f31a58...bb780a )
by Gaetano
09:56
created
demo/server/codegen.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once __DIR__ . "/_prepend.php";
2
+require_once __DIR__."/_prepend.php";
3 3
 
4 4
 require_once __DIR__.'/methodProviders/CommentManager.php';
5 5
 
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
 // generate a file with a class definition
24 24
 
25 25
 // the generated code does not have an autoloader included - we need to add in one
26
-$autoloader = __DIR__ . "/_prepend.php";
26
+$autoloader = __DIR__."/_prepend.php";
27 27
 
28 28
 file_put_contents($targetClassFile,
29
-    "<?php\n\n" .
30
-    "require_once '$autoloader';\n\n" .
29
+    "<?php\n\n".
30
+    "require_once '$autoloader';\n\n".
31 31
     "class MyServerClass\n{\n\n"
32 32
 ) || die('uh oh');
33 33
 
34 34
 // we mangle a bit the code we get from wrapPhpClass to generate a php class instead of a bunch of functions
35 35
 
36
-foreach($code as $methodName => $methodDef) {
37
-    file_put_contents($targetClassFile, '  ' . str_replace(array('function ', "\n"), array('public static function ', "\n  "), $methodDef['source']) . "\n\n", FILE_APPEND) || die('uh oh');
38
-    $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function'];
36
+foreach ($code as $methodName => $methodDef) {
37
+    file_put_contents($targetClassFile, '  '.str_replace(array('function ', "\n"), array('public static function ', "\n  "), $methodDef['source'])."\n\n", FILE_APPEND) || die('uh oh');
38
+    $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function'];
39 39
     unset($code[$methodName]['source']);
40 40
 }
41 41
 file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh');
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 // generate a separate file with the xml-rpc server instantiation and its dispatch map
44 44
 
45 45
 file_put_contents($targetServerFile,
46
-    "<?php\n\n" .
46
+    "<?php\n\n".
47 47
 
48
-    "require_once '$autoloader';\n\n" .
48
+    "require_once '$autoloader';\n\n".
49 49
 
50
-    "require_once '$targetClassFile';\n\n" .
50
+    "require_once '$targetClassFile';\n\n".
51 51
 
52 52
     // NB: since we are running the generated code within the same script, the existing CommentManager instance will be
53 53
     // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     //     Wrapper::holdObject('xmlrpc_CommentManager_addComment', $cm);
58 58
     //     Wrapper::holdObject('xmlrpc_CommentManager_getComments', $cm);
59 59
 
60
-    '$dm = ' . var_export($code, true) . ";\n" .
61
-    '$s = new \PhpXmlRpc\Server($dm, false);' . "\n" .
62
-    '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!' . "\n" .
63
-    '$s->setDebug(2);' . "\n" .
64
-    '$s->exception_handling = 1;' . "\n" .
65
-    '$s->service();' . "\n"
60
+    '$dm = '.var_export($code, true).";\n".
61
+    '$s = new \PhpXmlRpc\Server($dm, false);'."\n".
62
+    '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!'."\n".
63
+    '$s->setDebug(2);'."\n".
64
+    '$s->exception_handling = 1;'."\n".
65
+    '$s->service();'."\n"
66 66
 ) || die('uh oh');
67 67
 
68 68
 // test that everything worked by running it in realtime (note that this will return an xml-rpc error message if run
Please login to merge, or discard this patch.
src/Wrapper.php 2 patches
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
             $callable = explode('::', $callable);
191 191
         }
192 192
         if (is_array($callable)) {
193
-            if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
194
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong');
193
+            if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
194
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong');
195 195
                 return false;
196 196
             }
197 197
             if (is_string($callable[0])) {
198 198
                 $plainFuncName = implode('::', $callable);
199 199
             } elseif (is_object($callable[0])) {
200
-                $plainFuncName = get_class($callable[0]) . '->' . $callable[1];
200
+                $plainFuncName = get_class($callable[0]).'->'.$callable[1];
201 201
             }
202 202
             $exists = method_exists($callable[0], $callable[1]);
203 203
         } else if ($callable instanceof \Closure) {
204 204
             // we do not support creating code which wraps closures, as php does not allow to serialize them
205 205
             if (!$buildIt) {
206
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code');
206
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code');
207 207
                 return false;
208 208
             }
209 209
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         }
216 216
 
217 217
         if (!$exists) {
218
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName);
218
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName);
219 219
             return false;
220 220
         }
221 221
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
         if (is_array($callable)) {
260 260
             $func = new \ReflectionMethod($callable[0], $callable[1]);
261 261
             if ($func->isPrivate()) {
262
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName);
262
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName);
263 263
                 return false;
264 264
             }
265 265
             if ($func->isProtected()) {
266
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName);
266
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName);
267 267
                 return false;
268 268
             }
269 269
             if ($func->isConstructor()) {
270
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName);
270
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName);
271 271
                 return false;
272 272
             }
273 273
             if ($func->isDestructor()) {
274
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName);
274
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName);
275 275
                 return false;
276 276
             }
277 277
             if ($func->isAbstract()) {
278
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName);
278
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName);
279 279
                 return false;
280 280
             }
281 281
             /// @todo add more checks for static vs. nonstatic?
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         if ($func->isInternal()) {
286 286
             /// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully
287 287
             ///       reflect internal php functions
288
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName);
288
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName);
289 289
             return false;
290 290
         }
291 291
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         $i = 0;
338 338
         foreach ($func->getParameters() as $paramObj) {
339 339
             $params[$i] = array();
340
-            $params[$i]['name'] = '$' . $paramObj->getName();
340
+            $params[$i]['name'] = '$'.$paramObj->getName();
341 341
             $params[$i]['isoptional'] = $paramObj->isOptional();
342 342
             $i++;
343 343
         }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             // build a signature
402 402
             $sig = array($this->php2XmlrpcType($funcDesc['returns']));
403 403
             $pSig = array($funcDesc['returnsDocs']);
404
-            for ($i = 0; $i < count($pars); $i++) {
404
+            for ($i = 0; $i<count($pars); $i++) {
405 405
                 $name = strtolower($funcDesc['params'][$i]['name']);
406 406
                 if (isset($funcDesc['paramDocs'][$name]['type'])) {
407 407
                     $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']);
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
                 }
458 458
             }
459 459
             $numPars = $req->getNumParams();
460
-            if ($numPars < $minPars || $numPars > $maxPars) {
460
+            if ($numPars<$minPars || $numPars>$maxPars) {
461 461
                 return new $responseClass(0, 3, 'Incorrect parameters passed to method');
462 462
             }
463 463
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 
471 471
             $result = call_user_func_array($callable, $params);
472 472
 
473
-            if (! is_a($result, $responseClass)) {
473
+            if (!is_a($result, $responseClass)) {
474 474
                 // q: why not do the same for int, float, bool, string?
475 475
                 if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) {
476 476
                     $result = new $valueClass($result, $funcDesc['returns']);
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
         if ($newFuncName == '') {
510 510
             if (is_array($callable)) {
511 511
                 if (is_string($callable[0])) {
512
-                    $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable);
512
+                    $xmlrpcFuncName = "{$prefix}_".implode('_', $callable);
513 513
                 } else {
514
-                    $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1];
514
+                    $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1];
515 515
                 }
516 516
             } else {
517 517
                 if ($callable instanceof \Closure) {
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
      */
544 544
     protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc)
545 545
     {
546
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
547
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
548
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
546
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
547
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
548
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
549 549
         $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : '';
550 550
 
551 551
         $i = 0;
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
         // build body of new function
581 581
 
582 582
         $innerCode = "  \$paramCount = \$req->getNumParams();\n";
583
-        $innerCode .= "  if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n";
583
+        $innerCode .= "  if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n";
584 584
 
585
-        $innerCode .= "  \$encoder = new " . static::$namespace . "Encoder();\n";
585
+        $innerCode .= "  \$encoder = new ".static::$namespace."Encoder();\n";
586 586
         if ($decodePhpObjects) {
587 587
             $innerCode .= "  \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n";
588 588
         } else {
@@ -595,23 +595,23 @@  discard block
 block discarded – undo
595 595
             static::holdObject($newFuncName, $callable[0]);
596 596
             $class = get_class($callable[0]);
597 597
             if ($class[0] !== '\\') {
598
-                $class = '\\' . $class;
598
+                $class = '\\'.$class;
599 599
             }
600 600
             $innerCode .= "  /// @var $class \$obj\n";
601 601
             $innerCode .= "  \$obj = PhpXmlRpc\\Wrapper::getHeldObject('$newFuncName');\n";
602
-            $realFuncName = '$obj->' . $callable[1];
602
+            $realFuncName = '$obj->'.$callable[1];
603 603
         } else {
604 604
             $realFuncName = $plainFuncName;
605 605
         }
606 606
         foreach ($parsVariations as $i => $pars) {
607
-            $innerCode .= "  if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n";
608
-            if ($i < (count($parsVariations) - 1))
607
+            $innerCode .= "  if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n";
608
+            if ($i<(count($parsVariations)-1))
609 609
                 $innerCode .= "  else\n";
610 610
         }
611
-        $innerCode .= "  if (is_a(\$retVal, '" . static::$namespace . "Response'))\n    return \$retVal;\n  else\n";
611
+        $innerCode .= "  if (is_a(\$retVal, '".static::$namespace."Response'))\n    return \$retVal;\n  else\n";
612 612
         /// q: why not do the same for int, float, bool, string?
613 613
         if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) {
614
-            $innerCode .= "    return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));";
614
+            $innerCode .= "    return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));";
615 615
         } else {
616 616
             $encodeOptions = array();
617 617
             if ($encodeNulls) {
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
             }
623 623
 
624 624
             if ($encodeOptions) {
625
-                $innerCode .= "    return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" .
626
-                    implode("', '", $encodeOptions) . "')));";
625
+                $innerCode .= "    return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('".
626
+                    implode("', '", $encodeOptions)."')));";
627 627
             } else {
628
-                $innerCode .= "    return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));";
628
+                $innerCode .= "    return new ".static::$namespace."Response(\$encoder->encode(\$retVal));";
629 629
             }
630 630
         }
631 631
         // shall we exclude functions returning by ref?
632 632
         // if ($func->returnsReference())
633 633
         //     return false;
634 634
 
635
-        $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" .
636
-            "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}";
635
+        $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n".
636
+            "function $newFuncName(\$req)\n{\n".$innerCode."\n}";
637 637
 
638 638
         return $code;
639 639
     }
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
     protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array())
688 688
     {
689 689
         if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) {
690
-            return (isset($extraOptions['prefix']) ?  $extraOptions['prefix'] : '') . $classMethod;
690
+            return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod;
691 691
         }
692 692
 
693 693
         if (is_object($className)) {
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
         } else {
696 696
             $realClassName = $className;
697 697
         }
698
-        return (isset($extraOptions['prefix']) ?  $extraOptions['prefix'] : '') . "$realClassName.$classMethod";
698
+        return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod";
699 699
     }
700 700
 
701 701
     /**
@@ -778,21 +778,21 @@  discard block
 block discarded – undo
778 778
      */
779 779
     protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array())
780 780
     {
781
-        $reqClass = static::$namespace . 'Request';
782
-        $valClass = static::$namespace . 'Value';
783
-        $decoderClass = static::$namespace . 'Encoder';
781
+        $reqClass = static::$namespace.'Request';
782
+        $valClass = static::$namespace.'Value';
783
+        $decoderClass = static::$namespace.'Encoder';
784 784
 
785 785
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
786
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
786
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
787 787
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
788
-        $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0;
788
+        $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0;
789 789
 
790 790
         $req = new $reqClass('system.methodSignature');
791 791
         $req->addparam(new $valClass($methodName));
792 792
         $client->setDebug($debug);
793 793
         $response = $client->send($req, $timeout, $protocol);
794 794
         if ($response->faultCode()) {
795
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName);
795
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName);
796 796
             return false;
797 797
         }
798 798
 
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
             $mSig = $decoder->decode($mSig);
804 804
         }
805 805
 
806
-        if (!is_array($mSig) || count($mSig) <= $sigNum) {
807
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName);
806
+        if (!is_array($mSig) || count($mSig)<=$sigNum) {
807
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName);
808 808
             return false;
809 809
         }
810 810
 
@@ -819,11 +819,11 @@  discard block
 block discarded – undo
819 819
      */
820 820
     protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array())
821 821
     {
822
-        $reqClass = static::$namespace . 'Request';
823
-        $valClass = static::$namespace . 'Value';
822
+        $reqClass = static::$namespace.'Request';
823
+        $valClass = static::$namespace.'Value';
824 824
 
825 825
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
826
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
826
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
827 827
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
828 828
 
829 829
         $mDesc = '';
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
         $clientClone = clone $client;
858 858
         $function = function() use($clientClone, $methodName, $extraOptions, $mSig)
859 859
         {
860
-            $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
860
+            $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
861 861
             $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
862
-            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
863
-            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
864
-            $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
862
+            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
863
+            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
864
+            $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
865 865
             $throwFault = false;
866 866
             $decodeFault = false;
867 867
             $faultResponse = null;
@@ -872,9 +872,9 @@  discard block
 block discarded – undo
872 872
                 $faultResponse = $extraOptions['return_on_fault'];
873 873
             }
874 874
 
875
-            $reqClass = static::$namespace . 'Request';
876
-            $encoderClass = static::$namespace . 'Encoder';
877
-            $valueClass = static::$namespace . 'Value';
875
+            $reqClass = static::$namespace.'Request';
876
+            $encoderClass = static::$namespace.'Encoder';
877
+            $valueClass = static::$namespace.'Value';
878 878
 
879 879
             $encoder = new $encoderClass();
880 880
             $encodeOptions = array();
@@ -956,14 +956,14 @@  discard block
 block discarded – undo
956 956
      * @param string $mDesc
957 957
      * @return string[] keys: source, docstring
958 958
      */
959
-    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='')
959
+    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '')
960 960
     {
961
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
961
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
962 962
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
963
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
964
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
965
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
966
-        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0;
963
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
964
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
965
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
966
+        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0;
967 967
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
968 968
         $throwFault = false;
969 969
         $decodeFault = false;
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
         }
977 977
 
978 978
         $code = "function $newFuncName(";
979
-        if ($clientCopyMode < 2) {
979
+        if ($clientCopyMode<2) {
980 980
             // client copy mode 0 or 1 == full / partial client copy in emitted code
981 981
             $verbatimClientCopy = !$clientCopyMode;
982
-            $innerCode = '  ' . str_replace("\n", "\n  ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace));
982
+            $innerCode = '  '.str_replace("\n", "\n  ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace));
983 983
             $innerCode .= "\$client->setDebug(\$debug);\n";
984 984
             $this_ = '';
985 985
         } else {
@@ -987,28 +987,28 @@  discard block
 block discarded – undo
987 987
             $innerCode = '';
988 988
             $this_ = 'this->';
989 989
         }
990
-        $innerCode .= "  \$req = new " . static::$namespace . "Request('$methodName');\n";
990
+        $innerCode .= "  \$req = new ".static::$namespace."Request('$methodName');\n";
991 991
 
992 992
         if ($mDesc != '') {
993 993
             // take care that PHP comment is not terminated unwillingly by method description
994 994
             /// @todo according to the spec, method desc can have html in it. We should run it through strip_tags...
995
-            $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n";
995
+            $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n";
996 996
         } else {
997 997
             $mDesc = "/**\n * Function $newFuncName.\n";
998 998
         }
999 999
 
1000 1000
         // param parsing
1001
-        $innerCode .= "  \$encoder = new " . static::$namespace . "Encoder();\n";
1001
+        $innerCode .= "  \$encoder = new ".static::$namespace."Encoder();\n";
1002 1002
         $plist = array();
1003 1003
         $pCount = count($mSig);
1004
-        for ($i = 1; $i < $pCount; $i++) {
1004
+        for ($i = 1; $i<$pCount; $i++) {
1005 1005
             $plist[] = "\$p$i";
1006 1006
             $pType = $mSig[$i];
1007 1007
             if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
1008 1008
                 $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
1009 1009
             ) {
1010 1010
                 // only build directly xml-rpc values when type is known and scalar
1011
-                $innerCode .= "  \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n";
1011
+                $innerCode .= "  \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n";
1012 1012
             } else {
1013 1013
                 if ($encodePhpObjects || $encodeNulls) {
1014 1014
                     $encOpts = array();
@@ -1019,26 +1019,26 @@  discard block
 block discarded – undo
1019 1019
                         $encOpts[] = 'null_extension';
1020 1020
                     }
1021 1021
 
1022
-                    $innerCode .= "  \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n";
1022
+                    $innerCode .= "  \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n";
1023 1023
                 } else {
1024 1024
                     $innerCode .= "  \$p$i = \$encoder->encode(\$p$i);\n";
1025 1025
                 }
1026 1026
             }
1027 1027
             $innerCode .= "  \$req->addparam(\$p$i);\n";
1028
-            $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n";
1028
+            $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n";
1029 1029
         }
1030
-        if ($clientCopyMode < 2) {
1030
+        if ($clientCopyMode<2) {
1031 1031
             $plist[] = '$debug = 0';
1032 1032
             $mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
1033 1033
         }
1034 1034
         $plist = implode(', ', $plist);
1035
-        $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]);
1035
+        $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]);
1036 1036
         if ($throwFault) {
1037
-            $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\Exception');
1037
+            $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\Exception');
1038 1038
         } else if ($decodeFault) {
1039
-            $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)";
1039
+            $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)";
1040 1040
         } else {
1041
-            $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)";
1041
+            $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)";
1042 1042
         }
1043 1043
         $mDesc .= "\n */\n";
1044 1044
 
@@ -1050,9 +1050,9 @@  discard block
 block discarded – undo
1050 1050
             $respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())";
1051 1051
         } else if ($decodeFault) {
1052 1052
             if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) {
1053
-                $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')";
1053
+                $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')";
1054 1054
             } else {
1055
-                $respCode = 'return ' . var_export($faultResponse, true);
1055
+                $respCode = 'return '.var_export($faultResponse, true);
1056 1056
             }
1057 1057
         } else {
1058 1058
             $respCode = 'return $res';
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
             $innerCode .= "  if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());";
1064 1064
         }
1065 1065
 
1066
-        $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n";
1066
+        $code = $code.$plist.")\n{\n".$innerCode."\n}\n";
1067 1067
 
1068 1068
         return array('source' => $code, 'docstring' => $mDesc);
1069 1069
     }
@@ -1090,25 +1090,25 @@  discard block
 block discarded – undo
1090 1090
     public function wrapXmlrpcServer($client, $extraOptions = array())
1091 1091
     {
1092 1092
         $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : '';
1093
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
1093
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
1094 1094
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
1095 1095
         $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : '';
1096
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
1097
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
1098
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
1096
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
1097
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
1098
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
1099 1099
         $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true;
1100
-        $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false;
1100
+        $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false;
1101 1101
         $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true;
1102 1102
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
1103 1103
 
1104
-        $reqClass = static::$namespace . 'Request';
1105
-        $decoderClass = static::$namespace . 'Encoder';
1104
+        $reqClass = static::$namespace.'Request';
1105
+        $decoderClass = static::$namespace.'Encoder';
1106 1106
 
1107 1107
         // retrieve the list of methods
1108 1108
         $req = new $reqClass('system.listMethods');
1109 1109
         $response = $client->send($req, $timeout, $protocol);
1110 1110
         if ($response->faultCode()) {
1111
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
1111
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server');
1112 1112
 
1113 1113
             return false;
1114 1114
         }
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
             $mList = $decoder->decode($mList);
1120 1120
         }
1121 1121
         if (!is_array($mList) || !count($mList)) {
1122
-            $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
1122
+            $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server');
1123 1123
 
1124 1124
             return false;
1125 1125
         }
@@ -1128,8 +1128,8 @@  discard block
 block discarded – undo
1128 1128
         if ($newClassName != '') {
1129 1129
             $xmlrpcClassName = $newClassName;
1130 1130
         } else {
1131
-            $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
1132
-                    array('_', ''), $client->server) . '_client';
1131
+            $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
1132
+                    array('_', ''), $client->server).'_client';
1133 1133
         }
1134 1134
         while ($buildIt && class_exists($xmlrpcClassName)) {
1135 1135
             $xmlrpcClassName .= 'x';
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
         /// @todo add method setDebug() to new class, to enable/disable debugging
1139 1139
         $source = "class $xmlrpcClassName\n{\n  public \$client;\n\n";
1140 1140
         $source .= "  function __construct()\n  {\n";
1141
-        $source .= '    ' . str_replace("\n", "\n    ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace));
1141
+        $source .= '    '.str_replace("\n", "\n    ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace));
1142 1142
         $source .= "\$this->client = \$client;\n  }\n\n";
1143 1143
         $opts = array(
1144 1144
             'return_source' => true,
@@ -1161,26 +1161,26 @@  discard block
 block discarded – undo
1161 1161
                 $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts);
1162 1162
                 if ($methodWrap) {
1163 1163
                     if ($buildIt) {
1164
-                        $source .= $methodWrap['source'] . "\n";
1164
+                        $source .= $methodWrap['source']."\n";
1165 1165
 
1166 1166
                     } else {
1167
-                        $source .= '  ' . str_replace("\n", "\n  ", $methodWrap['docstring']);
1168
-                        $source .= str_replace("\n", "\n  ", $methodWrap['source']). "\n";
1167
+                        $source .= '  '.str_replace("\n", "\n  ", $methodWrap['docstring']);
1168
+                        $source .= str_replace("\n", "\n  ", $methodWrap['source'])."\n";
1169 1169
                     }
1170 1170
 
1171 1171
                 } else {
1172
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
1172
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName);
1173 1173
                 }
1174 1174
             }
1175 1175
         }
1176 1176
         $source .= "}\n";
1177 1177
         if ($buildIt) {
1178 1178
             $allOK = 0;
1179
-            eval($source . '$allOK=1;');
1179
+            eval($source.'$allOK=1;');
1180 1180
             if ($allOK) {
1181 1181
                 return $xmlrpcClassName;
1182 1182
             } else {
1183
-                $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server);
1183
+                $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.' to wrap remote server '.$client->server);
1184 1184
                 return false;
1185 1185
             }
1186 1186
         } else {
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
      */
1200 1200
     protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\')
1201 1201
     {
1202
-        $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path) .
1203
-            "', '" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server) . "', $client->port);\n";
1202
+        $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path).
1203
+            "', '".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server)."', $client->port);\n";
1204 1204
 
1205 1205
         // copy all client fields to the client that will be generated runtime
1206 1206
         // (this provides for future expansion or subclassing of client obj)
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -605,8 +605,9 @@
 block discarded – undo
605 605
         }
606 606
         foreach ($parsVariations as $i => $pars) {
607 607
             $innerCode .= "  if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n";
608
-            if ($i < (count($parsVariations) - 1))
609
-                $innerCode .= "  else\n";
608
+            if ($i < (count($parsVariations) - 1)) {
609
+                            $innerCode .= "  else\n";
610
+            }
610 611
         }
611 612
         $innerCode .= "  if (is_a(\$retVal, '" . static::$namespace . "Response'))\n    return \$retVal;\n  else\n";
612 613
         /// q: why not do the same for int, float, bool, string?
Please login to merge, or discard this patch.