@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | <h3>The code demonstrates usage of multicall and introspection methods</h3> |
7 | 7 | <?php |
8 | 8 | |
9 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
9 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
10 | 10 | PhpXmlRpc\Autoloader::register(); |
11 | 11 | |
12 | 12 | function display_error($r) |
13 | 13 | { |
14 | 14 | print "An error occurred: "; |
15 | - print "Code: " . $r->faultCode() |
|
16 | - . " Reason: '" . $r->faultString() . "'<br/>"; |
|
15 | + print "Code: ".$r->faultCode() |
|
16 | + . " Reason: '".$r->faultString()."'<br/>"; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); |
20 | 20 | |
21 | 21 | // First off, let's retrieve the list of methods available on the remote server |
22 | -print "<h3>methods available at http://" . $client->server . $client->path . "</h3>\n"; |
|
22 | +print "<h3>methods available at http://".$client->server.$client->path."</h3>\n"; |
|
23 | 23 | $req = new PhpXmlRpc\Request('system.listMethods'); |
24 | 24 | $resp = $client->send($req); |
25 | 25 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Then, retrieve the signature and help text of each available method |
32 | 32 | foreach ($v as $methodName) { |
33 | - print "<h4>" . $methodName->scalarval() . "</h4>\n"; |
|
33 | + print "<h4>".$methodName->scalarval()."</h4>\n"; |
|
34 | 34 | // build messages first, add params later |
35 | 35 | $m1 = new PhpXmlRpc\Request('system.methodHelp'); |
36 | 36 | $m2 = new PhpXmlRpc\Request('system.methodSignature'); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | if ($val->kindOf() == "array") { |
62 | 62 | foreach ($val as $x) { |
63 | 63 | $ret = $x[0]; |
64 | - print "<code>" . $ret->scalarval() . " " |
|
65 | - . $methodName->scalarval() . "("; |
|
66 | - if ($x->count() > 1) { |
|
67 | - for ($k = 1; $k < $x->count(); $k++) { |
|
64 | + print "<code>".$ret->scalarval()." " |
|
65 | + . $methodName->scalarval()."("; |
|
66 | + if ($x->count()>1) { |
|
67 | + for ($k = 1; $k<$x->count(); $k++) { |
|
68 | 68 | $y = $x[$k]; |
69 | 69 | print $y->scalarval(); |
70 | - if ($k < $x->count() - 1) { |
|
70 | + if ($k<$x->count()-1) { |
|
71 | 71 | print ", "; |
72 | 72 | } |
73 | 73 | } |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | </h3> |
13 | 13 | <?php |
14 | 14 | |
15 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
15 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
16 | 16 | PhpXmlRpc\Autoloader::register(); |
17 | 17 | |
18 | 18 | $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); |
19 | 19 | $client->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals |
20 | 20 | $resp = $client->send(new PhpXmlRpc\Request('system.listMethods')); |
21 | 21 | if ($resp->faultCode()) { |
22 | - echo "<p>Server methods list could not be retrieved: error {$resp->faultCode()} '" . htmlspecialchars($resp->faultString()) . "'</p>\n"; |
|
22 | + echo "<p>Server methods list could not be retrieved: error {$resp->faultCode()} '".htmlspecialchars($resp->faultString())."'</p>\n"; |
|
23 | 23 | } else { |
24 | 24 | echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n"; |
25 | 25 | flush(); |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | if ($methodName == 'examples.getStateName') { |
32 | 32 | $callable = $wrapper->wrapXmlrpcMethod($client, $methodName); |
33 | 33 | if ($callable) { |
34 | - echo "<li>Remote server method " . htmlspecialchars($methodName) . " wrapped into php function</li>\n"; |
|
34 | + echo "<li>Remote server method ".htmlspecialchars($methodName)." wrapped into php function</li>\n"; |
|
35 | 35 | } else { |
36 | - echo "<li>Remote server method " . htmlspecialchars($methodName) . " could not be wrapped!</li>\n"; |
|
36 | + echo "<li>Remote server method ".htmlspecialchars($methodName)." could not be wrapped!</li>\n"; |
|
37 | 37 | } |
38 | 38 | break; |
39 | 39 | } |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | <p></p> |
11 | 11 | <?php |
12 | 12 | |
13 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
13 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
14 | 14 | PhpXmlRpc\Autoloader::register(); |
15 | 15 | |
16 | 16 | $inAr = array("Dave" => 24, "Edd" => 45, "Joe" => 37, "Fred" => 27); |
17 | 17 | print "This is the input data:<br/><pre>"; |
18 | -foreach($inAr as $key => $val) { |
|
19 | - print $key . ", " . $val . "\n"; |
|
18 | +foreach ($inAr as $key => $val) { |
|
19 | + print $key.", ".$val."\n"; |
|
20 | 20 | } |
21 | 21 | print "</pre>"; |
22 | 22 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ); |
33 | 33 | } |
34 | 34 | $v = new PhpXmlRpc\Value($p, "array"); |
35 | -print "Encoded into xmlrpc format it looks like this: <pre>\n" . htmlentities($v->serialize()) . "</pre>\n"; |
|
35 | +print "Encoded into xmlrpc format it looks like this: <pre>\n".htmlentities($v->serialize())."</pre>\n"; |
|
36 | 36 | |
37 | 37 | // create client and message objects |
38 | 38 | $req = new PhpXmlRpc\Request('examples.sortByAge', array($v)); |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | foreach ($value as $struct) { |
53 | 53 | $name = $struct["name"]; |
54 | 54 | $age = $struct["age"]; |
55 | - print htmlspecialchars($name->scalarval()) . ", " . htmlspecialchars($age->scalarval()) . "\n"; |
|
55 | + print htmlspecialchars($name->scalarval()).", ".htmlspecialchars($age->scalarval())."\n"; |
|
56 | 56 | } |
57 | 57 | |
58 | - print "<hr/>For nerds: I got this value back<br/><pre>" . |
|
59 | - htmlentities($resp->serialize()) . "</pre><hr/>\n"; |
|
58 | + print "<hr/>For nerds: I got this value back<br/><pre>". |
|
59 | + htmlentities($resp->serialize())."</pre><hr/>\n"; |
|
60 | 60 | } else { |
61 | 61 | print "An error occurred:<pre>"; |
62 | - print "Code: " . htmlspecialchars($resp->faultCode()) . |
|
63 | - "\nReason: '" . htmlspecialchars($resp->faultString()) . '\'</pre><hr/>'; |
|
62 | + print "Code: ".htmlspecialchars($resp->faultCode()). |
|
63 | + "\nReason: '".htmlspecialchars($resp->faultString()).'\'</pre><hr/>'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | ?> |
@@ -6,7 +6,7 @@ |
||
6 | 6 | <h3>The code demonstrates usage for the terminally lazy. For a more complete proxy, look at at the Wrapper class</h3> |
7 | 7 | <?php |
8 | 8 | |
9 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
9 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
10 | 10 | PhpXmlRpc\Autoloader::register(); |
11 | 11 | |
12 | 12 | class PhpXmlRpcProxy |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <h3>The code demonstrates usage of the PhpXmlRpc\Encoder class</h3> |
7 | 7 | <?php |
8 | 8 | |
9 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
9 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
10 | 10 | PhpXmlRpc\Autoloader::register(); |
11 | 11 | |
12 | 12 | $req = new PhpXmlRpc\Request('interopEchoTests.whichToolkit', array()); |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | $encoder = new PhpXmlRpc\Encoder(); |
17 | 17 | $value = $encoder->decode($resp->value()); |
18 | 18 | print "<pre>"; |
19 | - print "name: " . htmlspecialchars($value["toolkitName"]) . "\n"; |
|
20 | - print "version: " . htmlspecialchars($value["toolkitVersion"]) . "\n"; |
|
21 | - print "docs: " . htmlspecialchars($value["toolkitDocsUrl"]) . "\n"; |
|
22 | - print "os: " . htmlspecialchars($value["toolkitOperatingSystem"]) . "\n"; |
|
19 | + print "name: ".htmlspecialchars($value["toolkitName"])."\n"; |
|
20 | + print "version: ".htmlspecialchars($value["toolkitVersion"])."\n"; |
|
21 | + print "docs: ".htmlspecialchars($value["toolkitDocsUrl"])."\n"; |
|
22 | + print "os: ".htmlspecialchars($value["toolkitOperatingSystem"])."\n"; |
|
23 | 23 | print "</pre>"; |
24 | 24 | } else { |
25 | 25 | print "An error occurred: "; |
26 | - print "Code: " . htmlspecialchars($resp->faultCode()) . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n"; |
|
26 | + print "Code: ".htmlspecialchars($resp->faultCode())." Reason: '".htmlspecialchars($resp->faultString())."'\n"; |
|
27 | 27 | } |
28 | 28 | ?> |
29 | 29 | </body> |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | method)</p> |
21 | 21 | <?php |
22 | 22 | |
23 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
23 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
24 | 24 | PhpXmlRpc\Autoloader::register(); |
25 | 25 | |
26 | 26 | if (isset($_POST["mailto"]) && $_POST["mailto"]) { |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | print "<fonr color=\"red\">"; |
45 | 45 | print "Mail send failed<br/>\n"; |
46 | 46 | print "Fault: "; |
47 | - print "Code: " . htmlspecialchars($resp->faultCode()) . |
|
48 | - " Reason: '" . htmlspecialchars($resp->faultString()) . "'<br/>"; |
|
47 | + print "Code: ".htmlspecialchars($resp->faultCode()). |
|
48 | + " Reason: '".htmlspecialchars($resp->faultString())."'<br/>"; |
|
49 | 49 | print "</font><br/>"; |
50 | 50 | } |
51 | 51 | } |
@@ -8,34 +8,34 @@ |
||
8 | 8 | <h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3> |
9 | 9 | <?php |
10 | 10 | |
11 | -include_once __DIR__ . "/../../src/Autoloader.php"; |
|
11 | +include_once __DIR__."/../../src/Autoloader.php"; |
|
12 | 12 | PhpXmlRpc\Autoloader::register(); |
13 | 13 | |
14 | 14 | if (isset($_POST["stateno"]) && $_POST["stateno"] != "") { |
15 | - $stateNo = (integer)$_POST["stateno"]; |
|
15 | + $stateNo = (integer) $_POST["stateno"]; |
|
16 | 16 | $encoder = new PhpXmlRpc\Encoder(); |
17 | 17 | $req = new PhpXmlRpc\Request('examples.getStateName', |
18 | 18 | array($encoder->encode($stateNo)) |
19 | 19 | ); |
20 | - print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n"; |
|
20 | + print "Sending the following request:<pre>\n\n".htmlentities($req->serialize())."\n\n</pre>Debug info of server data follows...\n\n"; |
|
21 | 21 | $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); |
22 | 22 | $client->setDebug(1); |
23 | 23 | $r = $client->send($req); |
24 | 24 | if (!$r->faultCode()) { |
25 | 25 | $v = $r->value(); |
26 | - print "<br/>State number <b>" . $stateNo . "</b> is <b>" |
|
27 | - . htmlspecialchars($encoder->decode($v)) . "</b><br/>"; |
|
26 | + print "<br/>State number <b>".$stateNo."</b> is <b>" |
|
27 | + . htmlspecialchars($encoder->decode($v))."</b><br/>"; |
|
28 | 28 | } else { |
29 | 29 | print "An error occurred: "; |
30 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
31 | - . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
30 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
31 | + . " Reason: '".htmlspecialchars($r->faultString())."'</pre><br/>"; |
|
32 | 32 | } |
33 | 33 | } else { |
34 | 34 | $stateNo = ""; |
35 | 35 | } |
36 | 36 | |
37 | 37 | print "<form action=\"getstatename.php\" method=\"POST\"> |
38 | -<input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
38 | +<input name=\"stateno\" value=\"" . $stateNo."\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
39 | 39 | <p>Enter a state number to query its name</p>"; |
40 | 40 | |
41 | 41 | ?> |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $xmlrpcVal->scalarval(); |
73 | 73 | case 'array': |
74 | 74 | $arr = array(); |
75 | - foreach($xmlrpcVal as $value) { |
|
75 | + foreach ($xmlrpcVal as $value) { |
|
76 | 76 | $arr[] = $this->decode($value, $options); |
77 | 77 | } |
78 | 78 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | case 'msg': |
103 | 103 | $paramCount = $xmlrpcVal->getNumParams(); |
104 | 104 | $arr = array(); |
105 | - for ($i = 0; $i < $paramCount; $i++) { |
|
105 | + for ($i = 0; $i<$paramCount; $i++) { |
|
106 | 106 | $arr[] = $this->decode($xmlrpcVal->getParam($i), $options); |
107 | 107 | } |
108 | 108 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | break; |
204 | 204 | case 'resource': |
205 | 205 | if (in_array('extension_api', $options)) { |
206 | - $xmlrpcVal = new Value((int)$phpVal, Value::$xmlrpcInt); |
|
206 | + $xmlrpcVal = new Value((int) $phpVal, Value::$xmlrpcInt); |
|
207 | 207 | } else { |
208 | 208 | $xmlrpcVal = new Value(); |
209 | 209 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | if (extension_loaded('mbstring')) { |
247 | 247 | $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding); |
248 | 248 | } else { |
249 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding); |
|
249 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of xml text: '.$valEncoding); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | xml_parser_free($parser); |
281 | - if ($xmlRpcParser->_xh['isf'] > 1) { |
|
281 | + if ($xmlRpcParser->_xh['isf']>1) { |
|
282 | 282 | // test that $xmlrpc->_xh['value'] is an obj, too??? |
283 | 283 | |
284 | 284 | error_log($xmlRpcParser->_xh['isf_reason']); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | return $r; |
300 | 300 | case 'methodcall': |
301 | 301 | $req = new Request($xmlRpcParser->_xh['method']); |
302 | - for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) { |
|
302 | + for ($i = 0; $i<count($xmlRpcParser->_xh['params']); $i++) { |
|
303 | 303 | $req->addParam($xmlRpcParser->_xh['params'][$i]); |
304 | 304 | } |
305 | 305 |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | $callable = explode('::', $callable); |
157 | 157 | } |
158 | 158 | if (is_array($callable)) { |
159 | - if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
160 | - error_log('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
159 | + if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
160 | + error_log('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | if (is_string($callable[0])) { |
164 | 164 | $plainFuncName = implode('::', $callable); |
165 | 165 | } elseif (is_object($callable[0])) { |
166 | - $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
166 | + $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
167 | 167 | } |
168 | 168 | $exists = method_exists($callable[0], $callable[1]); |
169 | 169 | } else if ($callable instanceof \Closure) { |
170 | 170 | // we do not support creating code which wraps closures, as php does not allow to serialize them |
171 | 171 | if (!$buildIt) { |
172 | - error_log('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
172 | + error_log('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | if (!$exists) { |
184 | - error_log('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
184 | + error_log('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
@@ -225,23 +225,23 @@ discard block |
||
225 | 225 | if (is_array($callable)) { |
226 | 226 | $func = new \ReflectionMethod($callable[0], $callable[1]); |
227 | 227 | if ($func->isPrivate()) { |
228 | - error_log('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
228 | + error_log('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | if ($func->isProtected()) { |
232 | - error_log('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
232 | + error_log('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | if ($func->isConstructor()) { |
236 | - error_log('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
236 | + error_log('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
237 | 237 | return false; |
238 | 238 | } |
239 | 239 | if ($func->isDestructor()) { |
240 | - error_log('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
240 | + error_log('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | if ($func->isAbstract()) { |
244 | - error_log('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
244 | + error_log('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | /// @todo add more checks for static vs. nonstatic? |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if ($func->isInternal()) { |
252 | 252 | // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs |
253 | 253 | // instead of getparameters to fully reflect internal php functions ? |
254 | - error_log('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
254 | + error_log('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $i = 0; |
304 | 304 | foreach ($func->getParameters() as $paramObj) { |
305 | 305 | $params[$i] = array(); |
306 | - $params[$i]['name'] = '$' . $paramObj->getName(); |
|
306 | + $params[$i]['name'] = '$'.$paramObj->getName(); |
|
307 | 307 | $params[$i]['isoptional'] = $paramObj->isOptional(); |
308 | 308 | $i++; |
309 | 309 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | // build a signature |
369 | 369 | $sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
370 | 370 | $pSig = array($funcDesc['returnsDocs']); |
371 | - for ($i = 0; $i < count($pars); $i++) { |
|
371 | + for ($i = 0; $i<count($pars); $i++) { |
|
372 | 372 | $name = strtolower($funcDesc['params'][$i]['name']); |
373 | 373 | if (isset($funcDesc['paramDocs'][$name]['type'])) { |
374 | 374 | $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | } |
420 | 420 | } |
421 | 421 | $numPars = $req->getNumParams(); |
422 | - if ($numPars < $minPars || $numPars > $maxPars) { |
|
422 | + if ($numPars<$minPars || $numPars>$maxPars) { |
|
423 | 423 | return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
424 | 424 | } |
425 | 425 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | $result = call_user_func_array($callable, $params); |
434 | 434 | |
435 | - if (! is_a($result, $responseClass)) { |
|
435 | + if (!is_a($result, $responseClass)) { |
|
436 | 436 | if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
437 | 437 | $result = new $valueClass($result, $funcDesc['returns']); |
438 | 438 | } else { |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | if ($newFuncName == '') { |
468 | 468 | if (is_array($callable)) { |
469 | 469 | if (is_string($callable[0])) { |
470 | - $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
470 | + $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
471 | 471 | } else { |
472 | - $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
472 | + $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
473 | 473 | } |
474 | 474 | } else { |
475 | 475 | if ($callable instanceof \Closure) { |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | { |
506 | 506 | $namespace = '\\PhpXmlRpc\\'; |
507 | 507 | |
508 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
509 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
508 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
509 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
510 | 510 | $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
511 | 511 | |
512 | 512 | $i = 0; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | // build body of new function |
542 | 542 | |
543 | 543 | $innerCode = "\$paramCount = \$req->getNumParams();\n"; |
544 | - $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
544 | + $innerCode .= "if (\$paramCount < $minPars || \$paramCount > $maxPars) return new {$namespace}Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
545 | 545 | |
546 | 546 | $innerCode .= "\$encoder = new {$namespace}Encoder();\n"; |
547 | 547 | if ($decodePhpObjects) { |
@@ -555,13 +555,13 @@ discard block |
||
555 | 555 | if (is_array($callable) && is_object($callable[0])) { |
556 | 556 | self::$objHolder[$newFuncName] = $callable[0]; |
557 | 557 | $innerCode .= "\$obj = PhpXmlRpc\\Wrapper::\$objHolder['$newFuncName'];\n"; |
558 | - $realFuncName = '$obj->' . $callable[1]; |
|
558 | + $realFuncName = '$obj->'.$callable[1]; |
|
559 | 559 | } else { |
560 | 560 | $realFuncName = $plainFuncName; |
561 | 561 | } |
562 | 562 | foreach ($parsVariations as $i => $pars) { |
563 | - $innerCode .= "if (\$paramCount == " . count($pars) . ") \$retval = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
564 | - if ($i < (count($parsVariations) - 1)) |
|
563 | + $innerCode .= "if (\$paramCount == ".count($pars).") \$retval = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
564 | + if ($i<(count($parsVariations)-1)) |
|
565 | 565 | $innerCode .= "else\n"; |
566 | 566 | } |
567 | 567 | $innerCode .= "if (is_a(\$retval, '{$namespace}Response')) return \$retval; else\n"; |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | // if($func->returnsReference()) |
579 | 579 | // return false; |
580 | 580 | |
581 | - $code = "function $newFuncName(\$req) {\n" . $innerCode . "\n}"; |
|
581 | + $code = "function $newFuncName(\$req) {\n".$innerCode."\n}"; |
|
582 | 582 | |
583 | 583 | return $code; |
584 | 584 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | if ($methodWrap) { |
616 | 616 | if (is_object($className)) { |
617 | 617 | $realClassName = get_class($className); |
618 | - }else { |
|
618 | + } else { |
|
619 | 619 | $realClassName = $className; |
620 | 620 | } |
621 | 621 | $results[$prefix."$realClassName.$mName"] = $methodWrap; |
@@ -716,21 +716,21 @@ discard block |
||
716 | 716 | protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
717 | 717 | { |
718 | 718 | $namespace = '\\PhpXmlRpc\\'; |
719 | - $reqClass = $namespace . 'Request'; |
|
720 | - $valClass = $namespace . 'Value'; |
|
721 | - $decoderClass = $namespace . 'Encoder'; |
|
719 | + $reqClass = $namespace.'Request'; |
|
720 | + $valClass = $namespace.'Value'; |
|
721 | + $decoderClass = $namespace.'Encoder'; |
|
722 | 722 | |
723 | 723 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
724 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
724 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
725 | 725 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
726 | - $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
726 | + $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
727 | 727 | |
728 | 728 | $req = new $reqClass('system.methodSignature'); |
729 | 729 | $req->addparam(new $valClass($methodName)); |
730 | 730 | $client->setDebug($debug); |
731 | 731 | $response = $client->send($req, $timeout, $protocol); |
732 | 732 | if ($response->faultCode()) { |
733 | - error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
733 | + error_log('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
734 | 734 | return false; |
735 | 735 | } |
736 | 736 | |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | $mSig = $decoder->decode($mSig); |
741 | 741 | } |
742 | 742 | |
743 | - if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
744 | - error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
743 | + if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
744 | + error_log('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
@@ -757,11 +757,11 @@ discard block |
||
757 | 757 | protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
758 | 758 | { |
759 | 759 | $namespace = '\\PhpXmlRpc\\'; |
760 | - $reqClass = $namespace . 'Request'; |
|
761 | - $valClass = $namespace . 'Value'; |
|
760 | + $reqClass = $namespace.'Request'; |
|
761 | + $valClass = $namespace.'Value'; |
|
762 | 762 | |
763 | 763 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
764 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
764 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
765 | 765 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
766 | 766 | |
767 | 767 | $mDesc = ''; |
@@ -795,10 +795,10 @@ discard block |
||
795 | 795 | $clientClone = clone $client; |
796 | 796 | $function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
797 | 797 | { |
798 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
798 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
799 | 799 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
800 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
801 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
800 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
801 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
802 | 802 | if (isset($extraOptions['return_on_fault'])) { |
803 | 803 | $decodeFault = true; |
804 | 804 | $faultResponse = $extraOptions['return_on_fault']; |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | } |
808 | 808 | |
809 | 809 | $namespace = '\\PhpXmlRpc\\'; |
810 | - $reqClass = $namespace . 'Request'; |
|
811 | - $encoderClass = $namespace . 'Encoder'; |
|
812 | - $valueClass = $namespace . 'Value'; |
|
810 | + $reqClass = $namespace.'Request'; |
|
811 | + $encoderClass = $namespace.'Encoder'; |
|
812 | + $valueClass = $namespace.'Value'; |
|
813 | 813 | |
814 | 814 | $encoder = new $encoderClass(); |
815 | 815 | $encodeOptions = array(); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | } |
833 | 833 | |
834 | 834 | $xmlrpcArgs = array(); |
835 | - foreach($currentArgs as $i => $arg) { |
|
835 | + foreach ($currentArgs as $i => $arg) { |
|
836 | 836 | if ($i == $maxArgs) { |
837 | 837 | break; |
838 | 838 | } |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | * @param string $mDesc |
881 | 881 | * @return array |
882 | 882 | */ |
883 | - public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
883 | + public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
884 | 884 | { |
885 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
885 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
886 | 886 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
887 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
888 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
889 | - $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
887 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
888 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
889 | + $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
890 | 890 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
891 | 891 | if (isset($extraOptions['return_on_fault'])) { |
892 | 892 | $decodeFault = true; |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | $namespace = '\\PhpXmlRpc\\'; |
900 | 900 | |
901 | 901 | $code = "function $newFuncName ("; |
902 | - if ($clientCopyMode < 2) { |
|
902 | + if ($clientCopyMode<2) { |
|
903 | 903 | // client copy mode 0 or 1 == full / partial client copy in emitted code |
904 | 904 | $verbatimClientCopy = !$clientCopyMode; |
905 | 905 | $innerCode = $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, $namespace); |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | |
915 | 915 | if ($mDesc != '') { |
916 | 916 | // take care that PHP comment is not terminated unwillingly by method description |
917 | - $mDesc = "/**\n* " . str_replace('*/', '* /', $mDesc) . "\n"; |
|
917 | + $mDesc = "/**\n* ".str_replace('*/', '* /', $mDesc)."\n"; |
|
918 | 918 | } else { |
919 | 919 | $mDesc = "/**\nFunction $newFuncName\n"; |
920 | 920 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | $innerCode .= "\$encoder = new {$namespace}Encoder();\n"; |
924 | 924 | $plist = array(); |
925 | 925 | $pCount = count($mSig); |
926 | - for ($i = 1; $i < $pCount; $i++) { |
|
926 | + for ($i = 1; $i<$pCount; $i++) { |
|
927 | 927 | $plist[] = "\$p$i"; |
928 | 928 | $pType = $mSig[$i]; |
929 | 929 | if ($pType == 'i4' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
@@ -939,19 +939,19 @@ discard block |
||
939 | 939 | } |
940 | 940 | } |
941 | 941 | $innerCode .= "\$req->addparam(\$p$i);\n"; |
942 | - $mDesc .= '* @param ' . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
942 | + $mDesc .= '* @param '.$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
943 | 943 | } |
944 | - if ($clientCopyMode < 2) { |
|
944 | + if ($clientCopyMode<2) { |
|
945 | 945 | $plist[] = '$debug=0'; |
946 | 946 | $mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
947 | 947 | } |
948 | 948 | $plist = implode(', ', $plist); |
949 | - $mDesc .= '* @return ' . $this->xmlrpc2PhpType($mSig[0]) . " (or an {$namespace}Response obj instance if call fails)\n*/\n"; |
|
949 | + $mDesc .= '* @return '.$this->xmlrpc2PhpType($mSig[0])." (or an {$namespace}Response obj instance if call fails)\n*/\n"; |
|
950 | 950 | |
951 | 951 | $innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n"; |
952 | 952 | if ($decodeFault) { |
953 | 953 | if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
954 | - $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
954 | + $respCode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
955 | 955 | } else { |
956 | 956 | $respCode = var_export($faultResponse, true); |
957 | 957 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $innerCode .= "if (\$res->faultcode()) return $respCode; else return \$encoder->decode(\$res->value());"; |
965 | 965 | } |
966 | 966 | |
967 | - $code = $code . $plist . ") {\n" . $innerCode . "\n}\n"; |
|
967 | + $code = $code.$plist.") {\n".$innerCode."\n}\n"; |
|
968 | 968 | |
969 | 969 | return array('source' => $code, 'docstring' => $mDesc); |
970 | 970 | } |
@@ -990,23 +990,23 @@ discard block |
||
990 | 990 | public function wrapXmlrpcServer($client, $extraOptions = array()) |
991 | 991 | { |
992 | 992 | $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
993 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
993 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
994 | 994 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
995 | 995 | $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
996 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
997 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
996 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
997 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
998 | 998 | $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
999 | 999 | $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
1000 | 1000 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
1001 | 1001 | $namespace = '\\PhpXmlRpc\\'; |
1002 | 1002 | |
1003 | - $reqClass = $namespace . 'Request'; |
|
1004 | - $decoderClass = $namespace . 'Encoder'; |
|
1003 | + $reqClass = $namespace.'Request'; |
|
1004 | + $decoderClass = $namespace.'Encoder'; |
|
1005 | 1005 | |
1006 | 1006 | $req = new $reqClass('system.listMethods'); |
1007 | 1007 | $response = $client->send($req, $timeout, $protocol); |
1008 | 1008 | if ($response->faultCode()) { |
1009 | - error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
1009 | + error_log('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
1010 | 1010 | |
1011 | 1011 | return false; |
1012 | 1012 | } else { |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | $mList = $decoder->decode($mList); |
1017 | 1017 | } |
1018 | 1018 | if (!is_array($mList) || !count($mList)) { |
1019 | - error_log('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
1019 | + error_log('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
1020 | 1020 | |
1021 | 1021 | return false; |
1022 | 1022 | } else { |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | if ($newClassName != '') { |
1025 | 1025 | $xmlrpcClassName = $newClassName; |
1026 | 1026 | } else { |
1027 | - $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
1028 | - array('_', ''), $client->server) . '_client'; |
|
1027 | + $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
1028 | + array('_', ''), $client->server).'_client'; |
|
1029 | 1029 | } |
1030 | 1030 | while ($buildIt && class_exists($xmlrpcClassName)) { |
1031 | 1031 | $xmlrpcClassName .= 'x'; |
@@ -1056,20 +1056,20 @@ discard block |
||
1056 | 1056 | if (!$buildIt) { |
1057 | 1057 | $source .= $methodWrap['docstring']; |
1058 | 1058 | } |
1059 | - $source .= $methodWrap['source'] . "\n"; |
|
1059 | + $source .= $methodWrap['source']."\n"; |
|
1060 | 1060 | } else { |
1061 | - error_log('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
1061 | + error_log('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
1062 | 1062 | } |
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | $source .= "}\n"; |
1066 | 1066 | if ($buildIt) { |
1067 | 1067 | $allOK = 0; |
1068 | - eval($source . '$allOK=1;'); |
|
1068 | + eval($source.'$allOK=1;'); |
|
1069 | 1069 | if ($allOK) { |
1070 | 1070 | return $xmlrpcClassName; |
1071 | 1071 | } else { |
1072 | - error_log('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server); |
|
1072 | + error_log('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.' to wrap remote server '.$client->server); |
|
1073 | 1073 | return false; |
1074 | 1074 | } |
1075 | 1075 | } else { |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | * |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\' ) |
|
1093 | + protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
|
1094 | 1094 | { |
1095 | - $code = "\$client = new {$namespace}Client('" . str_replace("'", "\'", $client->path) . |
|
1096 | - "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n"; |
|
1095 | + $code = "\$client = new {$namespace}Client('".str_replace("'", "\'", $client->path). |
|
1096 | + "', '".str_replace("'", "\'", $client->server)."', $client->port);\n"; |
|
1097 | 1097 | |
1098 | 1098 | // copy all client fields to the client that will be generated runtime |
1099 | 1099 | // (this provides for future expansion or subclassing of client obj) |