@@ -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 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (!is_resource($this->handle)) { |
52 | 52 | throw new SocketException("Socket is not available"); |
53 | 53 | } |
54 | - if (! @socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
54 | + if (!@socket_connect($this->handle, $this->endpoint->getAddress(), $this->endpoint->getPort())) { |
|
55 | 55 | $code = socket_last_error($this->handle); |
56 | 56 | throw new SocketException(socket_strerror($code), array(), $code); |
57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function disconnect() |
67 | 67 | { |
68 | - if (! $this->conntected) { |
|
68 | + if (!$this->conntected) { |
|
69 | 69 | throw new SocketException("Socket is not connected"); |
70 | 70 | } |
71 | 71 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function isWriteable():bool |
101 | 101 | { |
102 | - if (! $this->isConnected()) { |
|
102 | + if (!$this->isConnected()) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'rqtype' => $requestType, |
130 | 130 | 'path' => $this->path, |
131 | 131 | 'proto' => $this->protocol, |
132 | - 'query' => (strlen($this->queryString) ? '?' . $this->queryString : '') |
|
132 | + 'query' => (strlen($this->queryString) ? '?'.$this->queryString : '') |
|
133 | 133 | )); |
134 | 134 | |
135 | 135 | // Add the host part |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $numBytes = 1; |
185 | 185 | $start = time(); |
186 | 186 | while (true) { |
187 | - if (! $this->checkConnection($start)) { |
|
187 | + if (!$this->checkConnection($start)) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $start = time(); // we have readen something => adjust timeout start point |
198 | 198 | $tmp .= $c; |
199 | 199 | |
200 | - if (! $delimiterFound) { |
|
200 | + if (!$delimiterFound) { |
|
201 | 201 | $this->handleHeader($delimiterFound, $numBytes, $tmp); |
202 | 202 | } |
203 | 203 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | $ms = $this->appendPayloadToRequest($ms); |
307 | 307 | |
308 | - if (! $this->isConnected()) { |
|
308 | + if (!$this->isConnected()) { |
|
309 | 309 | $this->connect(); |
310 | 310 | } |
311 | 311 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | private function checkConnection($start): bool |
332 | 332 | { |
333 | - if (! $this->ready()) { |
|
333 | + if (!$this->ready()) { |
|
334 | 334 | if (time() - $start > $this->timeout) { |
335 | 335 | $this->disconnect(); |
336 | 336 | throw new HttpException("Connection timed out!"); |
@@ -234,7 +234,8 @@ |
||
234 | 234 | |
235 | 235 | if (is_dir($caPath)) { |
236 | 236 | $opts['ssl']['capath'] = $caPath; |
237 | - } else { |
|
237 | + } |
|
238 | + else { |
|
238 | 239 | $opts['ssl']['cafile'] = $caPath; |
239 | 240 | } |
240 | 241 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function read($length = 1, $offset = null): string |
62 | 62 | { |
63 | - return stream_get_contents($this->handle, $length, $offset === null ? - 1 : intval($offset)); |
|
63 | + return stream_get_contents($this->handle, $length, $offset === null ? -1 : intval($offset)); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function isOpen(): bool |
72 | 72 | { |
73 | - return is_resource($this->handle) && ! feof($this->handle); |
|
73 | + return is_resource($this->handle) && !feof($this->handle); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function ready(): bool |
92 | 92 | { |
93 | - if (! is_resource($this->handle)) { |
|
93 | + if (!is_resource($this->handle)) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if (! in_array($this->handle, $read)) { |
|
113 | + if (!in_array($this->handle, $read)) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function isWriteable(): bool |
195 | 195 | { |
196 | - if (! is_resource($this->handle)) { |
|
196 | + if (!is_resource($this->handle)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | - if (! in_array($this->handle, $write)) { |
|
216 | + if (!in_array($this->handle, $write)) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 |
@@ -174,7 +174,8 @@ |
||
174 | 174 | if ($code != 0) { |
175 | 175 | if ($code != 10053) { |
176 | 176 | throw new SocketException(socket_strerror($code), array(), $code); |
177 | - } else { |
|
177 | + } |
|
178 | + else { |
|
178 | 179 | $this->handle = null; |
179 | 180 | } |
180 | 181 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
56 | 56 | |
57 | - if (! is_resource($this->handle)) { |
|
57 | + if (!is_resource($this->handle)) { |
|
58 | 58 | $code = socket_last_error(); |
59 | 59 | throw new SocketException(socket_strerror($code), array(), $code); |
60 | 60 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function ready(): bool |
90 | 90 | { |
91 | - if (! is_resource($this->handle)) { |
|
91 | + if (!is_resource($this->handle)) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | - if (! in_array($this->handle, $read)) { |
|
112 | + if (!in_array($this->handle, $read)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function isWriteable(): bool |
125 | 125 | { |
126 | - if (! is_resource($this->handle)) { |
|
126 | + if (!is_resource($this->handle)) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - if (! in_array($this->handle, $write)) { |
|
147 | + if (!in_array($this->handle, $write)) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->handle = $clientHandle; |
36 | 36 | $this->conntected = false; |
37 | 37 | |
38 | - if (! is_resource($clientHandle)) { |
|
38 | + if (!is_resource($clientHandle)) { |
|
39 | 39 | parent::__construct($endpoint); |
40 | 40 | } |
41 | 41 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function disconnect() |
59 | 59 | { |
60 | - if (! $this->conntected) { |
|
60 | + if (!$this->conntected) { |
|
61 | 61 | throw new SocketException("Socket is not connected"); |
62 | 62 | } |
63 | 63 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function isWriteable(): bool |
93 | 93 | { |
94 | - if (! $this->isConnected()) { |
|
94 | + if (!$this->isConnected()) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | */ |
69 | 69 | public function get($key) |
70 | 70 | { |
71 | - if (! isset($this->sessionContainer[$key])) { |
|
71 | + if (!isset($this->sessionContainer[$key])) { |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 |
@@ -74,23 +74,23 @@ |
||
74 | 74 | */ |
75 | 75 | private function adjustHeaders($requestType) |
76 | 76 | { |
77 | - if (! array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
77 | + if (!array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
78 | 78 | $this->setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); |
79 | 79 | } |
80 | 80 | |
81 | - if (! array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
81 | + if (!array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
82 | 82 | $this->setHeader('Accept-Language', 'en-US;q=0.7,en;q=0.3'); |
83 | 83 | } |
84 | 84 | |
85 | - if (! array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
85 | + if (!array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
86 | 86 | $this->setHeader('User-Agent', 'phpGenerics 1.0'); |
87 | 87 | } |
88 | 88 | |
89 | - if (! array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
89 | + if (!array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
90 | 90 | $this->adjustConnectionHeader($requestType); |
91 | 91 | } |
92 | 92 | |
93 | - if (! array_key_exists('Accept-Encoding', $this->headers)) { |
|
93 | + if (!array_key_exists('Accept-Encoding', $this->headers)) { |
|
94 | 94 | if (function_exists('gzinflate')) { |
95 | 95 | $encoding = 'gzip, deflate'; |
96 | 96 | } else { |
@@ -93,7 +93,8 @@ discard block |
||
93 | 93 | if (! array_key_exists('Accept-Encoding', $this->headers)) { |
94 | 94 | if (function_exists('gzinflate')) { |
95 | 95 | $encoding = 'gzip, deflate'; |
96 | - } else { |
|
96 | + } |
|
97 | + else { |
|
97 | 98 | $encoding = 'identity'; |
98 | 99 | } |
99 | 100 | $this->setHeader('Accept-Encoding', $encoding); |
@@ -110,7 +111,8 @@ discard block |
||
110 | 111 | { |
111 | 112 | if ($requestType == 'HEAD') { |
112 | 113 | $this->setHeader('Connection', 'close'); |
113 | - } else { |
|
114 | + } |
|
115 | + else { |
|
114 | 116 | $this->setHeader('Connection', 'keep-alive'); |
115 | 117 | } |
116 | 118 | } |
@@ -124,7 +126,8 @@ discard block |
||
124 | 126 | { |
125 | 127 | if (strpos($line, ':') === false) { |
126 | 128 | $this->responseCode = HttpStatus::parseStatus($line)->getCode(); |
127 | - } else { |
|
129 | + } |
|
130 | + else { |
|
128 | 131 | $line = trim($line); |
129 | 132 | list ($headerName, $headerValue) = explode(':', $line, 2); |
130 | 133 | $this->headers[$headerName] = trim($headerValue); |
@@ -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 |