Passed
Push — master ( fc8ac8...484467 )
by Gaetano
11:38 queued 01:36
created
tests/09HTTPTest.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -201,8 +201,7 @@  discard block
 block discarded – undo
201 201
         {
202 202
             $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
203 203
             return;
204
-        }
205
-        else if ($this->args['PROXYSERVER'] == '')
204
+        } else if ($this->args['PROXYSERVER'] == '')
206 205
         {
207 206
             $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. http 1.1');
208 207
             return;
@@ -226,8 +225,7 @@  discard block
 block discarded – undo
226 225
         {
227 226
             $this->markTestSkipped('CURL missing: cannot test https functionality');
228 227
             return;
229
-        }
230
-        else if ($this->args['HTTPSSERVER'] == '')
228
+        } else if ($this->args['HTTPSSERVER'] == '')
231 229
         {
232 230
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
233 231
             return;
@@ -278,13 +276,11 @@  discard block
 block discarded – undo
278 276
         {
279 277
             $this->markTestSkipped('CURL missing: cannot test https w. proxy');
280 278
             return;
281
-        }
282
-        else if ($this->args['PROXYSERVER'] == '')
279
+        } else if ($this->args['PROXYSERVER'] == '')
283 280
         {
284 281
             $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. https');
285 282
             return;
286
-        }
287
-        else if ($this->args['HTTPSSERVER'] == '')
283
+        } else if ($this->args['HTTPSSERVER'] == '')
288 284
         {
289 285
             $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
290 286
             return;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 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.
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         );
26 26
 
27 27
         $methods = array();
28
-        foreach(get_class_methods('ServerTest') as $method)
28
+        foreach (get_class_methods('ServerTest') as $method)
29 29
         {
30 30
             if (strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
31 31
             {
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         if (version_compare(PHP_VERSION, '8.0', '>=') && $this->args['SSLVERSION'] == 0)
296 296
         {
297 297
             $version = explode('.', PHP_VERSION);
298
-            $this->client->setSSLVersion(min(4 + $version[1], 7));
298
+            $this->client->setSSLVersion(min(4+$version[1], 7));
299 299
         }
300 300
 
301 301
         $this->$method();
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                 preg_match('/ubunutu([0-9]+)/', $output[0], $matches);
326 326
                 $ubuntuVersion = @$matches[1];
327 327
             }
328
-            if ($ubuntuVersion >= 20) {
328
+            if ($ubuntuVersion>=20) {
329 329
                 $this->markTestSkipped('HTTPS via Socket known to fail on php less than 7.2 on Ubuntu 20 and higher');
330 330
                 return;
331 331
             }
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
         {
346 346
             $version = explode('.', PHP_VERSION);
347 347
             $this->client->setOption(\PhpXmlRpc\Client::OPT_EXTRA_SOCKET_OPTS,
348
-                array('ssl' => array('security_level' => 2 + $version[1])));
348
+                array('ssl' => array('security_level' => 2+$version[1])));
349 349
             /// @todo we should probably look deeper into the Apache config / ssl version in use to find out why this
350 350
             ///       does not work well with TLS < 1.2
351 351
             if ($this->args['SSLVERSION'] == 0) {
352
-                $this->client->setSSLVersion(min(5 + $version[1], 7));
352
+                $this->client->setSSLVersion(min(5+$version[1], 7));
353 353
             }
354 354
         }
355 355
         $this->$method();
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         if (version_compare(PHP_VERSION, '8.0', '>=') && $this->args['SSLVERSION'] == 0)
390 390
         {
391 391
             $version = explode('.', PHP_VERSION);
392
-            $this->client->setSSLVersion(min(4 + $version[1], 7));
392
+            $this->client->setSSLVersion(min(4+$version[1], 7));
393 393
         }
394 394
 
395 395
         $this->$method();
Please login to merge, or discard this patch.
demo/server/server.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 }
26 26
 
27
-require_once __DIR__ . "/_prepend.php";
27
+require_once __DIR__."/_prepend.php";
28 28
 
29 29
 use PhpXmlRpc\PhpXmlRpc;
30 30
 use PhpXmlRpc\Server;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         } elseif ($_GET['FORCE_AUTH'] == 'Digest') {
84 84
             if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
85 85
                 header('HTTP/1.1 401 Unauthorized');
86
-                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"');
86
+                header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="'.uniqid().'",opaque="'.md5('Phpxmlrpc Digest Realm').'"');
87 87
                 die('Text visible if user hits Cancel button');
88 88
             }
89 89
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     if (isset($_GET['FORCE_REDIRECT'])) {
92 92
         header('HTTP/1.0 302 Found');
93 93
         unset($_GET['FORCE_REDIRECT']);
94
-        header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : ''));
94
+        header('Location: '.$_SERVER['REQUEST_URI'].(count($_GET) ? '?'.http_build_query($_GET) : ''));
95 95
         die();
96 96
     }
97 97
 }
Please login to merge, or discard this patch.
demo/client/_prepend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 }
9 9
 
10 10
 // Use the custom class autoloader. These two lines are not needed when the phpxmlrpc library is installed using Composer
11
-include_once __DIR__ . '/../../src/Autoloader.php';
11
+include_once __DIR__.'/../../src/Autoloader.php';
12 12
 PhpXmlRpc\Autoloader::register();
13 13
 
14 14
 // Let unit tests run against localhost, 'plain' demos against a known public server
@@ -22,5 +22,5 @@  discard block
 block discarded – undo
22 22
 function output($text)
23 23
 {
24 24
     /// @todo we should only strip html tags, and let through all xml tags
25
-    echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>','<br>'), "\n", $text)) : $text;
25
+    echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>', '<br>'), "\n", $text)) : $text;
26 26
 }
Please login to merge, or discard this patch.
tests/05LoggerTest.php 1 patch
Spacing   +4 added lines, -4 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__ . '/PolyfillTestCase.php';
3
+include_once __DIR__.'/PolyfillTestCase.php';
4 4
 
5 5
 use PhpXmlRpc\Helper\Charset;
6 6
 use PhpXmlRpc\Helper\Http;
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
         $l = $h->getLogger();
39 39
         Http::setLogger($this);
40 40
 
41
-        $s = "HTTP/1.0 200 OK\r\n" .
42
-            "Content-Type: unknown\r\n" .
43
-            "\r\n" .
41
+        $s = "HTTP/1.0 200 OK\r\n".
42
+            "Content-Type: unknown\r\n".
43
+            "\r\n".
44 44
             "body";
45 45
         ob_start();
46 46
         $h->parseResponseHeaders($s, false, 1);
Please login to merge, or discard this patch.
tests/12ExtraFilesTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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 'extras' directory.
Please login to merge, or discard this patch.
tests/10DemofilesTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
tests/11DebuggerTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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 the bundled debugger.
Please login to merge, or discard this patch.
tests/01CharsetTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * @author JoakimLofgren
4 4
  */
5 5
 
6
-include_once __DIR__ . '/PolyfillTestCase.php';
6
+include_once __DIR__.'/PolyfillTestCase.php';
7 7
 
8 8
 use PhpXmlRpc\Helper\Charset;
9 9
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
     public function testUtf8ToLatin1All()
49 49
     {
50 50
         $latinString = "\n\r\t";
51
-        for($i = 32; $i < 127; $i++) {
51
+        for ($i = 32; $i<127; $i++) {
52 52
             $latinString .= chr($i);
53 53
         }
54
-        for($i = 160; $i < 256; $i++) {
54
+        for ($i = 160; $i<256; $i++) {
55 55
             $latinString .= chr($i);
56 56
         }
57 57
 
Please login to merge, or discard this patch.
src/Helper/Http.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 
27 27
         // read chunk-size, chunk-extension (if any) and crlf
28 28
         // get the position of the linebreak
29
-        $chunkEnd = strpos($buffer, "\r\n") + 2;
29
+        $chunkEnd = strpos($buffer, "\r\n")+2;
30 30
         $temp = substr($buffer, 0, $chunkEnd);
31 31
         $chunkSize = hexdec(trim($temp));
32 32
         $chunkStart = $chunkEnd;
33
-        while ($chunkSize > 0) {
34
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize);
33
+        while ($chunkSize>0) {
34
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize);
35 35
 
36 36
             // just in case we got a broken connection
37 37
             if ($chunkEnd == false) {
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
             }
44 44
 
45 45
             // read chunk-data and crlf
46
-            $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
46
+            $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
47 47
             // append chunk-data to entity-body
48 48
             $new .= $chunk;
49 49
             // length := length + chunk-size
50 50
             $length += strlen($chunk);
51 51
             // read chunk-size and crlf
52
-            $chunkStart = $chunkEnd + 2;
52
+            $chunkStart = $chunkEnd+2;
53 53
 
54
-            $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2;
54
+            $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2;
55 55
             if ($chunkEnd == false) {
56 56
                 break; // just in case we got a broken connection
57 57
             }
58
-            $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
58
+            $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart);
59 59
             $chunkSize = hexdec(trim($temp));
60 60
             $chunkStart = $chunkEnd;
61 61
         }
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
             // Look for CR/LF or simple LF as line separator (even though it is not valid http)
85 85
             $pos = strpos($data, "\r\n\r\n");
86 86
             if ($pos || is_int($pos)) {
87
-                $bd = $pos + 4;
87
+                $bd = $pos+4;
88 88
             } else {
89 89
                 $pos = strpos($data, "\n\n");
90 90
                 if ($pos || is_int($pos)) {
91
-                    $bd = $pos + 2;
91
+                    $bd = $pos+2;
92 92
                 } else {
93 93
                     // No separation between response headers and body: fault?
94 94
                     $bd = 0;
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
                 // this filters out all http headers from proxy. maybe we could take them into account, too?
99 99
                 $data = substr($data, $bd);
100 100
             } else {
101
-                $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
102
-                throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
101
+                $this->getLogger()->error('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed');
102
+                throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
103 103
             }
104 104
         }
105 105
 
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
         }
133 133
 
134 134
         if ($httpResponse['status_code'] !== '200') {
135
-            $errstr = substr($data, 0, strpos($data, "\n") - 1);
136
-            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
137
-            throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
135
+            $errstr = substr($data, 0, strpos($data, "\n")-1);
136
+            $this->getLogger()->error('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr);
137
+            throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
138 138
         }
139 139
 
140 140
         // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http)
141 141
         $pos = strpos($data, "\r\n\r\n");
142 142
         if ($pos || is_int($pos)) {
143
-            $bd = $pos + 4;
143
+            $bd = $pos+4;
144 144
         } else {
145 145
             $pos = strpos($data, "\n\n");
146 146
             if ($pos || is_int($pos)) {
147
-                $bd = $pos + 2;
147
+                $bd = $pos+2;
148 148
             } else {
149 149
                 // No separation between response headers and body: fault?
150 150
                 // we could take some action here instead of going on...
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         foreach ($ar as $line) {
159 159
             // take care of (multi-line) headers and cookies
160 160
             $arr = explode(':', $line, 2);
161
-            if (count($arr) > 1) {
161
+            if (count($arr)>1) {
162 162
                 /// @todo according to https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4, we should reject with error
163 163
                 ///       400 any messages where a space is present between the header name and colon
164 164
                 $headerName = strtolower(trim($arr[0]));
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                     $cookie = $arr[1];
167 167
                     // glue together all received cookies, using a comma to separate them (same as php does with getallheaders())
168 168
                     if (isset($httpResponse['headers'][$headerName])) {
169
-                        $httpResponse['headers'][$headerName] .= ', ' . trim($cookie);
169
+                        $httpResponse['headers'][$headerName] .= ', '.trim($cookie);
170 170
                     } else {
171 171
                         $httpResponse['headers'][$headerName] = trim($cookie);
172 172
                     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             } elseif (isset($headerName)) {
198 198
                 /// @todo improve this: 1. check that the line starts with a space or tab; 2. according to
199 199
                 ///       https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4, we should flat out refuse these messages
200
-                $httpResponse['headers'][$headerName] .= ' ' . trim($line);
200
+                $httpResponse['headers'][$headerName] .= ' '.trim($line);
201 201
             }
202 202
         }
203 203
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             // Decode chunked encoding sent by http 1.1 servers
221 221
             if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') {
222 222
                 if (!$data = static::decodeChunked($data)) {
223
-                    $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
223
+                    $this->getLogger()->error('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server');
224 224
                     throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']);
225 225
                 }
226 226
             }
@@ -235,19 +235,19 @@  discard block
 block discarded – undo
235 235
                         if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
236 236
                             $data = $degzdata;
237 237
                             if ($debug) {
238
-                                $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
238
+                                $this->getLogger()->debug("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
239 239
                             }
240 240
                         } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
241 241
                             $data = $degzdata;
242 242
                             if ($debug) {
243
-                                $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
243
+                                $this->getLogger()->debug("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---");
244 244
                             }
245 245
                         } else {
246
-                            $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
246
+                            $this->getLogger()->error('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server');
247 247
                             throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']);
248 248
                         }
249 249
                     } else {
250
-                        $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
250
+                        $this->getLogger()->error('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
251 251
                         throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']);
252 252
                     }
253 253
                 }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     public function parseAcceptHeader($header)
268 268
     {
269 269
         $accepted = array();
270
-        foreach(explode(',', $header) as $c) {
270
+        foreach (explode(',', $header) as $c) {
271 271
             if (preg_match('/^([^;]+); *q=([0-9.]+)/', $c, $matches)) {
272 272
                 $c = $matches[1];
273 273
                 $w = $matches[2];
Please login to merge, or discard this patch.