@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $has_dns_alt = false; |
41 | 41 | |
42 | 42 | // Check the subjectAltName |
43 | - if (!empty($cert['extensions']) && !empty($cert['extensions']['subjectAltName'])) { |
|
43 | + if ( ! empty($cert['extensions']) && ! empty($cert['extensions']['subjectAltName'])) { |
|
44 | 44 | $altnames = explode(',', $cert['extensions']['subjectAltName']); |
45 | 45 | foreach ($altnames as $altname) { |
46 | 46 | $altname = trim($altname); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | // Fall back to checking the common name if we didn't get any dNSName |
64 | 64 | // alt names, as per RFC2818 |
65 | - if (!$has_dns_alt && !empty($cert['subject']['CN'])) { |
|
65 | + if ( ! $has_dns_alt && ! empty($cert['subject']['CN'])) { |
|
66 | 66 | // Check for a match |
67 | 67 | if (self::match_domain($host, $cert['subject']['CN']) === true) { |
68 | 68 | return true; |
@@ -57,16 +57,13 @@ |
||
57 | 57 | public function __construct($args = null) { |
58 | 58 | if (is_string($args)) { |
59 | 59 | $this->proxy = $args; |
60 | - } |
|
61 | - elseif (is_array($args)) { |
|
60 | + } elseif (is_array($args)) { |
|
62 | 61 | if (count($args) == 1) { |
63 | 62 | list($this->proxy) = $args; |
64 | - } |
|
65 | - elseif (count($args) == 3) { |
|
63 | + } elseif (count($args) == 3) { |
|
66 | 64 | list($this->proxy, $this->user, $this->pass) = $args; |
67 | 65 | $this->use_authentication = true; |
68 | - } |
|
69 | - else { |
|
66 | + } else { |
|
70 | 67 | throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs'); |
71 | 68 | } |
72 | 69 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @see fsockopen_header |
54 | 54 | * @param Requests_Hooks $hooks Hook system |
55 | 55 | */ |
56 | - public function register(Requests_Hooks &$hooks) { |
|
56 | + public function register(Requests_Hooks & $hooks) { |
|
57 | 57 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); |
58 | 58 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); |
59 | 59 | } |
@@ -83,6 +83,6 @@ discard block |
||
83 | 83 | * @return string |
84 | 84 | */ |
85 | 85 | public function getAuthString() { |
86 | - return $this->user . ':' . $this->pass; |
|
86 | + return $this->user.':'.$this->pass; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @see fsockopen_header |
54 | 54 | * @param Requests_Hooks $hooks Hook system |
55 | 55 | */ |
56 | - public function register(Requests_Hooks &$hooks) { |
|
56 | + public function register(Requests_Hooks & $hooks) { |
|
57 | 57 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); |
58 | 58 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); |
59 | 59 | } |
@@ -83,6 +83,6 @@ discard block |
||
83 | 83 | * @return string |
84 | 84 | */ |
85 | 85 | public function getAuthString() { |
86 | - return $this->user . ':' . $this->pass; |
|
86 | + return $this->user.':'.$this->pass; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * @return string Exception class name to use |
58 | 58 | */ |
59 | 59 | public static function get_class($code) { |
60 | - if (!$code) { |
|
60 | + if ( ! $code) { |
|
61 | 61 | return 'Requests_Exception_HTTP_Unknown'; |
62 | 62 | } |
63 | 63 |
@@ -109,11 +109,11 @@ |
||
109 | 109 | */ |
110 | 110 | public function throw_for_status($allow_redirects = true) { |
111 | 111 | if ($this->is_redirect()) { |
112 | - if (!$allow_redirects) { |
|
112 | + if ( ! $allow_redirects) { |
|
113 | 113 | throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this); |
114 | 114 | } |
115 | 115 | } |
116 | - elseif (!$this->success) { |
|
116 | + elseif ( ! $this->success) { |
|
117 | 117 | $exception = Requests_Exception_HTTP::get_class($this->status_code); |
118 | 118 | throw new $exception(null, $this); |
119 | 119 | } |
@@ -112,8 +112,7 @@ |
||
112 | 112 | if (!$allow_redirects) { |
113 | 113 | throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this); |
114 | 114 | } |
115 | - } |
|
116 | - elseif (!$this->success) { |
|
115 | + } elseif (!$this->success) { |
|
117 | 116 | $exception = Requests_Exception_HTTP::get_class($this->status_code); |
118 | 117 | throw new $exception(null, $this); |
119 | 118 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function offsetGet($key) { |
27 | 27 | $key = strtolower($key); |
28 | - if (!isset($this->data[$key])) { |
|
28 | + if ( ! isset($this->data[$key])) { |
|
29 | 29 | return null; |
30 | 30 | } |
31 | 31 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $key = strtolower($key); |
49 | 49 | |
50 | - if (!isset($this->data[$key])) { |
|
50 | + if ( ! isset($this->data[$key])) { |
|
51 | 51 | $this->data[$key] = array(); |
52 | 52 | } |
53 | 53 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getValues($key) { |
64 | 64 | $key = strtolower($key); |
65 | - if (!isset($this->data[$key])) { |
|
65 | + if ( ! isset($this->data[$key])) { |
|
66 | 66 | return null; |
67 | 67 | } |
68 | 68 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return string Item value |
72 | 72 | */ |
73 | 73 | public function offsetGet($key) { |
74 | - if (!isset($this->cookies[$key])) { |
|
74 | + if ( ! isset($this->cookies[$key])) { |
|
75 | 75 | return null; |
76 | 76 | } |
77 | 77 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | * @param array $options |
135 | 135 | */ |
136 | 136 | public function before_request($url, &$headers, &$data, &$type, &$options) { |
137 | - if (!$url instanceof Requests_IRI) { |
|
137 | + if ( ! $url instanceof Requests_IRI) { |
|
138 | 138 | $url = new Requests_IRI($url); |
139 | 139 | } |
140 | 140 | |
141 | - if (!empty($this->cookies)) { |
|
141 | + if ( ! empty($this->cookies)) { |
|
142 | 142 | $cookies = array(); |
143 | 143 | foreach ($this->cookies as $key => $cookie) { |
144 | 144 | $cookie = $this->normalize_cookie($cookie, $key); |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @var Requests_Response $response |
164 | 164 | */ |
165 | - public function before_redirect_check(Requests_Response &$return) { |
|
165 | + public function before_redirect_check(Requests_Response & $return) { |
|
166 | 166 | $url = $return->url; |
167 | - if (!$url instanceof Requests_IRI) { |
|
167 | + if ( ! $url instanceof Requests_IRI) { |
|
168 | 168 | $url = new Requests_IRI($url); |
169 | 169 | } |
170 | 170 |
@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | if (isset($options['verify'])) { |
91 | 91 | if ($options['verify'] === false) { |
92 | 92 | $context_options['verify_peer'] = false; |
93 | - } |
|
94 | - elseif (is_string($options['verify'])) { |
|
93 | + } elseif (is_string($options['verify'])) { |
|
95 | 94 | $context_options['cafile'] = $options['verify']; |
96 | 95 | } |
97 | 96 | } |
@@ -101,8 +100,7 @@ discard block |
||
101 | 100 | } |
102 | 101 | |
103 | 102 | stream_context_set_option($context, array('ssl' => $context_options)); |
104 | - } |
|
105 | - else { |
|
103 | + } else { |
|
106 | 104 | $remote_socket = 'tcp://' . $host; |
107 | 105 | } |
108 | 106 | |
@@ -139,8 +137,7 @@ discard block |
||
139 | 137 | if ($data_format === 'query') { |
140 | 138 | $path = self::format_get($url_parts, $data); |
141 | 139 | $data = ''; |
142 | - } |
|
143 | - else { |
|
140 | + } else { |
|
144 | 141 | $path = self::format_get($url_parts, array()); |
145 | 142 | } |
146 | 143 | |
@@ -152,8 +149,7 @@ discard block |
||
152 | 149 | if ($options['type'] !== Requests::TRACE) { |
153 | 150 | if (is_array($data)) { |
154 | 151 | $request_body = http_build_query($data, null, '&'); |
155 | - } |
|
156 | - else { |
|
152 | + } else { |
|
157 | 153 | $request_body = $data; |
158 | 154 | } |
159 | 155 | |
@@ -219,8 +215,7 @@ discard block |
||
219 | 215 | $timeout_sec = (int) floor($options['timeout']); |
220 | 216 | if ($timeout_sec == $options['timeout']) { |
221 | 217 | $timeout_msec = 0; |
222 | - } |
|
223 | - else { |
|
218 | + } else { |
|
224 | 219 | $timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS; |
225 | 220 | } |
226 | 221 | stream_set_timeout($socket, $timeout_sec, $timeout_msec); |
@@ -268,8 +263,7 @@ discard block |
||
268 | 263 | $size += strlen($block); |
269 | 264 | if ($download) { |
270 | 265 | fwrite($download, $block); |
271 | - } |
|
272 | - else { |
|
266 | + } else { |
|
273 | 267 | $body .= $block; |
274 | 268 | } |
275 | 269 | } |
@@ -278,8 +272,7 @@ discard block |
||
278 | 272 | |
279 | 273 | if ($download) { |
280 | 274 | fclose($download); |
281 | - } |
|
282 | - else { |
|
275 | + } else { |
|
283 | 276 | $this->headers .= "\r\n\r\n" . $body; |
284 | 277 | } |
285 | 278 | fclose($socket); |
@@ -304,8 +297,7 @@ discard block |
||
304 | 297 | $responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']); |
305 | 298 | |
306 | 299 | $request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request)); |
307 | - } |
|
308 | - catch (Requests_Exception $e) { |
|
300 | + } catch (Requests_Exception $e) { |
|
309 | 301 | $responses[$id] = $e; |
310 | 302 | } |
311 | 303 | |
@@ -356,12 +348,10 @@ discard block |
||
356 | 348 | if (isset($url_parts['path'])) { |
357 | 349 | if (isset($url_parts['query'])) { |
358 | 350 | $get = $url_parts['path'] . '?' . $url_parts['query']; |
359 | - } |
|
360 | - else { |
|
351 | + } else { |
|
361 | 352 | $get = $url_parts['path']; |
362 | 353 | } |
363 | - } |
|
364 | - else { |
|
354 | + } else { |
|
365 | 355 | $get = '/'; |
366 | 356 | } |
367 | 357 | return $get; |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | |
70 | 70 | // HTTPS support |
71 | 71 | if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { |
72 | - $remote_socket = 'ssl://' . $host; |
|
73 | - if (!isset($url_parts['port'])) { |
|
72 | + $remote_socket = 'ssl://'.$host; |
|
73 | + if ( ! isset($url_parts['port'])) { |
|
74 | 74 | $url_parts['port'] = 443; |
75 | 75 | } |
76 | 76 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | stream_context_set_option($context, array('ssl' => $context_options)); |
107 | 107 | } |
108 | 108 | else { |
109 | - $remote_socket = 'tcp://' . $host; |
|
109 | + $remote_socket = 'tcp://'.$host; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $this->max_bytes = $options['max_bytes']; |
113 | 113 | |
114 | - if (!isset($url_parts['port'])) { |
|
114 | + if ( ! isset($url_parts['port'])) { |
|
115 | 115 | $url_parts['port'] = 80; |
116 | 116 | } |
117 | - $remote_socket .= ':' . $url_parts['port']; |
|
117 | + $remote_socket .= ':'.$url_parts['port']; |
|
118 | 118 | |
119 | 119 | set_error_handler(array($this, 'connect_error_handler'), E_WARNING | E_NOTICE); |
120 | 120 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | restore_error_handler(); |
126 | 126 | |
127 | - if ($verifyname && !$this->verify_certificate_from_context($host, $context)) { |
|
127 | + if ($verifyname && ! $this->verify_certificate_from_context($host, $context)) { |
|
128 | 128 | throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match'); |
129 | 129 | } |
130 | 130 | |
131 | - if (!$socket) { |
|
131 | + if ( ! $socket) { |
|
132 | 132 | if ($errno === 0) { |
133 | 133 | // Connection issue |
134 | 134 | throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error'); |
@@ -160,39 +160,39 @@ discard block |
||
160 | 160 | $request_body = $data; |
161 | 161 | } |
162 | 162 | |
163 | - if (!empty($data)) { |
|
164 | - if (!isset($case_insensitive_headers['Content-Length'])) { |
|
163 | + if ( ! empty($data)) { |
|
164 | + if ( ! isset($case_insensitive_headers['Content-Length'])) { |
|
165 | 165 | $headers['Content-Length'] = strlen($request_body); |
166 | 166 | } |
167 | 167 | |
168 | - if (!isset($case_insensitive_headers['Content-Type'])) { |
|
168 | + if ( ! isset($case_insensitive_headers['Content-Type'])) { |
|
169 | 169 | $headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - if (!isset($case_insensitive_headers['Host'])) { |
|
174 | + if ( ! isset($case_insensitive_headers['Host'])) { |
|
175 | 175 | $out .= sprintf('Host: %s', $url_parts['host']); |
176 | 176 | |
177 | - if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) { |
|
178 | - $out .= ':' . $url_parts['port']; |
|
177 | + if (('http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80) || ('https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443)) { |
|
178 | + $out .= ':'.$url_parts['port']; |
|
179 | 179 | } |
180 | 180 | $out .= "\r\n"; |
181 | 181 | } |
182 | 182 | |
183 | - if (!isset($case_insensitive_headers['User-Agent'])) { |
|
183 | + if ( ! isset($case_insensitive_headers['User-Agent'])) { |
|
184 | 184 | $out .= sprintf("User-Agent: %s\r\n", $options['useragent']); |
185 | 185 | } |
186 | 186 | |
187 | 187 | $accept_encoding = $this->accept_encoding(); |
188 | - if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) { |
|
188 | + if ( ! isset($case_insensitive_headers['Accept-Encoding']) && ! empty($accept_encoding)) { |
|
189 | 189 | $out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding); |
190 | 190 | } |
191 | 191 | |
192 | 192 | $headers = Requests::flatten($headers); |
193 | 193 | |
194 | - if (!empty($headers)) { |
|
195 | - $out .= implode($headers, "\r\n") . "\r\n"; |
|
194 | + if ( ! empty($headers)) { |
|
195 | + $out .= implode($headers, "\r\n")."\r\n"; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $options['hooks']->dispatch('fsockopen.after_headers', array(&$out)); |
@@ -201,18 +201,18 @@ discard block |
||
201 | 201 | $out .= "\r\n"; |
202 | 202 | } |
203 | 203 | |
204 | - if (!isset($case_insensitive_headers['Connection'])) { |
|
204 | + if ( ! isset($case_insensitive_headers['Connection'])) { |
|
205 | 205 | $out .= "Connection: Close\r\n"; |
206 | 206 | } |
207 | 207 | |
208 | - $out .= "\r\n" . $request_body; |
|
208 | + $out .= "\r\n".$request_body; |
|
209 | 209 | |
210 | 210 | $options['hooks']->dispatch('fsockopen.before_send', array(&$out)); |
211 | 211 | |
212 | 212 | fwrite($socket, $out); |
213 | 213 | $options['hooks']->dispatch('fsockopen.after_send', array($out)); |
214 | 214 | |
215 | - if (!$options['blocking']) { |
|
215 | + if ( ! $options['blocking']) { |
|
216 | 216 | fclose($socket); |
217 | 217 | $fake_headers = ''; |
218 | 218 | $options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers)); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $download = fopen($options['filename'], 'wb'); |
238 | 238 | } |
239 | 239 | |
240 | - while (!feof($socket)) { |
|
240 | + while ( ! feof($socket)) { |
|
241 | 241 | $this->info = stream_get_meta_data($socket); |
242 | 242 | if ($this->info['timed_out']) { |
243 | 243 | throw new Requests_Exception('fsocket timed out', 'timeout'); |
244 | 244 | } |
245 | 245 | |
246 | 246 | $block = fread($socket, Requests::BUFFER_SIZE); |
247 | - if (!$doingbody) { |
|
247 | + if ( ! $doingbody) { |
|
248 | 248 | $response .= $block; |
249 | 249 | if (strpos($response, "\r\n\r\n")) { |
250 | 250 | list($headers, $block) = explode("\r\n\r\n", $response, 2); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | fclose($download); |
284 | 284 | } |
285 | 285 | else { |
286 | - $this->headers .= "\r\n\r\n" . $body; |
|
286 | + $this->headers .= "\r\n\r\n".$body; |
|
287 | 287 | } |
288 | 288 | fclose($socket); |
289 | 289 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $responses[$id] = $e; |
313 | 313 | } |
314 | 314 | |
315 | - if (!is_string($responses[$id])) { |
|
315 | + if ( ! is_string($responses[$id])) { |
|
316 | 316 | $request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id)); |
317 | 317 | } |
318 | 318 | } |
@@ -348,17 +348,17 @@ discard block |
||
348 | 348 | * @return string URL with data |
349 | 349 | */ |
350 | 350 | protected static function format_get($url_parts, $data) { |
351 | - if (!empty($data)) { |
|
351 | + if ( ! empty($data)) { |
|
352 | 352 | if (empty($url_parts['query'])) { |
353 | 353 | $url_parts['query'] = ''; |
354 | 354 | } |
355 | 355 | |
356 | - $url_parts['query'] .= '&' . http_build_query($data, null, '&'); |
|
356 | + $url_parts['query'] .= '&'.http_build_query($data, null, '&'); |
|
357 | 357 | $url_parts['query'] = trim($url_parts['query'], '&'); |
358 | 358 | } |
359 | 359 | if (isset($url_parts['path'])) { |
360 | 360 | if (isset($url_parts['query'])) { |
361 | - $get = $url_parts['path'] . '?' . $url_parts['query']; |
|
361 | + $get = $url_parts['path'].'?'.$url_parts['query']; |
|
362 | 362 | } |
363 | 363 | else { |
364 | 364 | $get = $url_parts['path']; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | - $this->connect_error .= $errstr . "\n"; |
|
386 | + $this->connect_error .= $errstr."\n"; |
|
387 | 387 | return true; |
388 | 388 | } |
389 | 389 | |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | * @return boolean True if the transport is valid, false otherwise. |
424 | 424 | */ |
425 | 425 | public static function test($capabilities = array()) { |
426 | - if (!function_exists('fsockopen')) { |
|
426 | + if ( ! function_exists('fsockopen')) { |
|
427 | 427 | return false; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // If needed, check that streams support SSL |
431 | 431 | if (isset($capabilities['ssl']) && $capabilities['ssl']) { |
432 | - if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) { |
|
432 | + if ( ! extension_loaded('openssl') || ! function_exists('openssl_x509_parse')) { |
|
433 | 433 | return false; |
434 | 434 | } |
435 | 435 |
@@ -149,8 +149,7 @@ discard block |
||
149 | 149 | if ($options['verify'] === false) { |
150 | 150 | curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); |
151 | 151 | curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); |
152 | - } |
|
153 | - elseif (is_string($options['verify'])) { |
|
152 | + } elseif (is_string($options['verify'])) { |
|
154 | 153 | curl_setopt($this->handle, CURLOPT_CAINFO, $options['verify']); |
155 | 154 | } |
156 | 155 | } |
@@ -246,8 +245,7 @@ discard block |
||
246 | 245 | ); |
247 | 246 | $responses[$key] = $exception; |
248 | 247 | $options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key])); |
249 | - } |
|
250 | - else { |
|
248 | + } else { |
|
251 | 249 | $responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options); |
252 | 250 | |
253 | 251 | $options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key])); |
@@ -322,8 +320,7 @@ discard block |
||
322 | 320 | if ($data_format === 'query') { |
323 | 321 | $url = self::format_get($url, $data); |
324 | 322 | $data = ''; |
325 | - } |
|
326 | - elseif (!is_string($data)) { |
|
323 | + } elseif (!is_string($data)) { |
|
327 | 324 | $data = http_build_query($data, null, '&'); |
328 | 325 | } |
329 | 326 | } |
@@ -359,15 +356,13 @@ discard block |
||
359 | 356 | |
360 | 357 | if (is_int($timeout) || $this->version < self::CURL_7_16_2) { |
361 | 358 | curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); |
362 | - } |
|
363 | - else { |
|
359 | + } else { |
|
364 | 360 | curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); |
365 | 361 | } |
366 | 362 | |
367 | 363 | if (is_int($options['connect_timeout']) || $this->version < self::CURL_7_16_2) { |
368 | 364 | curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options['connect_timeout'])); |
369 | - } |
|
370 | - else { |
|
365 | + } else { |
|
371 | 366 | curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options['connect_timeout'] * 1000)); |
372 | 367 | } |
373 | 368 | curl_setopt($this->handle, CURLOPT_URL, $url); |
@@ -377,8 +372,7 @@ discard block |
||
377 | 372 | |
378 | 373 | if ($options['protocol_version'] === 1.1) { |
379 | 374 | curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
380 | - } |
|
381 | - else { |
|
375 | + } else { |
|
382 | 376 | curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
383 | 377 | } |
384 | 378 | |
@@ -405,8 +399,7 @@ discard block |
||
405 | 399 | if ($options['filename'] !== false) { |
406 | 400 | fclose($this->stream_handle); |
407 | 401 | $this->headers = trim($this->headers); |
408 | - } |
|
409 | - else { |
|
402 | + } else { |
|
410 | 403 | $this->headers .= $response; |
411 | 404 | } |
412 | 405 | |
@@ -476,8 +469,7 @@ discard block |
||
476 | 469 | |
477 | 470 | if ($this->stream_handle) { |
478 | 471 | fwrite($this->stream_handle, $data); |
479 | - } |
|
480 | - else { |
|
472 | + } else { |
|
481 | 473 | $this->response_data .= $data; |
482 | 474 | } |
483 | 475 | |
@@ -497,8 +489,7 @@ discard block |
||
497 | 489 | $url_parts = parse_url($url); |
498 | 490 | if (empty($url_parts['query'])) { |
499 | 491 | $query = $url_parts['query'] = ''; |
500 | - } |
|
501 | - else { |
|
492 | + } else { |
|
502 | 493 | $query = $url_parts['query']; |
503 | 494 | } |
504 | 495 | |
@@ -507,8 +498,7 @@ discard block |
||
507 | 498 | |
508 | 499 | if (empty($url_parts['query'])) { |
509 | 500 | $url .= '?' . $query; |
510 | - } |
|
511 | - else { |
|
501 | + } else { |
|
512 | 502 | $url = str_replace($url_parts['query'], $query, $url); |
513 | 503 | } |
514 | 504 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // Read the information as needed |
228 | 228 | while ($done = curl_multi_info_read($multihandle)) { |
229 | 229 | $key = array_search($done['handle'], $subhandles, true); |
230 | - if (!isset($to_process[$key])) { |
|
230 | + if ( ! isset($to_process[$key])) { |
|
231 | 231 | $to_process[$key] = $done; |
232 | 232 | } |
233 | 233 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | curl_multi_remove_handle($multihandle, $done['handle']); |
257 | 257 | curl_close($done['handle']); |
258 | 258 | |
259 | - if (!is_string($responses[$key])) { |
|
259 | + if ( ! is_string($responses[$key])) { |
|
260 | 260 | $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); |
261 | 261 | } |
262 | 262 | $completed++; |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); |
311 | 311 | |
312 | 312 | // Force closing the connection for old versions of cURL (<7.22). |
313 | - if ( ! isset( $headers['Connection'] ) ) { |
|
313 | + if ( ! isset($headers['Connection'])) { |
|
314 | 314 | $headers['Connection'] = 'close'; |
315 | 315 | } |
316 | 316 | |
317 | 317 | $headers = Requests::flatten($headers); |
318 | 318 | |
319 | - if (!empty($data)) { |
|
319 | + if ( ! empty($data)) { |
|
320 | 320 | $data_format = $options['data_format']; |
321 | 321 | |
322 | 322 | if ($data_format === 'query') { |
323 | 323 | $url = self::format_get($url, $data); |
324 | 324 | $data = ''; |
325 | 325 | } |
326 | - elseif (!is_string($data)) { |
|
326 | + elseif ( ! is_string($data)) { |
|
327 | 327 | $data = http_build_query($data, null, '&'); |
328 | 328 | } |
329 | 329 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | case Requests::OPTIONS: |
347 | 347 | default: |
348 | 348 | curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); |
349 | - if (!empty($data)) { |
|
349 | + if ( ! empty($data)) { |
|
350 | 350 | curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); |
351 | 351 | } |
352 | 352 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | curl_setopt($this->handle, CURLOPT_URL, $url); |
376 | 376 | curl_setopt($this->handle, CURLOPT_REFERER, $url); |
377 | 377 | curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); |
378 | - if (!empty($headers)) { |
|
378 | + if ( ! empty($headers)) { |
|
379 | 379 | curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); |
380 | 380 | } |
381 | 381 | if ($options['protocol_version'] === 1.1) { |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @return string URL with data |
497 | 497 | */ |
498 | 498 | protected static function format_get($url, $data) { |
499 | - if (!empty($data)) { |
|
499 | + if ( ! empty($data)) { |
|
500 | 500 | $url_parts = parse_url($url); |
501 | 501 | if (empty($url_parts['query'])) { |
502 | 502 | $query = $url_parts['query'] = ''; |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | $query = $url_parts['query']; |
506 | 506 | } |
507 | 507 | |
508 | - $query .= '&' . http_build_query($data, null, '&'); |
|
508 | + $query .= '&'.http_build_query($data, null, '&'); |
|
509 | 509 | $query = trim($query, '&'); |
510 | 510 | |
511 | 511 | if (empty($url_parts['query'])) { |
512 | - $url .= '?' . $query; |
|
512 | + $url .= '?'.$query; |
|
513 | 513 | } |
514 | 514 | else { |
515 | 515 | $url = str_replace($url_parts['query'], $query, $url); |
@@ -525,14 +525,14 @@ discard block |
||
525 | 525 | * @return boolean True if the transport is valid, false otherwise. |
526 | 526 | */ |
527 | 527 | public static function test($capabilities = array()) { |
528 | - if (!function_exists('curl_init') || !function_exists('curl_exec')) { |
|
528 | + if ( ! function_exists('curl_init') || ! function_exists('curl_exec')) { |
|
529 | 529 | return false; |
530 | 530 | } |
531 | 531 | |
532 | 532 | // If needed, check that our installed curl version supports SSL |
533 | 533 | if (isset($capabilities['ssl']) && $capabilities['ssl']) { |
534 | 534 | $curl_version = curl_version(); |
535 | - if (!(CURL_VERSION_SSL & $curl_version['features'])) { |
|
535 | + if ( ! (CURL_VERSION_SSL & $curl_version['features'])) { |
|
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | } |