@@ -1,5 +1,5 @@ discard block |
||
| 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; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $handles = array(); |
| 27 | 27 | $curl = curl_multi_init(); |
| 28 | 28 | |
| 29 | - foreach($requests as $k => $req) { |
|
| 29 | + foreach ($requests as $k => $req) { |
|
| 30 | 30 | $req->setDebug($this->debug); |
| 31 | 31 | |
| 32 | 32 | $handle = $this->prepareCurlHandle( |
@@ -59,19 +59,19 @@ discard block |
||
| 59 | 59 | $running = 0; |
| 60 | 60 | do { |
| 61 | 61 | curl_multi_exec($curl, $running); |
| 62 | - } while($running > 0); |
|
| 62 | + } while ($running>0); |
|
| 63 | 63 | |
| 64 | 64 | $responses = array(); |
| 65 | - foreach($handles as $k => $h) { |
|
| 65 | + foreach ($handles as $k => $h) { |
|
| 66 | 66 | $responses[$k] = curl_multi_getcontent($handles[$k]); |
| 67 | 67 | |
| 68 | - if ($this->debug > 1) { |
|
| 68 | + if ($this->debug>1) { |
|
| 69 | 69 | $message = "---CURL INFO---\n"; |
| 70 | 70 | foreach (curl_getinfo($h) as $name => $val) { |
| 71 | 71 | if (is_array($val)) { |
| 72 | 72 | $val = implode("\n", $val); |
| 73 | 73 | } |
| 74 | - $message .= $name . ': ' . $val . "\n"; |
|
| 74 | + $message .= $name.': '.$val."\n"; |
|
| 75 | 75 | } |
| 76 | 76 | $message .= '---END---'; |
| 77 | 77 | $this->getLogger()->debugMessage($message); |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | curl_multi_close($curl); |
| 84 | 84 | |
| 85 | - foreach($responses as $k => $resp) { |
|
| 85 | + foreach ($responses as $k => $resp) { |
|
| 86 | 86 | if (!$resp) { |
| 87 | - $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
| 87 | + $responses[$k] = new Response(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
| 88 | 88 | } else { |
| 89 | 89 | $responses[$k] = $requests[$k]->parseResponse($resp, true, $this->return_type); |
| 90 | 90 | } |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | $value = $encoder->encode($data, array('auto_dates')); |
| 102 | 102 | $req = new Request('interopEchoTests.echoValue', array($value)); |
| 103 | 103 | $reqs = array(); |
| 104 | -for ($i = 0; $i < $num_tests; $i++) { |
|
| 104 | +for ($i = 0; $i<$num_tests; $i++) { |
|
| 105 | 105 | $reqs[] = $req; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $client = new ParallelClient(XMLRPCSERVER); |
| 109 | -$client->setOption(Client::OPT_NO_MULTICALL, true); |
|
| 109 | +$client->setOption(Client::OPT_NO_MULTICALL, true); |
|
| 110 | 110 | |
| 111 | 111 | // a minimal benchmark - use 3 strategies to execute the same 25 calls: sequentially, using parallel http requests, and |
| 112 | 112 | // using a single system.multiCall request |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $t = microtime(true); |
| 118 | 118 | $resp = $client->send($reqs); |
| 119 | -$t = microtime(true) - $t; |
|
| 120 | -echo "Sequential send: " . sprintf('%.3f', $t) . " secs.\n"; |
|
| 119 | +$t = microtime(true)-$t; |
|
| 120 | +echo "Sequential send: ".sprintf('%.3f', $t)." secs.\n"; |
|
| 121 | 121 | flush(); |
| 122 | 122 | |
| 123 | 123 | $t = microtime(true); |
| 124 | 124 | $resp = $client->sendParallel($reqs); |
| 125 | -$t = microtime(true) - $t; |
|
| 126 | -echo "Parallel send: " . sprintf('%.3f', $t) . " secs.\n"; |
|
| 125 | +$t = microtime(true)-$t; |
|
| 126 | +echo "Parallel send: ".sprintf('%.3f', $t)." secs.\n"; |
|
| 127 | 127 | flush(); |
| 128 | 128 | |
| 129 | 129 | $client->setOption(Client::OPT_NO_MULTICALL, false); |
| 130 | 130 | $t = microtime(true); |
| 131 | 131 | $resp = $client->send($reqs); |
| 132 | -$t = microtime(true) - $t; |
|
| 133 | -echo "Multicall send: " . sprintf('%.3f', $t) . " secs.\n"; |
|
| 132 | +$t = microtime(true)-$t; |
|
| 133 | +echo "Multicall send: ".sprintf('%.3f', $t)." secs.\n"; |
|
@@ -1,5 +1,5 @@ discard block |
||
| 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> |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | function display_error($r) |
| 18 | 18 | { |
| 19 | 19 | output("An error occurred: "); |
| 20 | - output("Code: " . $r->faultCode() . " Reason: '" . $r->faultString() . "'<br/>"); |
|
| 20 | + output("Code: ".$r->faultCode()." Reason: '".$r->faultString()."'<br/>"); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $client = new Client(XMLRPCSERVER); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $client->setOption(Client::OPT_RETURN_TYPE, XMLRPCParser::RETURN_PHP); |
| 26 | 26 | |
| 27 | 27 | // First off, let's retrieve the list of methods available on the remote server |
| 28 | -output("<h3>methods available at http://" . $client->server . $client->path . "</h3>\n"); |
|
| 28 | +output("<h3>methods available at http://".$client->server.$client->path."</h3>\n"); |
|
| 29 | 29 | $req = new Request('system.listMethods'); |
| 30 | 30 | $resp = $client->send($req); |
| 31 | 31 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // Then, retrieve the signature and help text of each available method |
| 49 | 49 | foreach ($v as $methodName) { |
| 50 | - output("<h4>" . htmlspecialchars($methodName) . "</h4>\n"); |
|
| 50 | + output("<h4>".htmlspecialchars($methodName)."</h4>\n"); |
|
| 51 | 51 | // build requests first, add params later |
| 52 | 52 | $r1 = new PhpXmlRpc\Request('system.methodHelp'); |
| 53 | 53 | $r2 = new PhpXmlRpc\Request('system.methodSignature'); |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | $ret = $sig[0]; |
| 86 | - output("<code>" . htmlspecialchars($ret) . " " |
|
| 87 | - . htmlspecialchars($methodName) . "("); |
|
| 88 | - if (count($sig) > 1) { |
|
| 89 | - for ($k = 1; $k < count($sig); $k++) { |
|
| 86 | + output("<code>".htmlspecialchars($ret)." " |
|
| 87 | + . htmlspecialchars($methodName)."("); |
|
| 88 | + if (count($sig)>1) { |
|
| 89 | + for ($k = 1; $k<count($sig); $k++) { |
|
| 90 | 90 | output(htmlspecialchars($sig[$k])); |
| 91 | - if ($k < count($sig) - 1) { |
|
| 91 | + if ($k<count($sig)-1) { |
|
| 92 | 92 | output(", "); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 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 - Getstatename demo</title></head> |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | $stateNo = ""; |
| 18 | 18 | |
| 19 | 19 | if (isset($_POST['stateno']) && $_POST['stateno'] != "") { |
| 20 | - $stateNo = (integer)$_POST['stateno']; |
|
| 20 | + $stateNo = (integer) $_POST['stateno']; |
|
| 21 | 21 | $method = 'examples.getStateName'; |
| 22 | 22 | $arguments = array( |
| 23 | 23 | new Value($stateNo, Value::$xmlrpcInt), |
| 24 | 24 | ); |
| 25 | 25 | $req = new Request($method, $arguments); |
| 26 | - output("Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . |
|
| 26 | + output("Sending the following request:<pre>\n\n".htmlentities($req->serialize()). |
|
| 27 | 27 | "\n\n</pre>Debug info of server data follows...\n\n"); |
| 28 | 28 | $client = new Client(XMLRPCSERVER); |
| 29 | 29 | $client->setOption(Client::OPT_DEBUG, 1); |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | $val = $resp->value(); |
| 33 | 33 | // NB: we are _assuming_ that the server did return a scalar xml-rpc value here. |
| 34 | 34 | // If the server is not trusted, we might check that via `$val->kindOf() == 'scalar'` |
| 35 | - output('<br/>State number <b>' . $stateNo . '</b> is <b>' |
|
| 36 | - . htmlspecialchars($val->scalarval()) . '</b><br/><br/>'); |
|
| 35 | + output('<br/>State number <b>'.$stateNo.'</b> is <b>' |
|
| 36 | + . htmlspecialchars($val->scalarval()).'</b><br/><br/>'); |
|
| 37 | 37 | } else { |
| 38 | 38 | output('An error occurred: '); |
| 39 | - output('<pre>Code: ' . htmlspecialchars($resp->faultCode()) |
|
| 40 | - . " Reason: '" . htmlspecialchars($resp->faultString()) . "'</pre>"); |
|
| 39 | + output('<pre>Code: '.htmlspecialchars($resp->faultCode()) |
|
| 40 | + . " Reason: '".htmlspecialchars($resp->faultString())."'</pre>"); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -1,5 +1,5 @@ discard block |
||
| 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 - Webservice wrapper demo</title></head> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $client->setOption(\PhpXmlRpc\Client::OPT_RETURN_TYPE, 'phpvals'); // let client give us back php values instead of xmlrpcvals |
| 21 | 21 | $resp = $client->send(new PhpXmlRpc\Request('system.listMethods')); |
| 22 | 22 | if ($resp->faultCode()) { |
| 23 | - output("<p>Server methods list could not be retrieved: error {$resp->faultCode()} '" . htmlspecialchars($resp->faultString()) . "'</p>\n"); |
|
| 23 | + output("<p>Server methods list could not be retrieved: error {$resp->faultCode()} '".htmlspecialchars($resp->faultString())."'</p>\n"); |
|
| 24 | 24 | } else { |
| 25 | 25 | output("<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n"); |
| 26 | 26 | flush(); |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | if ($methodName == 'examples.getStateName') { |
| 33 | 33 | $callable = $wrapper->wrapXmlrpcMethod($client, $methodName); |
| 34 | 34 | if ($callable) { |
| 35 | - output("<li>Remote server method " . htmlspecialchars($methodName) . " wrapped into php function</li>\n"); |
|
| 35 | + output("<li>Remote server method ".htmlspecialchars($methodName)." wrapped into php function</li>\n"); |
|
| 36 | 36 | } else { |
| 37 | - output("<li>Remote server method " . htmlspecialchars($methodName) . " could not be wrapped!</li>\n"); |
|
| 37 | + output("<li>Remote server method ".htmlspecialchars($methodName)." could not be wrapped!</li>\n"); |
|
| 38 | 38 | } |
| 39 | 39 | break; |
| 40 | 40 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/_prepend.php"; |
|
| 2 | +require_once __DIR__."/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | require_once __DIR__.'/methodProviders/CommentManager.php'; |
| 5 | 5 | |
@@ -25,33 +25,33 @@ discard block |
||
| 25 | 25 | // generate a file with a class definition |
| 26 | 26 | |
| 27 | 27 | // the generated code does not have an autoloader included - we need to add in one |
| 28 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
| 28 | +$autoloader = __DIR__."/_prepend.php"; |
|
| 29 | 29 | |
| 30 | 30 | file_put_contents($targetClassFile, |
| 31 | - "<?php\n\n" . |
|
| 32 | - "require_once '$autoloader';\n\n" . |
|
| 31 | + "<?php\n\n". |
|
| 32 | + "require_once '$autoloader';\n\n". |
|
| 33 | 33 | "class MyServerClass\n{\n\n" |
| 34 | 34 | ) || die('uh oh'); |
| 35 | 35 | |
| 36 | 36 | // we mangle a bit the code we get from wrapPhpClass to generate a php class instead of a bunch of functions |
| 37 | 37 | |
| 38 | -foreach($code as $methodName => $methodDef) { |
|
| 39 | - file_put_contents($targetClassFile, ' ' . str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source']) . "\n\n", FILE_APPEND) || die('uh oh'); |
|
| 40 | - $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function']; |
|
| 38 | +foreach ($code as $methodName => $methodDef) { |
|
| 39 | + file_put_contents($targetClassFile, ' '.str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source'])."\n\n", FILE_APPEND) || die('uh oh'); |
|
| 40 | + $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function']; |
|
| 41 | 41 | unset($code[$methodName]['source']); |
| 42 | 42 | } |
| 43 | 43 | file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh'); |
| 44 | 44 | |
| 45 | 45 | // generate separate files with the xml-rpc server instantiation and its dispatch map |
| 46 | 46 | |
| 47 | -file_put_contents($targetDispatchMapFile, "<?php\n\nreturn " . var_export($code, true) . ";\n"); |
|
| 47 | +file_put_contents($targetDispatchMapFile, "<?php\n\nreturn ".var_export($code, true).";\n"); |
|
| 48 | 48 | |
| 49 | 49 | file_put_contents($targetControllerFile, |
| 50 | - "<?php\n\n" . |
|
| 50 | + "<?php\n\n". |
|
| 51 | 51 | |
| 52 | - "require_once '$autoloader';\n\n" . |
|
| 52 | + "require_once '$autoloader';\n\n". |
|
| 53 | 53 | |
| 54 | - "require_once '$targetClassFile';\n\n" . |
|
| 54 | + "require_once '$targetClassFile';\n\n". |
|
| 55 | 55 | |
| 56 | 56 | // NB: since we are running the generated code within the same script, the existing CommentManager instance will be |
| 57 | 57 | // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | // Wrapper::holdObject('xmlrpc_CommentManager_addComment', $cm); |
| 62 | 62 | // Wrapper::holdObject('xmlrpc_CommentManager_getComments', $cm); |
| 63 | 63 | |
| 64 | - "\$dm = require_once '$targetDispatchMapFile';\n" . |
|
| 65 | - '$s = new \PhpXmlRpc\Server($dm, false);' . "\n" . |
|
| 66 | - '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!' . "\n" . |
|
| 67 | - '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);' . "\n" . |
|
| 68 | - '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);' . "\n" . |
|
| 69 | - '$s->service();' . "\n" |
|
| 64 | + "\$dm = require_once '$targetDispatchMapFile';\n". |
|
| 65 | + '$s = new \PhpXmlRpc\Server($dm, false);'."\n". |
|
| 66 | + '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!'."\n". |
|
| 67 | + '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);'."\n". |
|
| 68 | + '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);'."\n". |
|
| 69 | + '$s->service();'."\n" |
|
| 70 | 70 | ) || die('uh oh'); |
| 71 | 71 | |
| 72 | 72 | // test that everything worked by running it in realtime (note that this will return an xml-rpc error message if run |