@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | setlocale(LC_ALL, "C"); |
53 | 53 | } |
54 | 54 | |
55 | - for ($i = 32; $i < 256; $i ++) { |
|
56 | - if (($allowed == RandomString::ASCII && ! ctype_alnum(chr($i))) || (! ctype_print(chr($i)))) { |
|
55 | + for ($i = 32; $i < 256; $i++) { |
|
56 | + if (($allowed == RandomString::ASCII && !ctype_alnum(chr($i))) || (!ctype_print(chr($i)))) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | $allowedChars[] = $i; |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $i = $length; |
68 | 68 | while ($i > 0) { |
69 | 69 | $index = mt_rand(0, count($allowedChars) - 1); |
70 | - if (! $repeatable && in_array($index, $used)) { |
|
70 | + if (!$repeatable && in_array($index, $used)) { |
|
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | $string .= chr($allowedChars[$index]); |
74 | 74 | $used[] = $i; |
75 | - $i --; |
|
75 | + $i--; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $string; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $localeData = explode(';', $localeSaved); |
90 | 90 | |
91 | 91 | foreach ($localeData as $identifier) { |
92 | - if (! strchr($identifier, '=')) { |
|
92 | + if (!strchr($identifier, '=')) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | $type = $value = null; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public static function hasElement($array, $element): bool |
41 | 41 | { |
42 | - if (! is_array($array)) |
|
42 | + if (!is_array($array)) |
|
43 | 43 | return false; |
44 | 44 | |
45 | 45 | return isset($array[$element]) && strlen($array[$element]) > 0; |
@@ -39,8 +39,9 @@ |
||
39 | 39 | */ |
40 | 40 | public static function hasElement($array, $element): bool |
41 | 41 | { |
42 | - if (! is_array($array)) |
|
43 | - return false; |
|
42 | + if (! is_array($array)) { |
|
43 | + return false; |
|
44 | + } |
|
44 | 45 | |
45 | 46 | return isset($array[$element]) && strlen($array[$element]) > 0; |
46 | 47 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public function get($key) |
62 | 62 | { |
63 | - if (! isset($_SESSION[$key])) { |
|
63 | + if (!isset($_SESSION[$key])) { |
|
64 | 64 | return null; |
65 | 65 | } |
66 | 66 |
@@ -22,7 +22,8 @@ |
||
22 | 22 | * Create a new session provider |
23 | 23 | */ |
24 | 24 | public function __construct() |
25 | - {} |
|
25 | + { |
|
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * Create session |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->handle = $clientHandle; |
37 | 37 | $this->conntected = false; |
38 | 38 | |
39 | - if (! is_resource($clientHandle)) { |
|
39 | + if (!is_resource($clientHandle)) { |
|
40 | 40 | parent::__construct($endpoint); |
41 | 41 | } |
42 | 42 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function connect() |
50 | 50 | { |
51 | - if (! @socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
51 | + if (!@socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
52 | 52 | $code = socket_last_error($this->handle); |
53 | 53 | throw new SocketException(socket_strerror($code), array(), $code); |
54 | 54 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function disconnect() |
64 | 64 | { |
65 | - if (! $this->conntected) { |
|
65 | + if (!$this->conntected) { |
|
66 | 66 | throw new SocketException("Socket is not connected"); |
67 | 67 | } |
68 | 68 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function isWriteable() |
98 | 98 | { |
99 | - if (! $this->isConnected()) { |
|
99 | + if (!$this->isConnected()) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 |
@@ -475,6 +475,7 @@ |
||
475 | 475 | |
476 | 476 | /** |
477 | 477 | * Adjust the headers by injecting default values for missing keys. |
478 | + * @param string $requestType |
|
478 | 479 | */ |
479 | 480 | private function adjustHeaders($requestType) |
480 | 481 | { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $ms = $this->appendPayloadToRequest($ms); |
207 | 207 | |
208 | - if (! $this->isConnected()) { |
|
208 | + if (!$this->isConnected()) { |
|
209 | 209 | $this->connect(); |
210 | 210 | } |
211 | 211 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | private function checkConnection($start) |
232 | 232 | { |
233 | - if (! $this->ready()) { |
|
233 | + if (!$this->ready()) { |
|
234 | 234 | if (time() - $start > $this->timeout) { |
235 | 235 | $this->disconnect(); |
236 | 236 | throw new HttpException("Connection timed out!"); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $numBytes = 1; |
338 | 338 | $start = time(); |
339 | 339 | while (true) { |
340 | - if (! $this->checkConnection($start)) { |
|
340 | + if (!$this->checkConnection($start)) { |
|
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $start = time(); // we have readen something => adjust timeout start point |
351 | 351 | $tmp .= $c; |
352 | 352 | |
353 | - if (! $delimiterFound) { |
|
353 | + if (!$delimiterFound) { |
|
354 | 354 | $this->handleHeader($delimiterFound, $numBytes, $tmp); |
355 | 355 | } |
356 | 356 | |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | // Set pointer to start |
374 | 374 | $this->payload->reset(); |
375 | 375 | |
376 | - if(Arrays::hasElement($this->headers, 'Content-Encoding')) { |
|
376 | + if (Arrays::hasElement($this->headers, 'Content-Encoding')) { |
|
377 | 377 | $mayCompressed = $this->payload->read($this->payload->count()); |
378 | - switch($this->headers['Content-Encoding']) { |
|
378 | + switch ($this->headers['Content-Encoding']) { |
|
379 | 379 | case 'gzip': |
380 | 380 | $uncompressed = gzdecode(strstr($mayCompressed, "\x1f\x8b")); |
381 | 381 | $this->payload->flush(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | 'rqtype' => $requestType, |
433 | 433 | 'path' => $this->path, |
434 | 434 | 'proto' => $this->protocol, |
435 | - 'query' => (strlen($this->queryString) ? '?' . $this->queryString : '') |
|
435 | + 'query' => (strlen($this->queryString) ? '?'.$this->queryString : '') |
|
436 | 436 | )); |
437 | 437 | |
438 | 438 | // Add the host part |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | */ |
479 | 479 | private function adjustHeaders($requestType) |
480 | 480 | { |
481 | - if (! array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
481 | + if (!array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
482 | 482 | $this->setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); |
483 | 483 | } |
484 | 484 | |
485 | - if (! array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
485 | + if (!array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
486 | 486 | $this->setHeader('Accept-Language', 'en-US;q=0.7,en;q=0.3'); |
487 | 487 | } |
488 | 488 | |
489 | - if (! array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
489 | + if (!array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
490 | 490 | $this->setHeader('User-Agent', 'phpGenerics 1.0'); |
491 | 491 | } |
492 | 492 | |
493 | - if (! array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
493 | + if (!array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
494 | 494 | $this->adjustConnectionHeader($requestType); |
495 | 495 | } |
496 | 496 | |
497 | - if (! array_key_exists('Accept-Encoding', $this->headers)) { |
|
497 | + if (!array_key_exists('Accept-Encoding', $this->headers)) { |
|
498 | 498 | $encoding = ""; |
499 | 499 | if (function_exists('gzinflate')) { |
500 | 500 | $encoding = 'gzip, deflate'; |
@@ -498,8 +498,7 @@ |
||
498 | 498 | $encoding = ""; |
499 | 499 | if (function_exists('gzinflate')) { |
500 | 500 | $encoding = 'gzip, deflate'; |
501 | - } |
|
502 | - else { |
|
501 | + } else { |
|
503 | 502 | $encoding = 'identity'; |
504 | 503 | } |
505 | 504 | $this->setHeader('Accept-Encoding', $encoding); |