Passed
Push — master ( d68788...24898d )
by Gaetano
10:00
created
demo/server/codegen.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.