@@ -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( |