Passed
Push — master ( 8b6717...c8a221 )
by Gaetano
08:12
created
tests/index.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 // In case this file is made available on an open-access server, avoid it being useable by anyone who can not also
8 8
 // write a specific file to disk.
9 9
 // NB: keep filename, cookie name in sync with the code within the TestCase classes sending http requests to this file
10
-$idFile = sys_get_temp_dir() . '/phpunit_rand_id.txt';
10
+$idFile = sys_get_temp_dir().'/phpunit_rand_id.txt';
11 11
 $randId = isset($_COOKIE['PHPUNIT_RANDOM_TEST_ID']) ? $_COOKIE['PHPUNIT_RANDOM_TEST_ID'] : '';
12 12
 $fileId = file_exists($idFile) ? file_get_contents($idFile) : '';
13 13
 if ($randId == '' || $fileId == '' || $fileId !== $randId) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         chmod($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 0777);
32 32
     }
33 33
 
34
-    include_once __DIR__ . "/../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
34
+    include_once __DIR__."/../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
35 35
 }
36 36
 
37 37
 $targetFile = null;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 }
55 55
 
56 56
 if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
57
-    include_once __DIR__ . "/../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
57
+    include_once __DIR__."/../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
58 58
 }
59 59
 
60 60
 /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         } elseif ($_GET['FORCE_AUTH'] == 'Digest') {
88 88
             if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
89 89
                 header('HTTP/1.1 401 Unauthorized');
90
-                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"');
90
+                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="'.uniqid().'",opaque="'.md5('Phpxmlrpc Digest Realm').'"');
91 91
                 die('Text visible if user hits Cancel button');
92 92
             }
93 93
         }
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
     if (isset($_GET['FORCE_REDIRECT'])) {
96 96
         header('HTTP/1.0 302 Found');
97 97
         unset($_GET['FORCE_REDIRECT']);
98
-        header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : ''));
98
+        header('Location: '.$_SERVER['REQUEST_URI'].(count($_GET) ? '?'.http_build_query($_GET) : ''));
99 99
         die();
100 100
     }
101
-    if (isset($_GET['SLOW_LORIS']) && $_GET['SLOW_LORIS'] > 0) {
102
-        slowLoris((int)$_GET['SLOW_LORIS'], $s);
101
+    if (isset($_GET['SLOW_LORIS']) && $_GET['SLOW_LORIS']>0) {
102
+        slowLoris((int) $_GET['SLOW_LORIS'], $s);
103 103
         die();
104 104
     }
105 105
 }
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 {
114 114
     /// @todo as is, this method can not be used by eg. jsonrpc servers. We could look at the value $s::$responseClass
115 115
     ///       to improve that
116
-    $strings = array('<?xml version="1.0"?>','<methodResponse>','<params>','<param>','<value>','<string></string>','</value>','</param>','</params>','</methodResponse>');
116
+    $strings = array('<?xml version="1.0"?>', '<methodResponse>', '<params>', '<param>', '<value>', '<string></string>', '</value>', '</param>', '</params>', '</methodResponse>');
117 117
 
118 118
     header('Content-type: xml; charset=utf-8');
119
-    foreach($strings as $i => $string) {
119
+    foreach ($strings as $i => $string) {
120 120
         echo $string;
121 121
         flush();
122
-        if ($i < count($strings) && $secs > 0 && $secs <= 60) {
122
+        if ($i<count($strings) && $secs>0 && $secs<=60) {
123 123
             sleep($secs);
124 124
         }
125 125
     }
Please login to merge, or discard this patch.
tests/legacy_loader_test.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@  discard block
 block discarded – undo
6 6
 
7 7
 echo "Legacy Loader Test\n\n";
8 8
 
9
-include_once __DIR__ . '/../lib/xmlrpc.inc';
9
+include_once __DIR__.'/../lib/xmlrpc.inc';
10 10
 
11
-include_once __DIR__ . '/parse_args.php';
11
+include_once __DIR__.'/parse_args.php';
12 12
 
13 13
 $args = argParser::getArgs();
14
-$baseurl = 'http://' . $args['HTTPSERVER'] . str_replace('/server.php', '/legacy.php', $args['HTTPURI']);
14
+$baseurl = 'http://'.$args['HTTPSERVER'].str_replace('/server.php', '/legacy.php', $args['HTTPURI']);
15 15
 
16 16
 $randId = uniqid();
17
-file_put_contents(sys_get_temp_dir() . '/phpunit_rand_id.txt', $randId);
17
+file_put_contents(sys_get_temp_dir().'/phpunit_rand_id.txt', $randId);
18 18
 
19 19
 $client = new xmlrpc_client($baseurl);
20 20
 $client->setCookie('PHPUNIT_RANDOM_TEST_ID', $randId);
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 $req = new xmlrpcmsg('system.listMethods', array());
23 23
 $resp = $client->send($req);
24 24
 if ($resp->faultCode() !== 0) {
25
-    unlink(sys_get_temp_dir() . '/phpunit_rand_id.txt');
26
-    throw new \Exception("system.listMethods returned fault " . $resp->faultCode());
25
+    unlink(sys_get_temp_dir().'/phpunit_rand_id.txt');
26
+    throw new \Exception("system.listMethods returned fault ".$resp->faultCode());
27 27
 }
28 28
 echo ". 1/1 (100%)\n\n";
29 29
 
30 30
 echo "OK (1 test, 1 assertion)\n";
31 31
 
32
-unlink(sys_get_temp_dir() . '/phpunit_rand_id.txt');
32
+unlink(sys_get_temp_dir().'/phpunit_rand_id.txt');
Please login to merge, or discard this patch.
tests/13LegacyAPITest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/ServerAwareTestCase.php';
3
+include_once __DIR__.'/ServerAwareTestCase.php';
4 4
 
5 5
 /**
6 6
  * @todo Long-term, this should replace all testing of the legacy API done via the main test-suite...
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     {
15 15
         /// @todo pass on as cli args for the executed script all the args that are already parsed by now, plus $this->testId
16 16
 
17
-        exec('php ' . __DIR__ . '/legacy_loader_test.php', $out, $result);
17
+        exec('php '.__DIR__.'/legacy_loader_test.php', $out, $result);
18 18
 
19 19
         /// @todo dump output if in debug mode or if test fails
20 20
 
Please login to merge, or discard this patch.
tests/ServerAwareTestCase.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/LoggerAwareTestCase.php';
3
+include_once __DIR__.'/LoggerAwareTestCase.php';
4 4
 
5 5
 use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage;
6 6
 use PHPUnit\Framework\TestResult;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function _run($result = NULL)
32 32
     {
33
-        $this->testId = get_class($this) . '__' . $this->getName();
33
+        $this->testId = get_class($this).'__'.$this->getName();
34 34
 
35 35
         if ($result === NULL) {
36 36
             $result = $this->createResult();
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
         // Set up a database connection or other fixture which needs to be available.
64 64
         self::$randId = uniqid();
65
-        file_put_contents(sys_get_temp_dir() . '/phpunit_rand_id.txt', self::$randId);
65
+        file_put_contents(sys_get_temp_dir().'/phpunit_rand_id.txt', self::$randId);
66 66
     }
67 67
 
68 68
     public static function tear_down_after_class()
69 69
     {
70
-        if (is_file(sys_get_temp_dir() . '/phpunit_rand_id.txt')) {
71
-            unlink(sys_get_temp_dir() . '/phpunit_rand_id.txt');
70
+        if (is_file(sys_get_temp_dir().'/phpunit_rand_id.txt')) {
71
+            unlink(sys_get_temp_dir().'/phpunit_rand_id.txt');
72 72
         }
73 73
 
74 74
         parent::tear_down_after_class();
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
         parent::set_up();
80 80
 
81 81
         // assumes HTTPURI to be in the form /tests/index.php?etc...
82
-        $this->baseUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
83
-        $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
82
+        $this->baseUrl = 'http://'.$this->args['HTTPSERVER'].preg_replace('|\?.+|', '', $this->args['HTTPURI']);
83
+        $this->coverageScriptUrl = 'http://'.$this->args['HTTPSERVER'].preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
84 84
     }
85 85
 
86 86
     protected function getClient()
87 87
     {
88 88
         $server = explode(':', $this->args['HTTPSERVER']);
89 89
         /// @todo use the non-legacy API calling convention, except in a dedicated test
90
-        if (count($server) > 1) {
90
+        if (count($server)>1) {
91 91
             $client = new xmlrpc_client($this->args['HTTPURI'], $server[0], $server[1]);
92 92
         } else {
93 93
             $client = new xmlrpc_client($this->args['HTTPURI'], $this->args['HTTPSERVER']);
Please login to merge, or discard this patch.
tests/09HTTPTest.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once __DIR__ . '/08ServerTest.php';
3
+include_once __DIR__.'/08ServerTest.php';
4 4
 
5 5
 /**
6 6
  * Tests which stress http features of the library.
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $methods = array();
36 36
         // as long as we are descendants, get_class_methods will list private/protected methods
37
-        foreach(get_class_methods('ServerTest') as $method)
37
+        foreach (get_class_methods('ServerTest') as $method)
38 38
         {
39 39
             if (strpos($method, 'test') === 0 && !in_array($method, $this->unsafeMethods))
40 40
             {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         // this checks for a non-failed call
149 149
         $time = microtime(true);
150 150
         $this->send($m);
151
-        $time = microtime(true) - $time;
151
+        $time = microtime(true)-$time;
152 152
         $this->assertGreaterThan(1.0, $time);
153 153
         $this->assertLessThan(2.0, $time);
154 154
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $m = new xmlrpcmsg('tests.sleep', array(new xmlrpcval(5, 'int')));
157 157
         $time = microtime(true);
158 158
         $r = $this->send($m, array(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['http_error'], PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['curl_fail']));
159
-        $time = microtime(true) - $time;
159
+        $time = microtime(true)-$time;
160 160
         $this->assertGreaterThan(2.0, $time);
161 161
         $this->assertLessThan(4.0, $time);
162 162
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         $this->addQueryParams(array('SLOW_LORIS' => 1));
177 177
         $time = microtime(true);
178 178
         $this->send($m, array(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['http_error'], PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['curl_fail']));
179
-        $time = microtime(true) - $time;
179
+        $time = microtime(true)-$time;
180 180
         $this->assertGreaterThan(2.0, $time);
181 181
         $this->assertLessThan(4.0, $time);
182 182
     }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                 preg_match('/ubunutu([0-9]+)/', $output[0], $matches);
356 356
                 $ubuntuVersion = @$matches[1];
357 357
             }
358
-            if ($ubuntuVersion >= 20 && $this->args['SSLVERSION'] != 6) {
358
+            if ($ubuntuVersion>=20 && $this->args['SSLVERSION'] != 6) {
359 359
                 $this->markTestSkipped('HTTPS via Socket known to fail on php less than 7.2 on Ubuntu 20 and higher');
360 360
             }
361 361
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
             $this->client->setOption(\PhpXmlRpc\Client::OPT_EXTRA_SOCKET_OPTS,
381 381
                 array('ssl' => array(
382 382
                     // security level is available as of php 7.2.0 + openssl 1.1.0 according to the docs
383
-                    'security_level' => min(1 + $version[1], 5),
383
+                    'security_level' => min(1+$version[1], 5),
384 384
                     // capture_session_meta was deprecated in php 7.0
385 385
                     //'capture_session_meta' => true,
386 386
                 ))
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
         if (version_compare(PHP_VERSION, '8.0', '>=') && $this->args['SSLVERSION'] == 0)
529 529
         {
530 530
             $version = explode('.', PHP_VERSION);
531
-            $this->client->setSSLVersion(min(4 + $version[1], 7));
531
+            $this->client->setSSLVersion(min(4+$version[1], 7));
532 532
         }
533 533
 
534 534
         $this->$method();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -304,8 +304,7 @@  discard block
 block discarded – undo
304 304
         if (!function_exists('curl_init'))
305 305
         {
306 306
             $this->markTestSkipped('CURL missing: cannot test https functionality');
307
-        }
308
-        else if ($this->args['HTTPSSERVER'] == '')
307
+        } else if ($this->args['HTTPSSERVER'] == '')
309 308
         {
310 309
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
311 310
         }
@@ -480,8 +479,7 @@  discard block
 block discarded – undo
480 479
         if (!function_exists('curl_init'))
481 480
         {
482 481
             $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
483
-        }
484
-        else if ($this->args['PROXYSERVER'] == '')
482
+        } else if ($this->args['PROXYSERVER'] == '')
485 483
         {
486 484
             $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. http 1.1');
487 485
         }
@@ -505,12 +503,10 @@  discard block
 block discarded – undo
505 503
         if (!function_exists('curl_init'))
506 504
         {
507 505
             $this->markTestSkipped('CURL missing: cannot test https w. proxy');
508
-        }
509
-        else if ($this->args['PROXYSERVER'] == '')
506
+        } else if ($this->args['PROXYSERVER'] == '')
510 507
         {
511 508
             $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. https');
512
-        }
513
-        else if ($this->args['HTTPSSERVER'] == '')
509
+        } else if ($this->args['HTTPSSERVER'] == '')
514 510
         {
515 511
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
516 512
         }
Please login to merge, or discard this patch.
lib/xmlrpcs.inc 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function echoInput()
56 56
     {
57
-        $r = new PhpXmlRpc\Response(new PhpXmlRpc\Value("'Aha said I: '" . file_get_contents('php://input'), 'string'));
57
+        $r = new PhpXmlRpc\Response(new PhpXmlRpc\Value("'Aha said I: '".file_get_contents('php://input'), 'string'));
58 58
         print $r->serialize();
59 59
     }
60 60
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function &__get($name)
67 67
     {
68
-        switch($name) {
68
+        switch ($name) {
69 69
             case 'dmap':
70 70
                 return $this->dmap;
71 71
             default:
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
     Server::xmlrpc_debugmsg($m);
97 97
 }
98 98
 
99
-function _xmlrpcs_getCapabilities($server, $m=null)
99
+function _xmlrpcs_getCapabilities($server, $m = null)
100 100
 {
101 101
     return Server::_xmlrpcs_getCapabilities($server, $m);
102 102
 }
103 103
 
104
-$_xmlrpcs_listMethods_sig=array(array(\PhpXmlRpc\Value::$xmlrpcArray));
105
-$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
106
-$_xmlrpcs_listMethods_sdoc=array(array('list of method names'));
107
-function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing
104
+$_xmlrpcs_listMethods_sig = array(array(\PhpXmlRpc\Value::$xmlrpcArray));
105
+$_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch';
106
+$_xmlrpcs_listMethods_sdoc = array(array('list of method names'));
107
+function _xmlrpcs_listMethods($server, $m = null) // if called in plain php values mode, second param is missing
108 108
 {
109 109
     return Server::_xmlrpcs_listMethods($server, $m);
110 110
 }
111 111
 
112
-$_xmlrpcs_methodSignature_sig=array(array(\PhpXmlRpc\Value::$xmlrpcArray, \PhpXmlRpc\Value::$xmlrpcString));
113
-$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
114
-$_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described'));
112
+$_xmlrpcs_methodSignature_sig = array(array(\PhpXmlRpc\Value::$xmlrpcArray, \PhpXmlRpc\Value::$xmlrpcString));
113
+$_xmlrpcs_methodSignature_doc = 'Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
114
+$_xmlrpcs_methodSignature_sdoc = array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described'));
115 115
 function _xmlrpcs_methodSignature($server, $m)
116 116
 {
117 117
     return Server::_xmlrpcs_methodSignature($server, $m);
118 118
 }
119 119
 
120
-$_xmlrpcs_methodHelp_sig=array(array(\PhpXmlRpc\Value::$xmlrpcString, \PhpXmlRpc\Value::$xmlrpcString));
121
-$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
122
-$_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described'));
120
+$_xmlrpcs_methodHelp_sig = array(array(\PhpXmlRpc\Value::$xmlrpcString, \PhpXmlRpc\Value::$xmlrpcString));
121
+$_xmlrpcs_methodHelp_doc = 'Returns help text if defined for the method passed, otherwise returns an empty string';
122
+$_xmlrpcs_methodHelp_sdoc = array(array('method description', 'name of the method to be described'));
123 123
 function _xmlrpcs_methodHelp($server, $m)
124 124
 {
125 125
     return Server::_xmlrpcs_methodHelp($server, $m);
Please login to merge, or discard this patch.
demo/client/codegen.php 1 patch
Spacing   +7 added lines, -7 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
 /**
5 5
  * Demoing the code-generation capabilities of the library: create a client class which exposes a bunch of methods
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 );
27 27
 
28 28
 // the generated code does not have an autoloader included - we need to add in one
29
-$autoloader = __DIR__ . "/_prepend.php";
29
+$autoloader = __DIR__."/_prepend.php";
30 30
 
31
-$targetFile = sys_get_temp_dir() . '/MyClient.php';
31
+$targetFile = sys_get_temp_dir().'/MyClient.php';
32 32
 $generated = file_put_contents($targetFile,
33
-    "<?php\n\n" .
34
-    "require_once '$autoloader';\n\n" .
33
+    "<?php\n\n".
34
+    "require_once '$autoloader';\n\n".
35 35
     $code['code']
36 36
 );
37 37
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 $client = new MyClient();
52 52
 $sorted = $client->examples_sortByAge(array(
53 53
     array('name' => 'Dave', 'age' => 24),
54
-    array('name' => 'Edd',  'age' => 45),
55
-    array('name' => 'Joe',  'age' => 37),
54
+    array('name' => 'Edd', 'age' => 45),
55
+    array('name' => 'Joe', 'age' => 37),
56 56
     array('name' => 'Fred', 'age' => 27),
57 57
 ));
58 58
 
Please login to merge, or discard this patch.
demo/server/codegen.php 1 patch
Spacing   +21 added lines, -21 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
 /**
5 5
  * Demoing the code-generation capabilities of the library: create all that is required to expose as xml-rpc methods
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use PhpXmlRpc\Wrapper;
14 14
 
15 15
 // CommentManager is the "xml-rpc-unaware" class, whose methods we want to make accessible via xml-rpc calls
16
-$cm = new CommentManager(sys_get_temp_dir() . "/comments.db");
16
+$cm = new CommentManager(sys_get_temp_dir()."/comments.db");
17 17
 
18 18
 // analyze the CommentManager instance and generate both code defining stub-methods and a dispatch map for the xml-rpc Server
19 19
 $w = new Wrapper();
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 // and a controller, to be accessed from the internet. This split allows to a) hand-edit the controller code if needed,
32 32
 // and b) later regenerate the stub-methods-holder and dispatch map without touching the controller.
33 33
 // NB: good security practices dictate that none of those files should be writeable by the webserver user account
34
-$targetClassFile = sys_get_temp_dir() . '/MyServerClass.php';
35
-$targetDispatchMapFile = sys_get_temp_dir() . '/myServerDispatchMap.php';
36
-$targetControllerFile = sys_get_temp_dir() . '/myServerController.php';
34
+$targetClassFile = sys_get_temp_dir().'/MyServerClass.php';
35
+$targetDispatchMapFile = sys_get_temp_dir().'/myServerDispatchMap.php';
36
+$targetControllerFile = sys_get_temp_dir().'/myServerController.php';
37 37
 
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
 block discarded – undo
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
Please login to merge, or discard this patch.
demo/server/discuss.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
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
 
15 15
 use PhpXmlRpc\Server;
16 16
 use PhpXmlRpc\Value;
17 17
 
18
-$manager = new CommentManager(sys_get_temp_dir() . "/comments.db");
18
+$manager = new CommentManager(sys_get_temp_dir()."/comments.db");
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();
Please login to merge, or discard this patch.