@@ -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->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 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @license code licensed under the BSD License: see file license.txt |
16 | 16 | */ |
17 | 17 | |
18 | -require_once __DIR__ . "/_prepend.php"; |
|
18 | +require_once __DIR__."/_prepend.php"; |
|
19 | 19 | |
20 | 20 | // *** NB: WE BLOCK THIS FROM RUNNING BY DEFAULT IN CASE ACCESS IS GRANTED TO IT IN PRODUCTION BY MISTAKE *** |
21 | 21 | // Comment out the following safeguard if you want to use it as is, but remember: this is an open relay !!! |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // fe. any url using the 'file://' protocol might be considered a hacking attempt |
47 | 47 | $client = new Client($url); |
48 | 48 | |
49 | - if ($req->getNumParams() > 3) { |
|
49 | + if ($req->getNumParams()>3) { |
|
50 | 50 | // we have to set some options onto the client. |
51 | 51 | // Note that if we do not untaint the received values, warnings might be generated... |
52 | 52 | $options = $encoder->decode($req->getParam(3)); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $client->setSSLVerifyPeer($val); |
69 | 69 | break; |
70 | 70 | case 'Timeout': |
71 | - $timeout = (integer)$val; |
|
71 | + $timeout = (integer) $val; |
|
72 | 72 | break; |
73 | 73 | } // switch |
74 | 74 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /// X-forwarded-for anyway, unless they consider this server as trusted...) |
82 | 82 | $reqMethod = $req->getParam(1)->scalarval(); |
83 | 83 | $req = new Request($reqMethod); |
84 | - if ($req->getNumParams() > 1) { |
|
84 | + if ($req->getNumParams()>1) { |
|
85 | 85 | $pars = $req->getParam(2); |
86 | 86 | foreach ($pars as $par) { |
87 | 87 | $req->addParam($par); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // add debug info into response we give back to caller |
92 | - Server::xmlrpc_debugmsg("Sending to server $url the payload: " . $req->serialize()); |
|
92 | + Server::xmlrpc_debugmsg("Sending to server $url the payload: ".$req->serialize()); |
|
93 | 93 | |
94 | 94 | return $client->send($req, $timeout); |
95 | 95 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | function plain_findstate($stateNo) |
28 | 28 | { |
29 | - if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
29 | + if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
30 | 30 | return exampleMethods::$stateNames[$stateNo - 1]; |
31 | 31 | } else { |
32 | 32 | // not, there so complain |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function plain_findstate($stateNo) |
28 | 28 | { |
29 | - if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
30 | - return exampleMethods::$stateNames[$stateNo - 1]; |
|
29 | + if (isset(exampleMethods::$stateNames[$stateNo-1])) { |
|
30 | + return exampleMethods::$stateNames[$stateNo-1]; |
|
31 | 31 | } else { |
32 | 32 | // not, there so complain |
33 | - throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
33 | + throw new Exception("I don't have a state for the index '".$stateNo."'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | |
125 | 125 | $findstate10_sig = array( |
126 | 126 | /// @todo add a demo and test with closure usage |
127 | - "function" => function ($req) { return exampleMethods::findState($req); }, |
|
127 | + "function" => function($req) { return exampleMethods::findState($req); }, |
|
128 | 128 | "signature" => array(array(Value::$xmlrpcString, Value::$xmlrpcInt)), |
129 | - "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the ' . |
|
129 | + "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the '. |
|
130 | 130 | 'index of that state name in an alphabetic order.', |
131 | 131 | ); |
132 | 132 | |
133 | -$findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return plain_findstate($stateNo); }); |
|
133 | +$findstate11_sig = $wrapper->wrapPhpFunction(function($stateNo) { return plain_findstate($stateNo); }); |
|
134 | 134 | |
135 | 135 | /// @todo do we really need a new instance ? |
136 | 136 | $c = new handlersContainer(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $namespaceSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'namespacetest.', 'replace_class_name' => true, 'method_filter' => '/^findState$/', 'method_type' => 'static')); |
141 | 141 | |
142 | -$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
142 | +$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
143 | 143 | |
144 | 144 | return array_merge( |
145 | 145 | array( |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $snv = $sno->scalarval(); |
54 | 54 | |
55 | 55 | // look it up in our array (zero-based) |
56 | - if (isset(self::$stateNames[$snv - 1])) { |
|
57 | - $stateName = self::$stateNames[$snv - 1]; |
|
56 | + if (isset(self::$stateNames[$snv-1])) { |
|
57 | + $stateName = self::$stateNames[$snv-1]; |
|
58 | 58 | } else { |
59 | 59 | // not there, so complain |
60 | - $err = "I don't have a state for the index '" . $snv . "'"; |
|
60 | + $err = "I don't have a state for the index '".$snv."'"; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if ($err != '') { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $s = $req->getParam(0); |
132 | 132 | $t = $req->getParam(1); |
133 | 133 | |
134 | - return new Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcInt)); |
|
134 | + return new Response(new Value($s->scalarval()+$t->scalarval(), Value::$xmlrpcInt)); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | public static $addtwodouble_sig = array(array('double', 'double', 'double')); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $s = $req->getParam(0); |
142 | 142 | $t = $req->getParam(1); |
143 | 143 | |
144 | - return new Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcDouble)); |
|
144 | + return new Response(new Value($s->scalarval()+$t->scalarval(), Value::$xmlrpcDouble)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | public static $stringecho_sig = array(array('string', 'string')); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public static function echoBack($req) |
158 | 158 | { |
159 | 159 | // just sends back a string with what I got sent to me, that's all (escaping for xml is automatic) |
160 | - $s = "I got the following message:\n" . $req->serialize(); |
|
160 | + $s = "I got the following message:\n".$req->serialize(); |
|
161 | 161 | |
162 | 162 | return new Response(new Value($s)); |
163 | 163 | } |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | |
231 | 231 | /// @todo in real life, we should check for presence of return characters to avoid header injection! |
232 | 232 | |
233 | - $msgHdr = "From: " . $mFrom->scalarval() . "\n"; |
|
234 | - $msgHdr .= "To: " . $mTo->scalarval() . "\n"; |
|
233 | + $msgHdr = "From: ".$mFrom->scalarval()."\n"; |
|
234 | + $msgHdr .= "To: ".$mTo->scalarval()."\n"; |
|
235 | 235 | |
236 | 236 | if ($mCc->scalarval() != "") { |
237 | - $msgHdr .= "Cc: " . $mCc->scalarval() . "\n"; |
|
237 | + $msgHdr .= "Cc: ".$mCc->scalarval()."\n"; |
|
238 | 238 | } |
239 | 239 | if ($mBcc->scalarval() != "") { |
240 | - $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n"; |
|
240 | + $msgHdr .= "Bcc: ".$mBcc->scalarval()."\n"; |
|
241 | 241 | } |
242 | 242 | if ($mMime->scalarval() != "") { |
243 | - $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n"; |
|
243 | + $msgHdr .= "Content-type: ".$mMime->scalarval()."\n"; |
|
244 | 244 | } |
245 | 245 | $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0"; |
246 | 246 |
@@ -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 | /** |
5 | 5 | * Demoing the code-generation capabilities of the library: create a client class which exposes a bunch of methods |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | ); |
22 | 22 | |
23 | 23 | // the generated code does not have an autoloader included - we need to add in one |
24 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
24 | +$autoloader = __DIR__."/_prepend.php"; |
|
25 | 25 | |
26 | 26 | $targetFile = '/tmp/MyClient.php'; |
27 | 27 | $generated = file_put_contents($targetFile, |
28 | - "<?php\n\n" . |
|
29 | - "require_once '$autoloader';\n\n" . |
|
28 | + "<?php\n\n". |
|
29 | + "require_once '$autoloader';\n\n". |
|
30 | 30 | $code['code'] |
31 | 31 | ); |
32 | 32 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $client = new MyClient(); |
47 | 47 | $sorted = $client->examples_sortByAge(array( |
48 | 48 | array('name' => 'Dave', 'age' => 24), |
49 | - array('name' => 'Edd', 'age' => 45), |
|
50 | - array('name' => 'Joe', 'age' => 37), |
|
49 | + array('name' => 'Edd', 'age' => 45), |
|
50 | + array('name' => 'Joe', 'age' => 37), |
|
51 | 51 | array('name' => 'Fred', 'age' => 27), |
52 | 52 | )); |
53 | 53 |
@@ -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 | |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | // generate a file with a class definition |
23 | 23 | |
24 | 24 | // the generated code does not have an autoloader included - we need to add in one |
25 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
25 | +$autoloader = __DIR__."/_prepend.php"; |
|
26 | 26 | |
27 | 27 | file_put_contents($targetClassFile, |
28 | - "<?php\n\n" . |
|
29 | - "require_once '$autoloader';\n\n" . |
|
28 | + "<?php\n\n". |
|
29 | + "require_once '$autoloader';\n\n". |
|
30 | 30 | "class MyServerClass {\n\n" |
31 | 31 | ) || die('uh oh'); |
32 | 32 | |
33 | 33 | // we mangle a bit the code we get from wrapPhpClass to generate a php class instead of a bunch of functions |
34 | 34 | |
35 | -foreach($code as $methodName => $methodDef) { |
|
36 | - file_put_contents($targetClassFile, 'public static ' . $methodDef['source'] . "\n\n", FILE_APPEND) || die('uh oh'); |
|
37 | - $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function']; |
|
35 | +foreach ($code as $methodName => $methodDef) { |
|
36 | + file_put_contents($targetClassFile, 'public static '.$methodDef['source']."\n\n", FILE_APPEND) || die('uh oh'); |
|
37 | + $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function']; |
|
38 | 38 | unset($code[$methodName]['source']); |
39 | 39 | } |
40 | 40 | file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh'); |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | // generate the separate file with the xml-rpc server and dispatch map |
43 | 43 | |
44 | 44 | file_put_contents($targetServerFile, |
45 | - "<?php\n\n" . |
|
45 | + "<?php\n\n". |
|
46 | 46 | |
47 | - "require_once '$autoloader';\n\n" . |
|
47 | + "require_once '$autoloader';\n\n". |
|
48 | 48 | |
49 | - "require_once '$targetClassFile';\n\n" . |
|
49 | + "require_once '$targetClassFile';\n\n". |
|
50 | 50 | |
51 | 51 | // NB: since we are running the generated code within the same script, the existing CommentManager instance will be |
52 | 52 | // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | // Wrapper::$objHolder['xmlrpc_CommentManager_addComment'] = $cm; |
57 | 57 | // Wrapper::$objHolder['xmlrpc_CommentManager_getComments'] = $cm; |
58 | 58 | |
59 | - '$dm = ' . var_export($code, true) . ";\n" . |
|
60 | - '$s = new \PhpXmlRpc\Server($dm, false);' . "\n" . |
|
61 | - '$s->setDebug(2);' . "\n" . |
|
62 | - '$s->exception_handling = 1;' . "\n" . |
|
63 | - '$s->service();' . "\n" |
|
59 | + '$dm = '.var_export($code, true).";\n". |
|
60 | + '$s = new \PhpXmlRpc\Server($dm, false);'."\n". |
|
61 | + '$s->setDebug(2);'."\n". |
|
62 | + '$s->exception_handling = 1;'."\n". |
|
63 | + '$s->service();'."\n" |
|
64 | 64 | ) || die('uh oh'); |
65 | 65 | |
66 | 66 | // test that everything worked by running it in realtime |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * `$functions_parameters_type` and `$exception_handling` |
9 | 9 | */ |
10 | 10 | |
11 | -require_once __DIR__ . "/_prepend.php"; |
|
11 | +require_once __DIR__."/_prepend.php"; |
|
12 | 12 | |
13 | 13 | require_once __DIR__.'/methodProviders/CommentManager.php'; |
14 | 14 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | |
20 | 20 | $addComment_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString)); |
21 | 21 | |
22 | -$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, ' . |
|
22 | +$addComment_doc = 'Adds a comment to an item. The first parameter is the item ID, the second the name of the commenter, '. |
|
23 | 23 | 'and the third is the comment itself. Returns the number of comments against that ID.'; |
24 | 24 | |
25 | 25 | $getComments_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcString)); |
26 | 26 | |
27 | -$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct ' . |
|
27 | +$getComments_doc = 'Returns an array of comments for a given ID, which is the sole argument. Each array item is a struct '. |
|
28 | 28 | 'containing name and comment text.'; |
29 | 29 | |
30 | 30 | $srv = new Server(array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once __DIR__ . '/WebTestCase.php'; |
|
3 | +include_once __DIR__.'/WebTestCase.php'; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Tests for php files in the 'demo' directory |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | $this->args = argParser::getArgs(); |
13 | 13 | |
14 | 14 | // assumes HTTPURI to be in the form /tests/index.php?etc... |
15 | - $this->baseUrl = $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']); |
|
16 | - $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']); |
|
15 | + $this->baseUrl = $this->args['HTTPSERVER'].preg_replace('|\?.+|', '', $this->args['HTTPURI']); |
|
16 | + $this->coverageScriptUrl = 'http://'.$this->args['HTTPSERVER'].preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function testVardemo() |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | die(); |
22 | 22 | } |
23 | 23 | |
24 | -require_once __DIR__ . "/_prepend.php"; |
|
24 | +require_once __DIR__."/_prepend.php"; |
|
25 | 25 | |
26 | 26 | use PhpXmlRpc\PhpXmlRpc; |
27 | 27 | use PhpXmlRpc\Server; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } elseif ($_GET['FORCE_AUTH'] == 'Digest') { |
81 | 81 | if (empty($_SERVER['PHP_AUTH_DIGEST'])) { |
82 | 82 | header('HTTP/1.1 401 Unauthorized'); |
83 | - header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"'); |
|
83 | + header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="'.uniqid().'",opaque="'.md5('Phpxmlrpc Digest Realm').'"'); |
|
84 | 84 | die('Text visible if user hits Cancel button'); |
85 | 85 | } |
86 | 86 | } |