@@ -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 how to inject a custom logger for use by the library |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | // logger API |
22 | 22 | public function debug($message, $context = array()) |
23 | 23 | { |
24 | - $this->debugBuffer .= $message . "\n"; |
|
24 | + $this->debugBuffer .= $message."\n"; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function error($message, $context = array()) |
28 | 28 | { |
29 | - $this->errorBuffer .= $message . "\n"; |
|
29 | + $this->errorBuffer .= $message."\n"; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function warning($message, $context = array()) |
33 | 33 | { |
34 | - $this->warningBuffer .= $message . "\n"; |
|
34 | + $this->warningBuffer .= $message."\n"; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function getDebug() |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | $input = array( |
64 | 64 | array('name' => 'Dave', 'age' => 24), |
65 | - array('name' => 'Edd', 'age' => 45), |
|
66 | - array('name' => 'Joe', 'age' => 37), |
|
65 | + array('name' => 'Edd', 'age' => 45), |
|
66 | + array('name' => 'Joe', 'age' => 37), |
|
67 | 67 | array('name' => 'Fred', 'age' => 27), |
68 | 68 | ); |
69 | 69 | |
@@ -85,6 +85,6 @@ discard block |
||
85 | 85 | $response = $client->send($request); |
86 | 86 | output("Response received.<br>"); |
87 | 87 | |
88 | -output("The client error info is:<pre>\n" . $logger->getError() . "\n</pre>"); |
|
89 | -output("The client warning info is:<pre>\n" . $logger->getWarning() . "\n</pre>"); |
|
90 | -output("The client debug info is:<pre>\n" . $logger->getDebug() . "\n</pre>"); |
|
88 | +output("The client error info is:<pre>\n".$logger->getError()."\n</pre>"); |
|
89 | +output("The client warning info is:<pre>\n".$logger->getWarning()."\n</pre>"); |
|
90 | +output("The client debug info is:<pre>\n".$logger->getDebug()."\n</pre>"); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | if ($response->faultCode()) { |
29 | 29 | throw new HttpException(502, $response->faultString()); |
30 | 30 | } else { |
31 | - return new Response("<html><body>State number $stateNo is: " . $response->value()->scalarVal() . '</body></html>'); |
|
31 | + return new Response("<html><body>State number $stateNo is: ".$response->value()->scalarVal().'</body></html>'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -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 all that is required to expose as xml-rpc methods |
@@ -38,33 +38,33 @@ discard block |
||
38 | 38 | // generate a file with a class definition |
39 | 39 | |
40 | 40 | // the generated code does not have an autoloader included - we need to add in one |
41 | -$autoloader = __DIR__ . "/_prepend.php"; |
|
41 | +$autoloader = __DIR__."/_prepend.php"; |
|
42 | 42 | |
43 | 43 | file_put_contents($targetClassFile, |
44 | - "<?php\n\n" . |
|
45 | - "require_once '$autoloader';\n\n" . |
|
44 | + "<?php\n\n". |
|
45 | + "require_once '$autoloader';\n\n". |
|
46 | 46 | "class MyServerClass\n{\n\n" |
47 | 47 | ) || die('uh oh'); |
48 | 48 | |
49 | 49 | // we mangle a bit the code we get from wrapPhpClass to turn it into a php class definition instead of a bunch of functions |
50 | 50 | |
51 | -foreach($code as $methodName => $methodDef) { |
|
52 | - file_put_contents($targetClassFile, ' ' . str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source']) . "\n\n", FILE_APPEND) || die('uh oh'); |
|
53 | - $code[$methodName]['function'] = 'MyServerClass::' . $methodDef['function']; |
|
51 | +foreach ($code as $methodName => $methodDef) { |
|
52 | + file_put_contents($targetClassFile, ' '.str_replace(array('function ', "\n"), array('public static function ', "\n "), $methodDef['source'])."\n\n", FILE_APPEND) || die('uh oh'); |
|
53 | + $code[$methodName]['function'] = 'MyServerClass::'.$methodDef['function']; |
|
54 | 54 | unset($code[$methodName]['source']); |
55 | 55 | } |
56 | 56 | file_put_contents($targetClassFile, "}\n", FILE_APPEND) || die('uh oh'); |
57 | 57 | |
58 | 58 | // generate separate files with the xml-rpc server instantiation and its dispatch map |
59 | 59 | |
60 | -file_put_contents($targetDispatchMapFile, "<?php\n\nreturn " . var_export($code, true) . ";\n"); |
|
60 | +file_put_contents($targetDispatchMapFile, "<?php\n\nreturn ".var_export($code, true).";\n"); |
|
61 | 61 | |
62 | 62 | file_put_contents($targetControllerFile, |
63 | - "<?php\n\n" . |
|
63 | + "<?php\n\n". |
|
64 | 64 | |
65 | - "require_once '$autoloader';\n\n" . |
|
65 | + "require_once '$autoloader';\n\n". |
|
66 | 66 | |
67 | - "require_once '$targetClassFile';\n\n" . |
|
67 | + "require_once '$targetClassFile';\n\n". |
|
68 | 68 | |
69 | 69 | // NB: since we are running the generated code within the same script, the existing CommentManager instance will be |
70 | 70 | // available for usage by the methods of MyServerClass, as we keep a reference to them within the variable Wrapper::$objHolder |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | // Wrapper::holdObject('xmlrpc_CommentManager_addComment', $cm); |
75 | 75 | // Wrapper::holdObject('xmlrpc_CommentManager_getComments', $cm); |
76 | 76 | |
77 | - "\$dm = require_once '$targetDispatchMapFile';\n" . |
|
78 | - '$s = new \PhpXmlRpc\Server($dm, false);' . "\n\n" . |
|
79 | - '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!' . "\n" . |
|
80 | - '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);' . "\n" . |
|
81 | - '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);' . "\n\n" . |
|
82 | - '$s->service();' . "\n" |
|
77 | + "\$dm = require_once '$targetDispatchMapFile';\n". |
|
78 | + '$s = new \PhpXmlRpc\Server($dm, false);'."\n\n". |
|
79 | + '// NB: do not leave these 2 debug lines enabled on publicly accessible servers!'."\n". |
|
80 | + '$s->setOption(\PhpXmlRpc\Server::OPT_DEBUG, 2);'."\n". |
|
81 | + '$s->setOption(\PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, 1);'."\n\n". |
|
82 | + '$s->service();'."\n" |
|
83 | 83 | ) || die('uh oh'); |
84 | 84 | |
85 | 85 | // test that everything worked by running it in realtime (note that this script will return an xml-rpc error message if |