Completed
Push — master ( 24e24a...fca7db )
by mains
02:44
created
php/Requests/libary/Requests/Transport/fsockopen.php 3 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$options['hooks']->dispatch('fsockopen.before_request');
60 60
 
61 61
 		$url_parts = parse_url($url);
62
-		if (empty($url_parts)) {
62
+		if(empty($url_parts)) {
63 63
 			throw new Requests_Exception('Invalid URL.', 'invalidurl', $url);
64 64
 		}
65 65
 		$host = $url_parts['host'];
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 		$case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers);
69 69
 
70 70
 		// HTTPS support
71
-		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
71
+		if(isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
72 72
 			$remote_socket = 'ssl://' . $host;
73
-			if (!isset($url_parts['port'])) {
73
+			if(!isset($url_parts['port'])) {
74 74
 				$url_parts['port'] = 443;
75 75
 			}
76 76
 
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
 			$verifyname = true;
83 83
 
84 84
 			// SNI, if enabled (OpenSSL >=0.9.8j)
85
-			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
85
+			if(defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
86 86
 				$context_options['SNI_enabled'] = true;
87
-				if (isset($options['verifyname']) && $options['verifyname'] === false) {
87
+				if(isset($options['verifyname']) && $options['verifyname'] === false) {
88 88
 					$context_options['SNI_enabled'] = false;
89 89
 				}
90 90
 			}
91 91
 
92
-			if (isset($options['verify'])) {
93
-				if ($options['verify'] === false) {
92
+			if(isset($options['verify'])) {
93
+				if($options['verify'] === false) {
94 94
 					$context_options['verify_peer'] = false;
95 95
 				}
96
-				elseif (is_string($options['verify'])) {
96
+				elseif(is_string($options['verify'])) {
97 97
 					$context_options['cafile'] = $options['verify'];
98 98
 				}
99 99
 			}
100 100
 
101
-			if (isset($options['verifyname']) && $options['verifyname'] === false) {
101
+			if(isset($options['verifyname']) && $options['verifyname'] === false) {
102 102
 				$context_options['verify_peer_name'] = false;
103 103
 				$verifyname = false;
104 104
 			}
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
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 117
 		$remote_socket .= ':' . $url_parts['port'];
118 118
 
119
-		set_error_handler(array($this, 'connect_error_handler'), E_WARNING | E_NOTICE);
119
+		set_error_handler(array($this, 'connect_error_handler'), E_WARNING|E_NOTICE);
120 120
 
121 121
 		$options['hooks']->dispatch('fsockopen.remote_socket', array(&$remote_socket));
122 122
 
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
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) {
132
-			if ($errno === 0) {
131
+		if(!$socket) {
132
+			if($errno === 0) {
133 133
 				// Connection issue
134 134
 				throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
135 135
 			}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$data_format = $options['data_format'];
141 141
 
142
-		if ($data_format === 'query') {
142
+		if($data_format === 'query') {
143 143
 			$path = self::format_get($url_parts, $data);
144 144
 			$data = '';
145 145
 		}
@@ -152,56 +152,56 @@  discard block
 block discarded – undo
152 152
 		$request_body = '';
153 153
 		$out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']);
154 154
 
155
-		if ($options['type'] !== Requests::TRACE) {
156
-			if (is_array($data)) {
155
+		if($options['type'] !== Requests::TRACE) {
156
+			if(is_array($data)) {
157 157
 				$request_body = http_build_query($data, null, '&');
158 158
 			}
159 159
 			else {
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 )) {
177
+			if(('http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80) || ('https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443)) {
178 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)) {
194
+		if(!empty($headers)) {
195 195
 			$out .= implode($headers, "\r\n") . "\r\n";
196 196
 		}
197 197
 
198 198
 		$options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
199 199
 
200
-		if (substr($out, -2) !== "\r\n") {
200
+		if(substr($out, -2) !== "\r\n") {
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
 
@@ -212,15 +212,15 @@  discard block
 block discarded – undo
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));
219 219
 			return '';
220 220
 		}
221 221
 
222
-		$timeout_sec = (int) floor($options['timeout']);
223
-		if ($timeout_sec == $options['timeout']) {
222
+		$timeout_sec = (int)floor($options['timeout']);
223
+		if($timeout_sec == $options['timeout']) {
224 224
 			$timeout_msec = 0;
225 225
 		}
226 226
 		else {
@@ -233,35 +233,35 @@  discard block
 block discarded – undo
233 233
 		$size = 0;
234 234
 		$doingbody = false;
235 235
 		$download = false;
236
-		if ($options['filename']) {
236
+		if($options['filename']) {
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
-			if ($this->info['timed_out']) {
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
-				if (strpos($response, "\r\n\r\n")) {
249
+				if(strpos($response, "\r\n\r\n")) {
250 250
 					list($headers, $block) = explode("\r\n\r\n", $response, 2);
251 251
 					$doingbody = true;
252 252
 				}
253 253
 			}
254 254
 
255 255
 			// Are we in body mode now?
256
-			if ($doingbody) {
256
+			if($doingbody) {
257 257
 				$options['hooks']->dispatch('request.progress', array($block, $size, $this->max_bytes));
258 258
 				$data_length = strlen($block);
259
-				if ($this->max_bytes) {
259
+				if($this->max_bytes) {
260 260
 					// Have we already hit a limit?
261
-					if ($size === $this->max_bytes) {
261
+					if($size === $this->max_bytes) {
262 262
 						continue;
263 263
 					}
264
-					if (($size + $data_length) > $this->max_bytes) {
264
+					if(($size + $data_length) > $this->max_bytes) {
265 265
 						// Limit the length
266 266
 						$limited_length = ($this->max_bytes - $size);
267 267
 						$block = substr($block, 0, $limited_length);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				}
270 270
 
271 271
 				$size += strlen($block);
272
-				if ($download) {
272
+				if($download) {
273 273
 					fwrite($download, $block);
274 274
 				}
275 275
 				else {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		}
280 280
 		$this->headers = $headers;
281 281
 
282
-		if ($download) {
282
+		if($download) {
283 283
 			fclose($download);
284 284
 		}
285 285
 		else {
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	public function request_multiple($requests, $options) {
302 302
 		$responses = array();
303 303
 		$class = get_class($this);
304
-		foreach ($requests as $id => $request) {
304
+		foreach($requests as $id => $request) {
305 305
 			try {
306 306
 				$handler = new $class();
307 307
 				$responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
308 308
 
309 309
 				$request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
310 310
 			}
311
-			catch (Requests_Exception $e) {
311
+			catch(Requests_Exception $e) {
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
 		}
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	protected static function accept_encoding() {
329 329
 		$type = array();
330
-		if (function_exists('gzinflate')) {
330
+		if(function_exists('gzinflate')) {
331 331
 			$type[] = 'deflate;q=1.0';
332 332
 		}
333 333
 
334
-		if (function_exists('gzuncompress')) {
334
+		if(function_exists('gzuncompress')) {
335 335
 			$type[] = 'compress;q=0.5';
336 336
 		}
337 337
 
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
 	 * @return string URL with data
349 349
 	 */
350 350
 	protected static function format_get($url_parts, $data) {
351
-		if (!empty($data)) {
352
-			if (empty($url_parts['query'])) {
351
+		if(!empty($data)) {
352
+			if(empty($url_parts['query'])) {
353 353
 				$url_parts['query'] = '';
354 354
 			}
355 355
 
356 356
 			$url_parts['query'] .= '&' . http_build_query($data, null, '&');
357 357
 			$url_parts['query'] = trim($url_parts['query'], '&');
358 358
 		}
359
-		if (isset($url_parts['path'])) {
360
-			if (isset($url_parts['query'])) {
359
+		if(isset($url_parts['path'])) {
360
+			if(isset($url_parts['query'])) {
361 361
 				$get = $url_parts['path'] . '?' . $url_parts['query'];
362 362
 			}
363 363
 			else {
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 */
379 379
 	public function connect_error_handler($errno, $errstr) {
380 380
 		// Double-check we can handle it
381
-		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0) {
381
+		if(($errno&E_WARNING) === 0 && ($errno&E_NOTICE) === 0) {
382 382
 			// Return false to indicate the default error handler should engage
383 383
 			return false;
384 384
 		}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
 		// If we don't have SSL options, then we couldn't make the connection at
409 409
 		// all
410
-		if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
410
+		if(empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
411 411
 			throw new Requests_Exception(rtrim($this->connect_error), 'ssl.connect_error');
412 412
 		}
413 413
 
@@ -423,18 +423,18 @@  discard block
 block discarded – undo
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
-		if (isset($capabilities['ssl']) && $capabilities['ssl']) {
432
-			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
431
+		if(isset($capabilities['ssl']) && $capabilities['ssl']) {
432
+			if(!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
433 433
 				return false;
434 434
 			}
435 435
 
436 436
 			// Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156
437
-			if (defined('HHVM_VERSION')) {
437
+			if(defined('HHVM_VERSION')) {
438 438
 				return false;
439 439
 			}
440 440
 		}
Please login to merge, or discard this patch.
Braces   +142 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Transport
14 14
  */
15
-class Requests_Transport_fsockopen implements Requests_Transport {
15
+class Requests_Transport_fsockopen implements Requests_Transport
16
+{
16 17
 	/**
17 18
 	 * Second to microsecond conversion
18 19
 	 *
@@ -55,11 +56,13 @@  discard block
 block discarded – undo
55 56
 	 * @param array $options Request options, see {@see Requests::response()} for documentation
56 57
 	 * @return string Raw HTTP result
57 58
 	 */
58
-	public function request($url, $headers = array(), $data = array(), $options = array()) {
59
+	public function request($url, $headers = array(), $data = array(), $options = array())
60
+	{
59 61
 		$options['hooks']->dispatch('fsockopen.before_request');
60 62
 
61 63
 		$url_parts = parse_url($url);
62
-		if (empty($url_parts)) {
64
+		if (empty($url_parts))
65
+		{
63 66
 			throw new Requests_Exception('Invalid URL.', 'invalidurl', $url);
64 67
 		}
65 68
 		$host = $url_parts['host'];
@@ -68,9 +71,11 @@  discard block
 block discarded – undo
68 71
 		$case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers);
69 72
 
70 73
 		// HTTPS support
71
-		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
74
+		if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
75
+		{
72 76
 			$remote_socket = 'ssl://' . $host;
73
-			if (!isset($url_parts['port'])) {
77
+			if (!isset($url_parts['port']))
78
+			{
74 79
 				$url_parts['port'] = 443;
75 80
 			}
76 81
 
@@ -82,36 +87,44 @@  discard block
 block discarded – undo
82 87
 			$verifyname = true;
83 88
 
84 89
 			// SNI, if enabled (OpenSSL >=0.9.8j)
85
-			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
90
+			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME)
91
+			{
86 92
 				$context_options['SNI_enabled'] = true;
87
-				if (isset($options['verifyname']) && $options['verifyname'] === false) {
93
+				if (isset($options['verifyname']) && $options['verifyname'] === false)
94
+				{
88 95
 					$context_options['SNI_enabled'] = false;
89 96
 				}
90 97
 			}
91 98
 
92
-			if (isset($options['verify'])) {
93
-				if ($options['verify'] === false) {
99
+			if (isset($options['verify']))
100
+			{
101
+				if ($options['verify'] === false)
102
+				{
94 103
 					$context_options['verify_peer'] = false;
95 104
 				}
96
-				elseif (is_string($options['verify'])) {
105
+				elseif (is_string($options['verify']))
106
+				{
97 107
 					$context_options['cafile'] = $options['verify'];
98 108
 				}
99 109
 			}
100 110
 
101
-			if (isset($options['verifyname']) && $options['verifyname'] === false) {
111
+			if (isset($options['verifyname']) && $options['verifyname'] === false)
112
+			{
102 113
 				$context_options['verify_peer_name'] = false;
103 114
 				$verifyname = false;
104 115
 			}
105 116
 
106 117
 			stream_context_set_option($context, array('ssl' => $context_options));
107 118
 		}
108
-		else {
119
+		else
120
+		{
109 121
 			$remote_socket = 'tcp://' . $host;
110 122
 		}
111 123
 
112 124
 		$this->max_bytes = $options['max_bytes'];
113 125
 
114
-		if (!isset($url_parts['port'])) {
126
+		if (!isset($url_parts['port']))
127
+		{
115 128
 			$url_parts['port'] = 80;
116 129
 		}
117 130
 		$remote_socket .= ':' . $url_parts['port'];
@@ -124,12 +137,15 @@  discard block
 block discarded – undo
124 137
 
125 138
 		restore_error_handler();
126 139
 
127
-		if ($verifyname && !$this->verify_certificate_from_context($host, $context)) {
140
+		if ($verifyname && !$this->verify_certificate_from_context($host, $context))
141
+		{
128 142
 			throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match');
129 143
 		}
130 144
 
131
-		if (!$socket) {
132
-			if ($errno === 0) {
145
+		if (!$socket)
146
+		{
147
+			if ($errno === 0)
148
+			{
133 149
 				// Connection issue
134 150
 				throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
135 151
 			}
@@ -139,11 +155,13 @@  discard block
 block discarded – undo
139 155
 
140 156
 		$data_format = $options['data_format'];
141 157
 
142
-		if ($data_format === 'query') {
158
+		if ($data_format === 'query')
159
+		{
143 160
 			$path = self::format_get($url_parts, $data);
144 161
 			$data = '';
145 162
 		}
146
-		else {
163
+		else
164
+		{
147 165
 			$path = self::format_get($url_parts, array());
148 166
 		}
149 167
 
@@ -152,56 +170,69 @@  discard block
 block discarded – undo
152 170
 		$request_body = '';
153 171
 		$out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']);
154 172
 
155
-		if ($options['type'] !== Requests::TRACE) {
156
-			if (is_array($data)) {
173
+		if ($options['type'] !== Requests::TRACE)
174
+		{
175
+			if (is_array($data))
176
+			{
157 177
 				$request_body = http_build_query($data, null, '&');
158 178
 			}
159
-			else {
179
+			else
180
+			{
160 181
 				$request_body = $data;
161 182
 			}
162 183
 
163
-			if (!empty($data)) {
164
-				if (!isset($case_insensitive_headers['Content-Length'])) {
184
+			if (!empty($data))
185
+			{
186
+				if (!isset($case_insensitive_headers['Content-Length']))
187
+				{
165 188
 					$headers['Content-Length'] = strlen($request_body);
166 189
 				}
167 190
 
168
-				if (!isset($case_insensitive_headers['Content-Type'])) {
191
+				if (!isset($case_insensitive_headers['Content-Type']))
192
+				{
169 193
 					$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
170 194
 				}
171 195
 			}
172 196
 		}
173 197
 
174
-		if (!isset($case_insensitive_headers['Host'])) {
198
+		if (!isset($case_insensitive_headers['Host']))
199
+		{
175 200
 			$out .= sprintf('Host: %s', $url_parts['host']);
176 201
 
177
-			if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
202
+			if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 ))
203
+			{
178 204
 				$out .= ':' . $url_parts['port'];
179 205
 			}
180 206
 			$out .= "\r\n";
181 207
 		}
182 208
 
183
-		if (!isset($case_insensitive_headers['User-Agent'])) {
209
+		if (!isset($case_insensitive_headers['User-Agent']))
210
+		{
184 211
 			$out .= sprintf("User-Agent: %s\r\n", $options['useragent']);
185 212
 		}
186 213
 
187 214
 		$accept_encoding = $this->accept_encoding();
188
-		if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) {
215
+		if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding))
216
+		{
189 217
 			$out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding);
190 218
 		}
191 219
 
192 220
 		$headers = Requests::flatten($headers);
193 221
 
194
-		if (!empty($headers)) {
222
+		if (!empty($headers))
223
+		{
195 224
 			$out .= implode($headers, "\r\n") . "\r\n";
196 225
 		}
197 226
 
198 227
 		$options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
199 228
 
200
-		if (substr($out, -2) !== "\r\n") {
229
+		if (substr($out, -2) !== "\r\n")
230
+		{
201 231
 			$out .= "\r\n";
202 232
 		}
203 233
 
204
-		if (!isset($case_insensitive_headers['Connection'])) {
234
+		if (!isset($case_insensitive_headers['Connection']))
235
+		{
205 236
 			$out .= "Connection: Close\r\n";
206 237
 		}
207 238
 
@@ -212,7 +243,8 @@  discard block
 block discarded – undo
212 243
 		fwrite($socket, $out);
213 244
 		$options['hooks']->dispatch('fsockopen.after_send', array($out));
214 245
 
215
-		if (!$options['blocking']) {
246
+		if (!$options['blocking'])
247
+		{
216 248
 			fclose($socket);
217 249
 			$fake_headers = '';
218 250
 			$options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers));
@@ -220,10 +252,12 @@  discard block
 block discarded – undo
220 252
 		}
221 253
 
222 254
 		$timeout_sec = (int) floor($options['timeout']);
223
-		if ($timeout_sec == $options['timeout']) {
255
+		if ($timeout_sec == $options['timeout'])
256
+		{
224 257
 			$timeout_msec = 0;
225 258
 		}
226
-		else {
259
+		else
260
+		{
227 261
 			$timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS;
228 262
 		}
229 263
 		stream_set_timeout($socket, $timeout_sec, $timeout_msec);
@@ -233,35 +267,44 @@  discard block
 block discarded – undo
233 267
 		$size = 0;
234 268
 		$doingbody = false;
235 269
 		$download = false;
236
-		if ($options['filename']) {
270
+		if ($options['filename'])
271
+		{
237 272
 			$download = fopen($options['filename'], 'wb');
238 273
 		}
239 274
 
240
-		while (!feof($socket)) {
275
+		while (!feof($socket))
276
+		{
241 277
 			$this->info = stream_get_meta_data($socket);
242
-			if ($this->info['timed_out']) {
278
+			if ($this->info['timed_out'])
279
+			{
243 280
 				throw new Requests_Exception('fsocket timed out', 'timeout');
244 281
 			}
245 282
 
246 283
 			$block = fread($socket, Requests::BUFFER_SIZE);
247
-			if (!$doingbody) {
284
+			if (!$doingbody)
285
+			{
248 286
 				$response .= $block;
249
-				if (strpos($response, "\r\n\r\n")) {
287
+				if (strpos($response, "\r\n\r\n"))
288
+				{
250 289
 					list($headers, $block) = explode("\r\n\r\n", $response, 2);
251 290
 					$doingbody = true;
252 291
 				}
253 292
 			}
254 293
 
255 294
 			// Are we in body mode now?
256
-			if ($doingbody) {
295
+			if ($doingbody)
296
+			{
257 297
 				$options['hooks']->dispatch('request.progress', array($block, $size, $this->max_bytes));
258 298
 				$data_length = strlen($block);
259
-				if ($this->max_bytes) {
299
+				if ($this->max_bytes)
300
+				{
260 301
 					// Have we already hit a limit?
261
-					if ($size === $this->max_bytes) {
302
+					if ($size === $this->max_bytes)
303
+					{
262 304
 						continue;
263 305
 					}
264
-					if (($size + $data_length) > $this->max_bytes) {
306
+					if (($size + $data_length) > $this->max_bytes)
307
+					{
265 308
 						// Limit the length
266 309
 						$limited_length = ($this->max_bytes - $size);
267 310
 						$block = substr($block, 0, $limited_length);
@@ -269,20 +312,24 @@  discard block
 block discarded – undo
269 312
 				}
270 313
 
271 314
 				$size += strlen($block);
272
-				if ($download) {
315
+				if ($download)
316
+				{
273 317
 					fwrite($download, $block);
274 318
 				}
275
-				else {
319
+				else
320
+				{
276 321
 					$body .= $block;
277 322
 				}
278 323
 			}
279 324
 		}
280 325
 		$this->headers = $headers;
281 326
 
282
-		if ($download) {
327
+		if ($download)
328
+		{
283 329
 			fclose($download);
284 330
 		}
285
-		else {
331
+		else
332
+		{
286 333
 			$this->headers .= "\r\n\r\n" . $body;
287 334
 		}
288 335
 		fclose($socket);
@@ -298,21 +345,26 @@  discard block
 block discarded – undo
298 345
 	 * @param array $options Global options, see {@see Requests::response()} for documentation
299 346
 	 * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well)
300 347
 	 */
301
-	public function request_multiple($requests, $options) {
348
+	public function request_multiple($requests, $options)
349
+	{
302 350
 		$responses = array();
303 351
 		$class = get_class($this);
304
-		foreach ($requests as $id => $request) {
305
-			try {
352
+		foreach ($requests as $id => $request)
353
+		{
354
+			try
355
+			{
306 356
 				$handler = new $class();
307 357
 				$responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']);
308 358
 
309 359
 				$request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request));
310 360
 			}
311
-			catch (Requests_Exception $e) {
361
+			catch (Requests_Exception $e)
362
+			{
312 363
 				$responses[$id] = $e;
313 364
 			}
314 365
 
315
-			if (!is_string($responses[$id])) {
366
+			if (!is_string($responses[$id]))
367
+			{
316 368
 				$request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id));
317 369
 			}
318 370
 		}
@@ -325,13 +377,16 @@  discard block
 block discarded – undo
325 377
 	 *
326 378
 	 * @return string Accept-Encoding header value
327 379
 	 */
328
-	protected static function accept_encoding() {
380
+	protected static function accept_encoding()
381
+	{
329 382
 		$type = array();
330
-		if (function_exists('gzinflate')) {
383
+		if (function_exists('gzinflate'))
384
+		{
331 385
 			$type[] = 'deflate;q=1.0';
332 386
 		}
333 387
 
334
-		if (function_exists('gzuncompress')) {
388
+		if (function_exists('gzuncompress'))
389
+		{
335 390
 			$type[] = 'compress;q=0.5';
336 391
 		}
337 392
 
@@ -347,24 +402,31 @@  discard block
 block discarded – undo
347 402
 	 * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query}
348 403
 	 * @return string URL with data
349 404
 	 */
350
-	protected static function format_get($url_parts, $data) {
351
-		if (!empty($data)) {
352
-			if (empty($url_parts['query'])) {
405
+	protected static function format_get($url_parts, $data)
406
+	{
407
+		if (!empty($data))
408
+		{
409
+			if (empty($url_parts['query']))
410
+			{
353 411
 				$url_parts['query'] = '';
354 412
 			}
355 413
 
356 414
 			$url_parts['query'] .= '&' . http_build_query($data, null, '&');
357 415
 			$url_parts['query'] = trim($url_parts['query'], '&');
358 416
 		}
359
-		if (isset($url_parts['path'])) {
360
-			if (isset($url_parts['query'])) {
417
+		if (isset($url_parts['path']))
418
+		{
419
+			if (isset($url_parts['query']))
420
+			{
361 421
 				$get = $url_parts['path'] . '?' . $url_parts['query'];
362 422
 			}
363
-			else {
423
+			else
424
+			{
364 425
 				$get = $url_parts['path'];
365 426
 			}
366 427
 		}
367
-		else {
428
+		else
429
+		{
368 430
 			$get = '/';
369 431
 		}
370 432
 		return $get;
@@ -376,9 +438,11 @@  discard block
 block discarded – undo
376 438
 	 * @param int $errno Error number (e.g. E_WARNING)
377 439
 	 * @param string $errstr Error message
378 440
 	 */
379
-	public function connect_error_handler($errno, $errstr) {
441
+	public function connect_error_handler($errno, $errstr)
442
+	{
380 443
 		// Double-check we can handle it
381
-		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0) {
444
+		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0)
445
+		{
382 446
 			// Return false to indicate the default error handler should engage
383 447
 			return false;
384 448
 		}
@@ -402,12 +466,14 @@  discard block
 block discarded – undo
402 466
 	 * @param resource $context Stream context
403 467
 	 * @return bool
404 468
 	 */
405
-	public function verify_certificate_from_context($host, $context) {
469
+	public function verify_certificate_from_context($host, $context)
470
+	{
406 471
 		$meta = stream_context_get_options($context);
407 472
 
408 473
 		// If we don't have SSL options, then we couldn't make the connection at
409 474
 		// all
410
-		if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
475
+		if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate']))
476
+		{
411 477
 			throw new Requests_Exception(rtrim($this->connect_error), 'ssl.connect_error');
412 478
 		}
413 479
 
@@ -422,19 +488,24 @@  discard block
 block discarded – undo
422 488
 	 * @codeCoverageIgnore
423 489
 	 * @return boolean True if the transport is valid, false otherwise.
424 490
 	 */
425
-	public static function test($capabilities = array()) {
426
-		if (!function_exists('fsockopen')) {
491
+	public static function test($capabilities = array())
492
+	{
493
+		if (!function_exists('fsockopen'))
494
+		{
427 495
 			return false;
428 496
 		}
429 497
 
430 498
 		// If needed, check that streams support SSL
431
-		if (isset($capabilities['ssl']) && $capabilities['ssl']) {
432
-			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
499
+		if (isset($capabilities['ssl']) && $capabilities['ssl'])
500
+		{
501
+			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse'))
502
+			{
433 503
 				return false;
434 504
 			}
435 505
 
436 506
 			// Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156
437
-			if (defined('HHVM_VERSION')) {
507
+			if (defined('HHVM_VERSION'))
508
+			{
438 509
 				return false;
439 510
 			}
440 511
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @var int|bool Byte count, or false if no limit.
41 41
 	 */
42
-	protected $max_bytes = false;
42
+	protected $max_bytes = FALSE;
43 43
 
44 44
 	protected $connect_error = '';
45 45
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		}
65 65
 		$host = $url_parts['host'];
66 66
 		$context = stream_context_create();
67
-		$verifyname = false;
67
+		$verifyname = FALSE;
68 68
 		$case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers);
69 69
 
70 70
 		// HTTPS support
@@ -75,32 +75,32 @@  discard block
 block discarded – undo
75 75
 			}
76 76
 
77 77
 			$context_options = array(
78
-				'verify_peer' => true,
78
+				'verify_peer' => TRUE,
79 79
 				// 'CN_match' => $host,
80
-				'capture_peer_cert' => true
80
+				'capture_peer_cert' => TRUE
81 81
 			);
82
-			$verifyname = true;
82
+			$verifyname = TRUE;
83 83
 
84 84
 			// SNI, if enabled (OpenSSL >=0.9.8j)
85 85
 			if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) {
86
-				$context_options['SNI_enabled'] = true;
87
-				if (isset($options['verifyname']) && $options['verifyname'] === false) {
88
-					$context_options['SNI_enabled'] = false;
86
+				$context_options['SNI_enabled'] = TRUE;
87
+				if (isset($options['verifyname']) && $options['verifyname'] === FALSE) {
88
+					$context_options['SNI_enabled'] = FALSE;
89 89
 				}
90 90
 			}
91 91
 
92 92
 			if (isset($options['verify'])) {
93
-				if ($options['verify'] === false) {
94
-					$context_options['verify_peer'] = false;
93
+				if ($options['verify'] === FALSE) {
94
+					$context_options['verify_peer'] = FALSE;
95 95
 				}
96 96
 				elseif (is_string($options['verify'])) {
97 97
 					$context_options['cafile'] = $options['verify'];
98 98
 				}
99 99
 			}
100 100
 
101
-			if (isset($options['verifyname']) && $options['verifyname'] === false) {
102
-				$context_options['verify_peer_name'] = false;
103
-				$verifyname = false;
101
+			if (isset($options['verifyname']) && $options['verifyname'] === FALSE) {
102
+				$context_options['verify_peer_name'] = FALSE;
103
+				$verifyname = FALSE;
104 104
 			}
105 105
 
106 106
 			stream_context_set_option($context, array('ssl' => $context_options));
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 				throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
135 135
 			}
136 136
 
137
-			throw new Requests_Exception($errstr, 'fsockopenerror', null, $errno);
137
+			throw new Requests_Exception($errstr, 'fsockopenerror', NULL, $errno);
138 138
 		}
139 139
 
140 140
 		$data_format = $options['data_format'];
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if ($options['type'] !== Requests::TRACE) {
156 156
 			if (is_array($data)) {
157
-				$request_body = http_build_query($data, null, '&');
157
+				$request_body = http_build_query($data, NULL, '&');
158 158
 			}
159 159
 			else {
160 160
 				$request_body = $data;
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 		$response = $body = $headers = '';
232 232
 		$this->info = stream_get_meta_data($socket);
233 233
 		$size = 0;
234
-		$doingbody = false;
235
-		$download = false;
234
+		$doingbody = FALSE;
235
+		$download = FALSE;
236 236
 		if ($options['filename']) {
237 237
 			$download = fopen($options['filename'], 'wb');
238 238
 		}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
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);
251
-					$doingbody = true;
251
+					$doingbody = TRUE;
252 252
 				}
253 253
 			}
254 254
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
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'])) {
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
 		// Double-check we can handle it
381 381
 		if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0) {
382 382
 			// Return false to indicate the default error handler should engage
383
-			return false;
383
+			return FALSE;
384 384
 		}
385 385
 
386 386
 		$this->connect_error .= $errstr . "\n";
387
-		return true;
387
+		return TRUE;
388 388
 	}
389 389
 
390 390
 	/**
@@ -424,21 +424,21 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	public static function test($capabilities = array()) {
426 426
 		if (!function_exists('fsockopen')) {
427
-			return false;
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 432
 			if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) {
433
-				return false;
433
+				return FALSE;
434 434
 			}
435 435
 
436 436
 			// Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156
437 437
 			if (defined('HHVM_VERSION')) {
438
-				return false;
438
+				return FALSE;
439 439
 			}
440 440
 		}
441 441
 
442
-		return true;
442
+		return TRUE;
443 443
 	}
444 444
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Transport.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Transport
14 14
  */
15
-interface Requests_Transport {
15
+interface Requests_Transport
16
+{
16 17
 	/**
17 18
 	 * Perform a request
18 19
 	 *
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Utility/CaseInsensitiveDictionary.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param array $data Dictionary/map to convert to case-insensitive
27 27
 	 */
28 28
 	public function __construct(array $data = array()) {
29
-		foreach ($data as $key => $value) {
29
+		foreach($data as $key => $value) {
30 30
 			$this->offsetSet($key, $value);
31 31
 		}
32 32
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function offsetGet($key) {
52 52
 		$key = strtolower($key);
53
-		if (!isset($this->data[$key])) {
53
+		if(!isset($this->data[$key])) {
54 54
 			return null;
55 55
 		}
56 56
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param string $value Item value
67 67
 	 */
68 68
 	public function offsetSet($key, $value) {
69
-		if ($key === null) {
69
+		if($key === null) {
70 70
 			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71 71
 		}
72 72
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,8 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param array $data Dictionary/map to convert to case-insensitive
27 27
 	 */
28
-	public function __construct(array $data = array()) {
29
-		foreach ($data as $key => $value) {
28
+	public function __construct(array $data = array())
29
+	{
30
+		foreach ($data as $key => $value)
31
+		{
30 32
 			$this->offsetSet($key, $value);
31 33
 		}
32 34
 	}
@@ -37,7 +39,8 @@  discard block
 block discarded – undo
37 39
 	 * @param string $key Item key
38 40
 	 * @return boolean Does the item exist?
39 41
 	 */
40
-	public function offsetExists($key) {
42
+	public function offsetExists($key)
43
+	{
41 44
 		$key = strtolower($key);
42 45
 		return isset($this->data[$key]);
43 46
 	}
@@ -48,9 +51,11 @@  discard block
 block discarded – undo
48 51
 	 * @param string $key Item key
49 52
 	 * @return string Item value
50 53
 	 */
51
-	public function offsetGet($key) {
54
+	public function offsetGet($key)
55
+	{
52 56
 		$key = strtolower($key);
53
-		if (!isset($this->data[$key])) {
57
+		if (!isset($this->data[$key]))
58
+		{
54 59
 			return null;
55 60
 		}
56 61
 
@@ -65,8 +70,10 @@  discard block
 block discarded – undo
65 70
 	 * @param string $key Item name
66 71
 	 * @param string $value Item value
67 72
 	 */
68
-	public function offsetSet($key, $value) {
69
-		if ($key === null) {
73
+	public function offsetSet($key, $value)
74
+	{
75
+		if ($key === null)
76
+		{
70 77
 			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71 78
 		}
72 79
 
@@ -79,7 +86,8 @@  discard block
 block discarded – undo
79 86
 	 *
80 87
 	 * @param string $key
81 88
 	 */
82
-	public function offsetUnset($key) {
89
+	public function offsetUnset($key)
90
+	{
83 91
 		unset($this->data[strtolower($key)]);
84 92
 	}
85 93
 
@@ -88,7 +96,8 @@  discard block
 block discarded – undo
88 96
 	 *
89 97
 	 * @return ArrayIterator
90 98
 	 */
91
-	public function getIterator() {
99
+	public function getIterator()
100
+	{
92 101
 		return new ArrayIterator($this->data);
93 102
 	}
94 103
 
@@ -97,7 +106,8 @@  discard block
 block discarded – undo
97 106
 	 *
98 107
 	 * @return array Header data
99 108
 	 */
100
-	public function getAll() {
109
+	public function getAll()
110
+	{
101 111
 		return $this->data;
102 112
 	}
103 113
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	public function offsetGet($key) {
52 52
 		$key = strtolower($key);
53 53
 		if (!isset($this->data[$key])) {
54
-			return null;
54
+			return NULL;
55 55
 		}
56 56
 
57 57
 		return $this->data[$key];
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param string $value Item value
67 67
 	 */
68 68
 	public function offsetSet($key, $value) {
69
-		if ($key === null) {
69
+		if ($key === NULL) {
70 70
 			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
71 71
 		}
72 72
 
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Utility/FilteredIterator.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
  * @package Requests
13 13
  * @subpackage Utilities
14 14
  */
15
-class Requests_Utility_FilteredIterator extends ArrayIterator {
15
+class Requests_Utility_FilteredIterator extends ArrayIterator
16
+{
16 17
 	/**
17 18
 	 * Callback to run as a filter
18 19
 	 *
@@ -26,7 +27,8 @@  discard block
 block discarded – undo
26 27
 	 * @param array $data
27 28
 	 * @param callable $callback Callback to be called on each value
28 29
 	 */
29
-	public function __construct($data, $callback) {
30
+	public function __construct($data, $callback)
31
+	{
30 32
 		parent::__construct($data);
31 33
 
32 34
 		$this->callback = $callback;
@@ -37,7 +39,8 @@  discard block
 block discarded – undo
37 39
 	 *
38 40
 	 * @return string
39 41
 	 */
40
-	public function current() {
42
+	public function current()
43
+	{
41 44
 		$value = parent::current();
42 45
 		$value = call_user_func($this->callback, $value);
43 46
 		return $value;
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/Transport.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Requests_Exception_Transport extends Requests_Exception {
3
+class Requests_Exception_Transport extends Requests_Exception
4
+{
4 5
 
5 6
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param mixed $data Associated data
36 36
 	 */
37 37
 	public function __construct($reason = null, $data = null) {
38
-		if ($reason !== null) {
38
+		if($reason !== null) {
39 39
 			$this->reason = $reason;
40 40
 		}
41 41
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
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
 
64 64
 		$class = sprintf('Requests_Exception_HTTP_%d', $code);
65
-		if (class_exists($class)) {
65
+		if(class_exists($class)) {
66 66
 			return $class;
67 67
 		}
68 68
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception_HTTP extends Requests_Exception {
13
+class Requests_Exception_HTTP extends Requests_Exception
14
+{
14 15
 	/**
15 16
 	 * HTTP status code
16 17
 	 *
@@ -34,8 +35,10 @@  discard block
 block discarded – undo
34 35
 	 * @param string|null $reason Reason phrase
35 36
 	 * @param mixed $data Associated data
36 37
 	 */
37
-	public function __construct($reason = null, $data = null) {
38
-		if ($reason !== null) {
38
+	public function __construct($reason = null, $data = null)
39
+	{
40
+		if ($reason !== null)
41
+		{
39 42
 			$this->reason = $reason;
40 43
 		}
41 44
 
@@ -46,7 +49,8 @@  discard block
 block discarded – undo
46 49
 	/**
47 50
 	 * Get the status message
48 51
 	 */
49
-	public function getReason() {
52
+	public function getReason()
53
+	{
50 54
 		return $this->reason;
51 55
 	}
52 56
 
@@ -56,13 +60,16 @@  discard block
 block discarded – undo
56 60
 	 * @param int|bool $code HTTP status code, or false if unavailable
57 61
 	 * @return string Exception class name to use
58 62
 	 */
59
-	public static function get_class($code) {
60
-		if (!$code) {
63
+	public static function get_class($code)
64
+	{
65
+		if (!$code)
66
+		{
61 67
 			return 'Requests_Exception_HTTP_Unknown';
62 68
 		}
63 69
 
64 70
 		$class = sprintf('Requests_Exception_HTTP_%d', $code);
65
-		if (class_exists($class)) {
71
+		if (class_exists($class))
72
+		{
66 73
 			return $class;
67 74
 		}
68 75
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 	 * @param string|null $reason Reason phrase
35 35
 	 * @param mixed $data Associated data
36 36
 	 */
37
-	public function __construct($reason = null, $data = null) {
38
-		if ($reason !== null) {
37
+	public function __construct($reason = NULL, $data = NULL) {
38
+		if ($reason !== NULL) {
39 39
 			$this->reason = $reason;
40 40
 		}
41 41
 
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP/414.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP {
13
+class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP
14
+{
14 15
 	/**
15 16
 	 * HTTP status code
16 17
 	 *
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP/408.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
  *
11 11
  * @package Requests
12 12
  */
13
-class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP {
13
+class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP
14
+{
14 15
 	/**
15 16
 	 * HTTP status code
16 17
 	 *
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception/HTTP/511.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
  * @see https://tools.ietf.org/html/rfc6585
13 13
  * @package Requests
14 14
  */
15
-class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP {
15
+class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP
16
+{
16 17
 	/**
17 18
 	 * HTTP status code
18 19
 	 *
Please login to merge, or discard this patch.