Passed
Push — master ( 2b7078...5a0906 )
by Gaetano
07:50
created
demo/client/introspect.php 1 patch
Spacing   +9 added lines, -9 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
 output('<html lang="en">
5 5
 <head><title>phpxmlrpc - Introspect demo</title></head>
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 function display_error($r)
19 19
 {
20 20
     output("An error occurred: ");
21
-    output("Code: " . $r->faultCode() . " Reason: '" . $r->faultString() . "'<br/>");
21
+    output("Code: ".$r->faultCode()." Reason: '".$r->faultString()."'<br/>");
22 22
 }
23 23
 
24 24
 $client = new Client(XMLRPCSERVER);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $client->setOption(Client::OPT_RETURN_TYPE, XMLRPCParser::RETURN_PHP);
27 27
 
28 28
 // First off, let's retrieve the list of methods available on the remote server
29
-output("<h3>methods available at http://" . $client->getUrl(PHP_URL_HOST) . $client->getUrl(PHP_URL_PATH) . "</h3>\n");
29
+output("<h3>methods available at http://".$client->getUrl(PHP_URL_HOST).$client->getUrl(PHP_URL_PATH)."</h3>\n");
30 30
 $req = new Request('system.listMethods');
31 31
 $resp = $client->send($req);
32 32
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     // Then, retrieve the signature and help text of each available method
50 50
     foreach ($v as $methodName) {
51
-        output("<h4>" . htmlspecialchars($methodName) . "</h4>\n");
51
+        output("<h4>".htmlspecialchars($methodName)."</h4>\n");
52 52
         // build requests first, add params later
53 53
         $r1 = new Request('system.methodHelp');
54 54
         $r2 = new Request('system.methodSignature');
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
                         continue;
85 85
                     }
86 86
                     $ret = $sig[0];
87
-                    output("<code>" . htmlspecialchars($ret) . " "
88
-                        . htmlspecialchars($methodName) . "(");
89
-                    if (count($sig) > 1) {
90
-                        for ($k = 1; $k < count($sig); $k++) {
87
+                    output("<code>".htmlspecialchars($ret)." "
88
+                        . htmlspecialchars($methodName)."(");
89
+                    if (count($sig)>1) {
90
+                        for ($k = 1; $k<count($sig); $k++) {
91 91
                             output(htmlspecialchars($sig[$k]));
92
-                            if ($k < count($sig) - 1) {
92
+                            if ($k<count($sig)-1) {
93 93
                                 output(", ");
94 94
                             }
95 95
                         }
Please login to merge, or discard this patch.
demo/client/which.php 1 patch
Spacing   +8 added lines, -8 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
 output('<html lang="en">
5 5
 <head><title>phpxmlrpc - Which toolkit demo</title></head>
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     <methodName>interopEchoTests.whichToolkit</methodName>
20 20
     <params/>
21 21
 </methodCall>';
22
-output("XML custom request:<br/><pre>" . htmlspecialchars($payload) . "</pre>\n");
22
+output("XML custom request:<br/><pre>".htmlspecialchars($payload)."</pre>\n");
23 23
 
24 24
 $client = new Client(XMLRPCSERVER);
25 25
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 if (!$resp->faultCode()) {
41 41
 
42 42
     $xml = $resp->value();
43
-    output("XML response:<br/><pre>" . htmlspecialchars($xml) . "</pre>\n");
43
+    output("XML response:<br/><pre>".htmlspecialchars($xml)."</pre>\n");
44 44
 
45 45
     $encoder = new Encoder();
46 46
     // from xml to xml-rpc Response
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 
54 54
         output("Toolkit info:<br/>\n");
55 55
         output("<pre>");
56
-        output("name: " . htmlspecialchars($value["toolkitName"]) . "\n");
57
-        output("version: " . htmlspecialchars($value["toolkitVersion"]) . "\n");
58
-        output("docs: " . htmlspecialchars($value["toolkitDocsUrl"]) . "\n");
59
-        output("os: " . htmlspecialchars($value["toolkitOperatingSystem"]) . "\n");
56
+        output("name: ".htmlspecialchars($value["toolkitName"])."\n");
57
+        output("version: ".htmlspecialchars($value["toolkitVersion"])."\n");
58
+        output("docs: ".htmlspecialchars($value["toolkitDocsUrl"])."\n");
59
+        output("os: ".htmlspecialchars($value["toolkitOperatingSystem"])."\n");
60 60
         output("</pre>");
61 61
     } else {
62 62
         output("An xml-rpc error occurred");
63 63
     }
64 64
 } else {
65 65
     output("An http error occurred: ");
66
-    output("Code: " . htmlspecialchars($resp->faultCode()) . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n");
66
+    output("Code: ".htmlspecialchars($resp->faultCode())." Reason: '".htmlspecialchars($resp->faultString())."'\n");
67 67
 }
68 68
 
69 69
 output("</body></html>\n");
Please login to merge, or discard this patch.
demo/client/parallel.php 1 patch
Spacing   +26 added lines, -26 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
 use PhpXmlRpc\Encoder;
5 5
 use PhpXmlRpc\Client;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $handles = array();
36 36
         $curl = curl_multi_init();
37 37
 
38
-        foreach($requests as $k => $req) {
38
+        foreach ($requests as $k => $req) {
39 39
             $req->setDebug($this->debug);
40 40
             $handle = $this->createCurlHandle($req, $method, $this->server, $this->port, $this->path, $opts);
41 41
             if (($error = curl_multi_add_handle($curl, $handle)) !== 0) {
@@ -60,27 +60,27 @@  discard block
 block discarded – undo
60 60
                     }
61 61
                 }
62 62
             }
63
-            if ($running > 0) {
63
+            if ($running>0) {
64 64
                 if (curl_multi_select($curl) === -1) {
65 65
                     throw new \Exception("Curl multi error");
66 66
                 }
67 67
             }
68
-        } while ($running > 0);
68
+        } while ($running>0);
69 69
 
70 70
         curl_multi_close($curl);
71 71
 
72 72
         $responses = array();
73 73
         $errors = array();
74
-        foreach($handles as $k => $h) {
74
+        foreach ($handles as $k => $h) {
75 75
             $responses[$k] = curl_multi_getcontent($h);
76 76
 
77
-            if ($this->debug > 1) {
77
+            if ($this->debug>1) {
78 78
                 $message = "---CURL INFO---\n";
79 79
                 foreach (curl_getinfo($h) as $name => $val) {
80 80
                     if (is_array($val)) {
81 81
                         $val = implode("\n", $val);
82 82
                     }
83
-                    $message .= $name . ': ' . $val . "\n";
83
+                    $message .= $name.': '.$val."\n";
84 84
                 }
85 85
                 $message .= '---END---';
86 86
                 $this->getLogger()->debugMessage($message);
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
             }
92 92
         }
93 93
 
94
-        foreach($responses as $k => $resp) {
94
+        foreach ($responses as $k => $resp) {
95 95
             if (!$resp) {
96
-                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . $errors[$k]);
96
+                $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.$errors[$k]);
97 97
             } else {
98 98
                 $responses[$k] = $requests[$k]->parseResponse($resp, true, $this->return_type);
99 99
             }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 $encoder = new Encoder();
112 112
 $reqs = array();
113
-for ($i = 0; $i < $num_tests; $i++) {
113
+for ($i = 0; $i<$num_tests; $i++) {
114 114
     $data = array($i, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00');
115 115
     $value = $encoder->encode($data, array('auto_dates'));
116 116
     $req = new Request('interopEchoTests.echoValue', array($value));
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
 // avoid storing http info in the responses, to make the checksums comparable
123 123
 $client->setDebug(-1);
124 124
 
125
-echo "Making $num_tests calls to method interopEchoTests.echoValue on server " . XMLRPCSERVER . " ...\n";
125
+echo "Making $num_tests calls to method interopEchoTests.echoValue on server ".XMLRPCSERVER." ...\n";
126 126
 flush();
127 127
 
128
-$client->setOption(Client::OPT_NO_MULTICALL,  true);
128
+$client->setOption(Client::OPT_NO_MULTICALL, true);
129 129
 $t = microtime(true);
130 130
 $resp = $client->send($reqs);
131
-$t = microtime(true) - $t;
132
-echo "Sequential send: " . sprintf('%.3f', $t) . " secs.\n";
133
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
131
+$t = microtime(true)-$t;
132
+echo "Sequential send: ".sprintf('%.3f', $t)." secs.\n";
133
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
134 134
 flush();
135 135
 
136 136
 if (strpos(XMLRPCSERVER, 'http://') === 0) {
137
-    $client->setOption(Client::OPT_USE_CURL,  Client::USE_CURL_ALWAYS);
137
+    $client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_ALWAYS);
138 138
     $t = microtime(true);
139 139
     $resp = $client->send($reqs);
140
-    $t = microtime(true) - $t;
141
-    echo "Sequential send, curl (w. keepalive): " . sprintf('%.3f', $t) . " secs.\n";
142
-    echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
140
+    $t = microtime(true)-$t;
141
+    echo "Sequential send, curl (w. keepalive): ".sprintf('%.3f', $t)." secs.\n";
142
+    echo "Response checksum: ".md5(var_export($resp, true))."\n";
143 143
     flush();
144 144
 }
145 145
 
146 146
 $t = microtime(true);
147 147
 $resp = $client->sendParallel($reqs);
148
-$t = microtime(true) - $t;
149
-echo "Parallel send: " . sprintf('%.3f', $t) . " secs.\n";
150
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
148
+$t = microtime(true)-$t;
149
+echo "Parallel send: ".sprintf('%.3f', $t)." secs.\n";
150
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
151 151
 flush();
152 152
 
153 153
 $client->setOption(Client::OPT_NO_MULTICALL, false);
154 154
 // make sure we don't reuse the keepalive handle
155
-$client->setOption(Client::OPT_USE_CURL,  Client::USE_CURL_NEVER);
155
+$client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_NEVER);
156 156
 $t = microtime(true);
157 157
 $resp = $client->send($reqs);
158
-$t = microtime(true) - $t;
159
-echo "Multicall send: " . sprintf('%.3f', $t) . " secs.\n";
160
-echo "Response checksum: " . md5(var_export($resp, true)) . "\n";
158
+$t = microtime(true)-$t;
159
+echo "Multicall send: ".sprintf('%.3f', $t)." secs.\n";
160
+echo "Response checksum: ".md5(var_export($resp, true))."\n";
161 161
 flush();
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
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
             $callable = explode('::', $callable);
177 177
         }
178 178
         if (is_array($callable)) {
179
-            if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
180
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong');
179
+            if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
180
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong');
181 181
                 return false;
182 182
             }
183 183
             if (is_string($callable[0])) {
184 184
                 $plainFuncName = implode('::', $callable);
185 185
             } elseif (is_object($callable[0])) {
186
-                $plainFuncName = get_class($callable[0]) . '->' . $callable[1];
186
+                $plainFuncName = get_class($callable[0]).'->'.$callable[1];
187 187
             }
188 188
             $exists = method_exists($callable[0], $callable[1]);
189 189
         } else if ($callable instanceof \Closure) {
190 190
             // we do not support creating code which wraps closures, as php does not allow to serialize them
191 191
             if (!$buildIt) {
192
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code');
192
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code');
193 193
                 return false;
194 194
             }
195 195
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         }
202 202
 
203 203
         if (!$exists) {
204
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName);
204
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName);
205 205
             return false;
206 206
         }
207 207
 
@@ -245,23 +245,23 @@  discard block
 block discarded – undo
245 245
         if (is_array($callable)) {
246 246
             $func = new \ReflectionMethod($callable[0], $callable[1]);
247 247
             if ($func->isPrivate()) {
248
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName);
248
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName);
249 249
                 return false;
250 250
             }
251 251
             if ($func->isProtected()) {
252
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName);
252
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName);
253 253
                 return false;
254 254
             }
255 255
             if ($func->isConstructor()) {
256
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName);
256
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName);
257 257
                 return false;
258 258
             }
259 259
             if ($func->isDestructor()) {
260
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName);
260
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName);
261 261
                 return false;
262 262
             }
263 263
             if ($func->isAbstract()) {
264
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName);
264
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName);
265 265
                 return false;
266 266
             }
267 267
             /// @todo add more checks for static vs. nonstatic?
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         if ($func->isInternal()) {
272 272
             /// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully
273 273
             ///       reflect internal php functions
274
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName);
274
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName);
275 275
             return false;
276 276
         }
277 277
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $i = 0;
332 332
         foreach ($func->getParameters() as $paramObj) {
333 333
             $params[$i] = array();
334
-            $params[$i]['name'] = '$' . $paramObj->getName();
334
+            $params[$i]['name'] = '$'.$paramObj->getName();
335 335
             $params[$i]['isoptional'] = $paramObj->isOptional();
336 336
             if (method_exists($paramObj, 'getType')) {
337 337
                 $paramType = $paramObj->getType();
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             // build a signature
403 403
             $sig = array($this->php2XmlrpcType($funcDesc['returns']));
404 404
             $pSig = array($funcDesc['returnsDocs']);
405
-            for ($i = 0; $i < count($pars); $i++) {
405
+            for ($i = 0; $i<count($pars); $i++) {
406 406
                 $name = strtolower($funcDesc['params'][$i]['name']);
407 407
                 if (isset($funcDesc['paramDocs'][$name]['type'])) {
408 408
                     $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                 }
459 459
             }
460 460
             $numPars = $req->getNumParams();
461
-            if ($numPars < $minPars || $numPars > $maxPars) {
461
+            if ($numPars<$minPars || $numPars>$maxPars) {
462 462
                 return new $responseClass(0, 3, 'Incorrect parameters passed to method');
463 463
             }
464 464
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             $result = call_user_func_array($callable, $params);
473 473
 
474 474
 /// @todo when namespaces is under PhpXmlRpc, use root-class checking
475
-            if (! is_a($result, $responseClass)) {
475
+            if (!is_a($result, $responseClass)) {
476 476
                 // q: why not do the same for int, float, bool, string?
477 477
                 if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) {
478 478
                     $result = new $valueClass($result, $funcDesc['returns']);
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
         if ($newFuncName == '') {
512 512
             if (is_array($callable)) {
513 513
                 if (is_string($callable[0])) {
514
-                    $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable);
514
+                    $xmlrpcFuncName = "{$prefix}_".implode('_', $callable);
515 515
                 } else {
516
-                    $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1];
516
+                    $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1];
517 517
                 }
518 518
             } else {
519 519
                 if ($callable instanceof \Closure) {
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
      */
546 546
     protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc)
547 547
     {
548
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
549
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
550
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
548
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
549
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
550
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
551 551
         $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : '';
552 552
 
553 553
         $i = 0;
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
         // build body of new function
583 583
 
584 584
         $innerCode = "  \$paramCount = \$req->getNumParams();\n";
585
-        $innerCode .= "  if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n";
585
+        $innerCode .= "  if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n";
586 586
 
587
-        $innerCode .= "  \$encoder = new " . static::$namespace . "Encoder();\n";
587
+        $innerCode .= "  \$encoder = new ".static::$namespace."Encoder();\n";
588 588
         if ($decodePhpObjects) {
589 589
             $innerCode .= "  \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n";
590 590
         } else {
@@ -598,24 +598,24 @@  discard block
 block discarded – undo
598 598
             static::holdObject($newFuncName, $callable[0]);
599 599
             $class = get_class($callable[0]);
600 600
             if ($class[0] !== '\\') {
601
-                $class = '\\' . $class;
601
+                $class = '\\'.$class;
602 602
             }
603 603
             $innerCode .= "  /// @var $class \$obj\n";
604 604
             $innerCode .= "  \$obj = PhpXmlRpc\\Wrapper::getHeldObject('$newFuncName');\n";
605
-            $realFuncName = '$obj->' . $callable[1];
605
+            $realFuncName = '$obj->'.$callable[1];
606 606
         } else {
607 607
             $realFuncName = $plainFuncName;
608 608
         }
609 609
         foreach ($parsVariations as $i => $pars) {
610
-            $innerCode .= "  if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n";
611
-            if ($i < (count($parsVariations) - 1))
610
+            $innerCode .= "  if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n";
611
+            if ($i<(count($parsVariations)-1))
612 612
                 $innerCode .= "  else\n";
613 613
         }
614 614
 /// @todo here we should (could?) check for PhpXmlRpc/Response when dealing with a subclass namespace
615
-        $innerCode .= "  if (is_a(\$retVal, '" . static::$namespace . "Response'))\n    return \$retVal;\n  else\n";
615
+        $innerCode .= "  if (is_a(\$retVal, '".static::$namespace."Response'))\n    return \$retVal;\n  else\n";
616 616
         /// q: why not do the same for int, float, bool, string?
617 617
         if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) {
618
-            $innerCode .= "    return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));";
618
+            $innerCode .= "    return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));";
619 619
         } else {
620 620
             $encodeOptions = array();
621 621
             if ($encodeNulls) {
@@ -626,18 +626,18 @@  discard block
 block discarded – undo
626 626
             }
627 627
 
628 628
             if ($encodeOptions) {
629
-                $innerCode .= "    return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" .
630
-                    implode("', '", $encodeOptions) . "')));";
629
+                $innerCode .= "    return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('".
630
+                    implode("', '", $encodeOptions)."')));";
631 631
             } else {
632
-                $innerCode .= "    return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));";
632
+                $innerCode .= "    return new ".static::$namespace."Response(\$encoder->encode(\$retVal));";
633 633
             }
634 634
         }
635 635
         // shall we exclude functions returning by ref?
636 636
         // if ($func->returnsReference())
637 637
         //     return false;
638 638
 
639
-        $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" .
640
-            "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}";
639
+        $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n".
640
+            "function $newFuncName(\$req)\n{\n".$innerCode."\n}";
641 641
 
642 642
         return $code;
643 643
     }
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
     protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array())
698 698
     {
699 699
         if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) {
700
-            return (isset($extraOptions['prefix']) ?  $extraOptions['prefix'] : '') . $classMethod;
700
+            return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod;
701 701
         }
702 702
 
703 703
         if (is_object($className)) {
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
         } else {
706 706
             $realClassName = $className;
707 707
         }
708
-        return (isset($extraOptions['prefix']) ?  $extraOptions['prefix'] : '') . "$realClassName.$classMethod";
708
+        return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod";
709 709
     }
710 710
 
711 711
     /**
@@ -801,14 +801,14 @@  discard block
 block discarded – undo
801 801
      */
802 802
     protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array())
803 803
     {
804
-        $reqClass = static::$namespace . 'Request';
805
-        $valClass = static::$namespace . 'Value';
806
-        $decoderClass = static::$namespace . 'Encoder';
804
+        $reqClass = static::$namespace.'Request';
805
+        $valClass = static::$namespace.'Value';
806
+        $decoderClass = static::$namespace.'Encoder';
807 807
 
808 808
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
809
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
809
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
810 810
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
811
-        $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0;
811
+        $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0;
812 812
 
813 813
         $req = new $reqClass('system.methodSignature');
814 814
         $req->addParam(new $valClass($methodName));
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
         $response = $client->send($req, $timeout, $protocol);
819 819
         $client->setDebug($origDebug);
820 820
         if ($response->faultCode()) {
821
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName);
821
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName);
822 822
             return false;
823 823
         }
824 824
 
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
             $mSig = $decoder->decode($mSig);
830 830
         }
831 831
 
832
-        if (!is_array($mSig) || count($mSig) <= $sigNum) {
833
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName);
832
+        if (!is_array($mSig) || count($mSig)<=$sigNum) {
833
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName);
834 834
             return false;
835 835
         }
836 836
 
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
      */
846 846
     protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array())
847 847
     {
848
-        $reqClass = static::$namespace . 'Request';
849
-        $valClass = static::$namespace . 'Value';
848
+        $reqClass = static::$namespace.'Request';
849
+        $valClass = static::$namespace.'Value';
850 850
 
851 851
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
852
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
852
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
853 853
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
854 854
 
855 855
         $mDesc = '';
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
         $clientClone = $this->cloneClientForClosure($client);
887 887
         $function = function() use($clientClone, $methodName, $extraOptions, $mSig)
888 888
         {
889
-            $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
889
+            $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
890 890
             $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
891
-            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
892
-            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
893
-            $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
891
+            $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
892
+            $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
893
+            $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
894 894
             $throwFault = false;
895 895
             $decodeFault = false;
896 896
             $faultResponse = null;
@@ -901,9 +901,9 @@  discard block
 block discarded – undo
901 901
                 $faultResponse = $extraOptions['return_on_fault'];
902 902
             }
903 903
 
904
-            $reqClass = static::$namespace . 'Request';
905
-            $encoderClass = static::$namespace . 'Encoder';
906
-            $valueClass = static::$namespace . 'Value';
904
+            $reqClass = static::$namespace.'Request';
905
+            $encoderClass = static::$namespace.'Encoder';
906
+            $valueClass = static::$namespace.'Value';
907 907
 
908 908
             $encoder = new $encoderClass();
909 909
             $encodeOptions = array();
@@ -985,14 +985,14 @@  discard block
 block discarded – undo
985 985
      * @param string $mDesc
986 986
      * @return string[] keys: source, docstring
987 987
      */
988
-    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='')
988
+    public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '')
989 989
     {
990
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
990
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
991 991
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
992
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
993
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
994
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
995
-        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0;
992
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
993
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
994
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
995
+        $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0;
996 996
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix;
997 997
         $clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix;
998 998
         $throwFault = false;
@@ -1006,10 +1006,10 @@  discard block
 block discarded – undo
1006 1006
         }
1007 1007
 
1008 1008
         $code = "function $newFuncName(";
1009
-        if ($clientCopyMode < 2) {
1009
+        if ($clientCopyMode<2) {
1010 1010
             // client copy mode 0 or 1 == full / partial client copy in emitted code
1011 1011
             $verbatimClientCopy = !$clientCopyMode;
1012
-            $innerCode = '  ' . str_replace("\n", "\n  ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace));
1012
+            $innerCode = '  '.str_replace("\n", "\n  ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace));
1013 1013
             $innerCode .= "\$client->setDebug(\$debug);\n";
1014 1014
             $this_ = '';
1015 1015
         } else {
@@ -1017,28 +1017,28 @@  discard block
 block discarded – undo
1017 1017
             $innerCode = '';
1018 1018
             $this_ = 'this->';
1019 1019
         }
1020
-        $innerCode .= "  \$req = new " . static::$namespace . "Request('$methodName');\n";
1020
+        $innerCode .= "  \$req = new ".static::$namespace."Request('$methodName');\n";
1021 1021
 
1022 1022
         if ($mDesc != '') {
1023 1023
             // take care that PHP comment is not terminated unwillingly by method description
1024 1024
             /// @todo according to the spec, method desc can have html in it. We should run it through strip_tags...
1025
-            $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n";
1025
+            $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n";
1026 1026
         } else {
1027 1027
             $mDesc = "/**\n * Function $newFuncName.\n";
1028 1028
         }
1029 1029
 
1030 1030
         // param parsing
1031
-        $innerCode .= "  \$encoder = new " . static::$namespace . "Encoder();\n";
1031
+        $innerCode .= "  \$encoder = new ".static::$namespace."Encoder();\n";
1032 1032
         $plist = array();
1033 1033
         $pCount = count($mSig);
1034
-        for ($i = 1; $i < $pCount; $i++) {
1034
+        for ($i = 1; $i<$pCount; $i++) {
1035 1035
             $plist[] = "\$p$i";
1036 1036
             $pType = $mSig[$i];
1037 1037
             if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
1038 1038
                 $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
1039 1039
             ) {
1040 1040
                 // only build directly xml-rpc values when type is known and scalar
1041
-                $innerCode .= "  \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n";
1041
+                $innerCode .= "  \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n";
1042 1042
             } else {
1043 1043
                 if ($encodePhpObjects || $encodeNulls) {
1044 1044
                     $encOpts = array();
@@ -1049,26 +1049,26 @@  discard block
 block discarded – undo
1049 1049
                         $encOpts[] = 'null_extension';
1050 1050
                     }
1051 1051
 
1052
-                    $innerCode .= "  \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n";
1052
+                    $innerCode .= "  \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n";
1053 1053
                 } else {
1054 1054
                     $innerCode .= "  \$p$i = \$encoder->encode(\$p$i);\n";
1055 1055
                 }
1056 1056
             }
1057 1057
             $innerCode .= "  \$req->addParam(\$p$i);\n";
1058
-            $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n";
1058
+            $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n";
1059 1059
         }
1060
-        if ($clientCopyMode < 2) {
1060
+        if ($clientCopyMode<2) {
1061 1061
             $plist[] = '$debug = 0';
1062 1062
             $mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
1063 1063
         }
1064 1064
         $plist = implode(', ', $plist);
1065
-        $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]);
1065
+        $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]);
1066 1066
         if ($throwFault) {
1067
-            $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception');
1067
+            $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception');
1068 1068
         } else if ($decodeFault) {
1069
-            $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)";
1069
+            $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)";
1070 1070
         } else {
1071
-            $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)";
1071
+            $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)";
1072 1072
         }
1073 1073
         $mDesc .= "\n */\n";
1074 1074
 
@@ -1081,9 +1081,9 @@  discard block
 block discarded – undo
1081 1081
             $respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())";
1082 1082
         } else if ($decodeFault) {
1083 1083
             if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) {
1084
-                $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')";
1084
+                $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')";
1085 1085
             } else {
1086
-                $respCode = 'return ' . var_export($faultResponse, true);
1086
+                $respCode = 'return '.var_export($faultResponse, true);
1087 1087
             }
1088 1088
         } else {
1089 1089
             $respCode = 'return $res';
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
             $innerCode .= "  if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());";
1095 1095
         }
1096 1096
 
1097
-        $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n";
1097
+        $code = $code.$plist.")\n{\n".$innerCode."\n}\n";
1098 1098
 
1099 1099
         return array('source' => $code, 'docstring' => $mDesc);
1100 1100
     }
@@ -1124,27 +1124,27 @@  discard block
 block discarded – undo
1124 1124
     public function wrapXmlrpcServer($client, $extraOptions = array())
1125 1125
     {
1126 1126
         $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : '';
1127
-        $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
1127
+        $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0;
1128 1128
         $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
1129 1129
         $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : '';
1130
-        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false;
1131
-        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
1132
-        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
1130
+        $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false;
1131
+        $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false;
1132
+        $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false;
1133 1133
         $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true;
1134
-        $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false;
1134
+        $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false;
1135 1135
         $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true;
1136 1136
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : static::$prefix;
1137 1137
         $clientReturnType = isset($extraOptions['client_return_type']) ? $extraOptions['client_return_type'] : $prefix;
1138 1138
 
1139
-        $reqClass = static::$namespace . 'Request';
1140
-        $decoderClass = static::$namespace . 'Encoder';
1139
+        $reqClass = static::$namespace.'Request';
1140
+        $decoderClass = static::$namespace.'Encoder';
1141 1141
 
1142 1142
         // retrieve the list of methods
1143 1143
         $req = new $reqClass('system.listMethods');
1144 1144
         /// @todo move setting of timeout, protocol to outside the send() call
1145 1145
         $response = $client->send($req, $timeout, $protocol);
1146 1146
         if ($response->faultCode()) {
1147
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
1147
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server');
1148 1148
 
1149 1149
             return false;
1150 1150
         }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
             $mList = $decoder->decode($mList);
1156 1156
         }
1157 1157
         if (!is_array($mList) || !count($mList)) {
1158
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
1158
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server');
1159 1159
 
1160 1160
             return false;
1161 1161
         }
@@ -1165,8 +1165,8 @@  discard block
 block discarded – undo
1165 1165
             $xmlrpcClassName = $newClassName;
1166 1166
         } else {
1167 1167
             /// @todo direct access to $client->server is now deprecated
1168
-            $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''),
1169
-                $client->server) . '_client';
1168
+            $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), array('_', ''),
1169
+                $client->server).'_client';
1170 1170
         }
1171 1171
         while ($buildIt && class_exists($xmlrpcClassName)) {
1172 1172
             $xmlrpcClassName .= 'x';
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 
1175 1175
         $source = "class $xmlrpcClassName\n{\n  public \$client;\n\n";
1176 1176
         $source .= "  function __construct()\n  {\n";
1177
-        $source .= '    ' . str_replace("\n", "\n    ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace));
1177
+        $source .= '    '.str_replace("\n", "\n    ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $clientReturnType, static::$namespace));
1178 1178
         $source .= "\$this->client = \$client;\n  }\n\n";
1179 1179
         $opts = array(
1180 1180
             'return_source' => true,
@@ -1197,28 +1197,28 @@  discard block
 block discarded – undo
1197 1197
                 $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts);
1198 1198
                 if ($methodWrap) {
1199 1199
                     if ($buildIt) {
1200
-                        $source .= $methodWrap['source'] . "\n";
1200
+                        $source .= $methodWrap['source']."\n";
1201 1201
 
1202 1202
                     } else {
1203
-                        $source .= '  ' . str_replace("\n", "\n  ", $methodWrap['docstring']);
1204
-                        $source .= str_replace("\n", "\n  ", $methodWrap['source']). "\n";
1203
+                        $source .= '  '.str_replace("\n", "\n  ", $methodWrap['docstring']);
1204
+                        $source .= str_replace("\n", "\n  ", $methodWrap['source'])."\n";
1205 1205
                     }
1206 1206
 
1207 1207
                 } else {
1208
-                    $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
1208
+                    $this->getLogger()->error('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName);
1209 1209
                 }
1210 1210
             }
1211 1211
         }
1212 1212
         $source .= "}\n";
1213 1213
         if ($buildIt) {
1214 1214
             $allOK = 0;
1215
-            eval($source . '$allOK=1;');
1215
+            eval($source.'$allOK=1;');
1216 1216
             if ($allOK) {
1217 1217
                 return $xmlrpcClassName;
1218 1218
             } else {
1219 1219
                 /// @todo direct access to $client->server is now deprecated
1220
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName .
1221
-                    ' to wrap remote server ' . $client->server);
1220
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.
1221
+                    ' to wrap remote server '.$client->server);
1222 1222
                 return false;
1223 1223
             }
1224 1224
         } else {
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
      */
1238 1238
     protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\')
1239 1239
     {
1240
-        $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()) .
1240
+        $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->getUrl()).
1241 1241
             "');\n";
1242 1242
 
1243 1243
         // copy all client fields to the client that will be generated runtime
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -608,8 +608,9 @@
 block discarded – undo
608 608
         }
609 609
         foreach ($parsVariations as $i => $pars) {
610 610
             $innerCode .= "  if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n";
611
-            if ($i < (count($parsVariations) - 1))
612
-                $innerCode .= "  else\n";
611
+            if ($i < (count($parsVariations) - 1)) {
612
+                            $innerCode .= "  else\n";
613
+            }
613 614
         }
614 615
 /// @todo here we should (could?) check for PhpXmlRpc/Response when dealing with a subclass namespace
615 616
         $innerCode .= "  if (is_a(\$retVal, '" . static::$namespace . "Response'))\n    return \$retVal;\n  else\n";
Please login to merge, or discard this patch.
demo/server/codegen.php 1 patch
Spacing   +25 added lines, -25 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
 /**
5 5
  * Demoing the code-generation capabilities of the library: create all that is required to expose as xml-rpc methods
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 if (isset($_GET['generate']) && $_GET['generate']) {
16 16
 // CommentManager is the "xml-rpc-unaware" class, whose methods we want to make accessible via xml-rpc calls
17
-$cm = new CommentManager(sys_get_temp_dir() . "/comments.db");
17
+$cm = new CommentManager(sys_get_temp_dir()."/comments.db");
18 18
 
19 19
 // analyze the CommentManager instance and generate both code defining stub-methods and a dispatch map for the xml-rpc Server
20 20
 $w = new Wrapper();
@@ -32,55 +32,55 @@  discard block
 block discarded – undo
32 32
 // and a controller, to be accessed from the internet. This split allows to a) hand-edit the controller code if needed,
33 33
 // and b) later regenerate the stub-methods-holder and dispatch map without touching the controller.
34 34
 // NB: good security practices dictate that none of those files should be writeable by the webserver user account
35
-$targetClassFile = sys_get_temp_dir() . '/MyServerClass.php';
36
-$targetDispatchMapFile = sys_get_temp_dir() . '/myServerDispatchMap.php';
37
-$targetControllerFile = sys_get_temp_dir() . '/myServerController.php';
35
+$targetClassFile = sys_get_temp_dir().'/MyServerClass.php';
36
+$targetDispatchMapFile = sys_get_temp_dir().'/myServerDispatchMap.php';
37
+$targetControllerFile = sys_get_temp_dir().'/myServerController.php';
38 38
 
39 39
 // generate a file with a class definition
40 40
 
41 41
 // the generated code does not have an autoloader included - we need to add in one
42
-$autoloader = __DIR__ . "/_prepend.php";
42
+$autoloader = __DIR__."/_prepend.php";
43 43
 
44 44
 file_put_contents($targetClassFile,
45
-    "<?php\n\n" .
46
-    "require_once '$autoloader';\n\n" .
45
+    "<?php\n\n".
46
+    "require_once '$autoloader';\n\n".
47 47
     "class MyServerClass\n{\n\n"
48 48
 ) || die('uh oh');
49 49
 
50 50
 // we mangle a bit the code we get from wrapPhpClass to turn it into a php class definition instead of a bunch of functions
51 51
 
52 52
 foreach ($code as $methodName => $methodDef) {
53
-    file_put_contents($targetClassFile, '  ' . str_replace(array('function ', "\n"), array('public static function ', "\n  "), $methodDef['source']) . "\n\n", FILE_APPEND) || die('uh oh');
54
-    $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function'];
53
+    file_put_contents($targetClassFile, '  '.str_replace(array('function ', "\n"), array('public static function ', "\n  "), $methodDef['source'])."\n\n", FILE_APPEND) || die('uh oh');
54
+    $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function'];
55 55
     unset($code[$methodName]['source']);
56 56
 }
57 57
 file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh');
58 58
 
59 59
 // generate separate files with the xml-rpc server instantiation and its dispatch map
60 60
 
61
-file_put_contents($targetDispatchMapFile, "<?php\n\nreturn " . var_export($code, true) . ";\n");
61
+file_put_contents($targetDispatchMapFile, "<?php\n\nreturn ".var_export($code, true).";\n");
62 62
 
63 63
 file_put_contents($targetControllerFile,
64
-    "<?php\n\n" .
64
+    "<?php\n\n".
65 65
 
66
-    "// autoloader\n" .
67
-    "require_once '$autoloader';\n\n" .
66
+    "// autoloader\n".
67
+    "require_once '$autoloader';\n\n".
68 68
 
69
-    "require_once '$targetClassFile';\n\n" .
69
+    "require_once '$targetClassFile';\n\n".
70 70
 
71 71
         // NB: if we were running the generated code within the same script, the existing CommentManager instance would be
72 72
         // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder,
73 73
         // but since we are generating a php file for later use, it is up to us to initialize that variable with a
74 74
         // CommentManager instance:
75
-        "\$cm = new CommentManager(sys_get_temp_dir() . '/comments.db');\n" .
76
-        "\PhpXmlRpc\Wrapper::holdObject('*', \$cm);\n\n" .
77
-
78
-    "\$dm = require_once '$targetDispatchMapFile';\n" .
79
-    '$s = new \PhpXmlRpc\Server($dm, false);' . "\n\n" .
80
-    '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!' . "\n" .
81
-    '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);' . "\n" .
82
-    '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);' . "\n\n" .
83
-    '$s->service();' . "\n"
75
+        "\$cm = new CommentManager(sys_get_temp_dir() . '/comments.db');\n".
76
+        "\PhpXmlRpc\Wrapper::holdObject('*', \$cm);\n\n".
77
+
78
+    "\$dm = require_once '$targetDispatchMapFile';\n".
79
+    '$s = new \PhpXmlRpc\Server($dm, false);'."\n\n".
80
+    '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!'."\n".
81
+    '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);'."\n".
82
+    '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);'."\n\n".
83
+    '$s->service();'."\n"
84 84
 ) || die('uh oh');
85 85
 
86 86
     echo "Code generated";
@@ -90,6 +90,6 @@  discard block
 block discarded – undo
90 90
 
91 91
     // *** NB do not do this in prod! The whole concept of code-generation is to do it offline using console scripts/ci/cd ***
92 92
 
93
-    $targetControllerFile = sys_get_temp_dir() . '/myServerController.php';
93
+    $targetControllerFile = sys_get_temp_dir().'/myServerController.php';
94 94
     require $targetControllerFile;
95 95
 }
Please login to merge, or discard this patch.
tests/10DemofilesTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/WebTestCase.php';
3
+include_once __DIR__.'/WebTestCase.php';
4 4
 
5 5
 use PhpXmlRpc\Request;
6 6
 use PhpXmlRpc\Value;
Please login to merge, or discard this patch.