@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->data = $data; |
70 | 70 | $this->options = $options; |
71 | 71 | |
72 | - if (empty($this->options['cookies'])) { |
|
72 | + if(empty($this->options['cookies'])) { |
|
73 | 73 | $this->options['cookies'] = new Requests_Cookie_Jar(); |
74 | 74 | } |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return mixed|null Property value, null if none found |
82 | 82 | */ |
83 | 83 | public function __get($key) { |
84 | - if (isset($this->options[$key])) { |
|
84 | + if(isset($this->options[$key])) { |
|
85 | 85 | return $this->options[$key]; |
86 | 86 | } |
87 | 87 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string $key Property key |
114 | 114 | */ |
115 | 115 | public function __unset($key) { |
116 | - if (isset($this->options[$key])) { |
|
116 | + if(isset($this->options[$key])) { |
|
117 | 117 | unset($this->options[$key]); |
118 | 118 | } |
119 | 119 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return array Responses (either Requests_Response or a Requests_Exception object) |
216 | 216 | */ |
217 | 217 | public function request_multiple($requests, $options = array()) { |
218 | - foreach ($requests as $key => $request) { |
|
218 | + foreach($requests as $key => $request) { |
|
219 | 219 | $requests[$key] = $this->merge_request($request, false); |
220 | 220 | } |
221 | 221 | |
@@ -235,26 +235,26 @@ discard block |
||
235 | 235 | * @return array Request data |
236 | 236 | */ |
237 | 237 | protected function merge_request($request, $merge_options = true) { |
238 | - if ($this->url !== null) { |
|
238 | + if($this->url !== null) { |
|
239 | 239 | $request['url'] = Requests_IRI::absolutize($this->url, $request['url']); |
240 | 240 | $request['url'] = $request['url']->uri; |
241 | 241 | } |
242 | 242 | |
243 | - if (empty($request['headers'])) { |
|
243 | + if(empty($request['headers'])) { |
|
244 | 244 | $request['headers'] = array(); |
245 | 245 | } |
246 | 246 | $request['headers'] = array_merge($this->headers, $request['headers']); |
247 | 247 | |
248 | - if (empty($request['data'])) { |
|
249 | - if (is_array($this->data)) { |
|
248 | + if(empty($request['data'])) { |
|
249 | + if(is_array($this->data)) { |
|
250 | 250 | $request['data'] = $this->data; |
251 | 251 | } |
252 | 252 | } |
253 | - elseif (is_array($request['data']) && is_array($this->data)) { |
|
253 | + elseif(is_array($request['data']) && is_array($this->data)) { |
|
254 | 254 | $request['data'] = array_merge($this->data, $request['data']); |
255 | 255 | } |
256 | 256 | |
257 | - if ($merge_options !== false) { |
|
257 | + if($merge_options !== false) { |
|
258 | 258 | $request['options'] = array_merge($this->options, $request['options']); |
259 | 259 | |
260 | 260 | // Disallow forcing the type, as that's a per request setting |
@@ -26,7 +26,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -30,15 +30,15 @@ |
||
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | 32 | public function __construct($message, $type, $data = null, $code = 0) { |
33 | - if ($type !== null) { |
|
33 | + if($type !== null) { |
|
34 | 34 | $this->type = $type; |
35 | 35 | } |
36 | 36 | |
37 | - if ($code !== null) { |
|
37 | + if($code !== null) { |
|
38 | 38 | $this->code = $code; |
39 | 39 | } |
40 | 40 | |
41 | - if ($message !== null) { |
|
41 | + if($message !== null) { |
|
42 | 42 | $this->reason = $message; |
43 | 43 | } |
44 | 44 |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @param mixed $data Associated data |
36 | 36 | */ |
37 | 37 | public function __construct($reason = null, $data = null) { |
38 | - if ($data instanceof Requests_Response) { |
|
38 | + if($data instanceof Requests_Response) { |
|
39 | 39 | $this->code = $data->status_code; |
40 | 40 | } |
41 | 41 |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @param int $priority Priority number. <0 is executed earlier, >0 is executed later |
36 | 36 | */ |
37 | 37 | public function register($hook, $callback, $priority = 0) { |
38 | - if (!isset($this->hooks[$hook])) { |
|
38 | + if(!isset($this->hooks[$hook])) { |
|
39 | 39 | $this->hooks[$hook] = array(); |
40 | 40 | } |
41 | - if (!isset($this->hooks[$hook][$priority])) { |
|
41 | + if(!isset($this->hooks[$hook][$priority])) { |
|
42 | 42 | $this->hooks[$hook][$priority] = array(); |
43 | 43 | } |
44 | 44 | |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return boolean Successfulness |
54 | 54 | */ |
55 | 55 | public function dispatch($hook, $parameters = array()) { |
56 | - if (empty($this->hooks[$hook])) { |
|
56 | + if(empty($this->hooks[$hook])) { |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | - foreach ($this->hooks[$hook] as $priority => $hooked) { |
|
61 | - foreach ($hooked as $callback) { |
|
60 | + foreach($this->hooks[$hook] as $priority => $hooked) { |
|
61 | + foreach($hooked as $callback) { |
|
62 | 62 | call_user_func_array($callback, $parameters); |
63 | 63 | } |
64 | 64 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public static function verify_certificate($host, $cert) { |
33 | 33 | // Calculate the valid wildcard match if the host is not an IP address |
34 | 34 | $parts = explode('.', $host); |
35 | - if (ip2long($host) === false) { |
|
35 | + if(ip2long($host) === false) { |
|
36 | 36 | $parts[0] = '*'; |
37 | 37 | } |
38 | 38 | $wildcard = implode('.', $parts); |
@@ -40,11 +40,11 @@ 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 | - foreach ($altnames as $altname) { |
|
45 | + foreach($altnames as $altname) { |
|
46 | 46 | $altname = trim($altname); |
47 | - if (strpos($altname, 'DNS:') !== 0) { |
|
47 | + if(strpos($altname, 'DNS:') !== 0) { |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $altname = trim(substr($altname, 4)); |
55 | 55 | |
56 | 56 | // Check for a match |
57 | - if (self::match_domain($host, $altname) === true) { |
|
57 | + if(self::match_domain($host, $altname) === true) { |
|
58 | 58 | return true; |
59 | 59 | } |
60 | 60 | } |
@@ -62,9 +62,9 @@ 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 | - if (self::match_domain($host, $cert['subject']['CN']) === true) { |
|
67 | + if(self::match_domain($host, $cert['subject']['CN']) === true) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | 70 | } |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | // Check the first part of the name |
95 | 95 | $first = array_shift($parts); |
96 | 96 | |
97 | - if (strpos($first, '*') !== false) { |
|
97 | + if(strpos($first, '*') !== false) { |
|
98 | 98 | // Check that the wildcard is the full part |
99 | - if ($first !== '*') { |
|
99 | + if($first !== '*') { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Check that we have at least 3 components (including first) |
104 | - if (count($parts) < 2) { |
|
104 | + if(count($parts) < 2) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Check the remaining parts |
110 | - foreach ($parts as $part) { |
|
111 | - if (strpos($part, '*') !== false) { |
|
110 | + foreach($parts as $part) { |
|
111 | + if(strpos($part, '*') !== false) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | } |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function match_domain($host, $reference) { |
128 | 128 | // Check if the reference is blacklisted first |
129 | - if (self::verify_reference_name($reference) !== true) { |
|
129 | + if(self::verify_reference_name($reference) !== true) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Check for a direct match |
134 | - if ($host === $reference) { |
|
134 | + if($host === $reference) { |
|
135 | 135 | return true; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Calculate the valid wildcard match if the host is not an IP address |
139 | 139 | // Also validates that the host has 3 parts or more, as per Firefox's |
140 | 140 | // ruleset. |
141 | - if (ip2long($host) === false) { |
|
141 | + if(ip2long($host) === false) { |
|
142 | 142 | $parts = explode('.', $host); |
143 | 143 | $parts[0] = '*'; |
144 | 144 | $wildcard = implode('.', $parts); |
145 | - if ($wildcard === $reference) { |
|
145 | + if($wildcard === $reference) { |
|
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | } |
@@ -35,28 +35,28 @@ discard block |
||
35 | 35 | * @return string The uncompressed IPv6 address |
36 | 36 | */ |
37 | 37 | public static function uncompress($ip) { |
38 | - if (substr_count($ip, '::') !== 1) { |
|
38 | + if(substr_count($ip, '::') !== 1) { |
|
39 | 39 | return $ip; |
40 | 40 | } |
41 | 41 | |
42 | 42 | list($ip1, $ip2) = explode('::', $ip); |
43 | - $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':'); |
|
44 | - $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':'); |
|
43 | + $c1 = ($ip1 === '')? -1 : substr_count($ip1, ':'); |
|
44 | + $c2 = ($ip2 === '')? -1 : substr_count($ip2, ':'); |
|
45 | 45 | |
46 | - if (strpos($ip2, '.') !== false) { |
|
46 | + if(strpos($ip2, '.') !== false) { |
|
47 | 47 | $c2++; |
48 | 48 | } |
49 | 49 | // :: |
50 | - if ($c1 === -1 && $c2 === -1) { |
|
50 | + if($c1 === -1 && $c2 === -1) { |
|
51 | 51 | $ip = '0:0:0:0:0:0:0:0'; |
52 | 52 | } |
53 | 53 | // ::xxx |
54 | - else if ($c1 === -1) { |
|
54 | + else if($c1 === -1) { |
|
55 | 55 | $fill = str_repeat('0:', 7 - $c2); |
56 | 56 | $ip = str_replace('::', $fill, $ip); |
57 | 57 | } |
58 | 58 | // xxx:: |
59 | - else if ($c2 === -1) { |
|
59 | + else if($c2 === -1) { |
|
60 | 60 | $fill = str_repeat(':0', 7 - $c1); |
61 | 61 | $ip = str_replace('::', $fill, $ip); |
62 | 62 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); |
92 | 92 | |
93 | 93 | // Find bunches of zeros |
94 | - if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) { |
|
94 | + if(preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) { |
|
95 | 95 | $max = 0; |
96 | 96 | $pos = null; |
97 | - foreach ($matches[0] as $match) { |
|
98 | - if (strlen($match[0]) > $max) { |
|
97 | + foreach($matches[0] as $match) { |
|
98 | + if(strlen($match[0]) > $max) { |
|
99 | 99 | $max = strlen($match[0]); |
100 | 100 | $pos = $match[1]; |
101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); |
105 | 105 | } |
106 | 106 | |
107 | - if ($ip_parts[1] !== '') { |
|
107 | + if($ip_parts[1] !== '') { |
|
108 | 108 | return implode(':', $ip_parts); |
109 | 109 | } |
110 | 110 | else { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part |
126 | 126 | */ |
127 | 127 | protected static function split_v6_v4($ip) { |
128 | - if (strpos($ip, '.') !== false) { |
|
128 | + if(strpos($ip, '.') !== false) { |
|
129 | 129 | $pos = strrpos($ip, ':'); |
130 | 130 | $ipv6_part = substr($ip, 0, $pos); |
131 | 131 | $ipv4_part = substr($ip, $pos + 1); |
@@ -149,34 +149,34 @@ discard block |
||
149 | 149 | list($ipv6, $ipv4) = self::split_v6_v4($ip); |
150 | 150 | $ipv6 = explode(':', $ipv6); |
151 | 151 | $ipv4 = explode('.', $ipv4); |
152 | - if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) { |
|
153 | - foreach ($ipv6 as $ipv6_part) { |
|
152 | + if(count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) { |
|
153 | + foreach($ipv6 as $ipv6_part) { |
|
154 | 154 | // The section can't be empty |
155 | - if ($ipv6_part === '') { |
|
155 | + if($ipv6_part === '') { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Nor can it be over four characters |
160 | - if (strlen($ipv6_part) > 4) { |
|
160 | + if(strlen($ipv6_part) > 4) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Remove leading zeros (this is safe because of the above) |
165 | 165 | $ipv6_part = ltrim($ipv6_part, '0'); |
166 | - if ($ipv6_part === '') { |
|
166 | + if($ipv6_part === '') { |
|
167 | 167 | $ipv6_part = '0'; |
168 | 168 | } |
169 | 169 | |
170 | 170 | // Check the value is valid |
171 | 171 | $value = hexdec($ipv6_part); |
172 | - if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { |
|
172 | + if(dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | } |
176 | - if (count($ipv4) === 4) { |
|
177 | - foreach ($ipv4 as $ipv4_part) { |
|
178 | - $value = (int) $ipv4_part; |
|
179 | - if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) { |
|
176 | + if(count($ipv4) === 4) { |
|
177 | + foreach($ipv4 as $ipv4_part) { |
|
178 | + $value = (int)$ipv4_part; |
|
179 | + if((string)$value !== $ipv4_part || $value < 0 || $value > 0xFF) { |
|
180 | 180 | return false; |
181 | 181 | } |
182 | 182 | } |
@@ -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 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | * @param string $value Item value |
42 | 42 | */ |
43 | 43 | public function offsetSet($key, $value) { |
44 | - if ($key === null) { |
|
44 | + if($key === null) { |
|
45 | 45 | throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
46 | 46 | } |
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 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return string Flattened value |
80 | 80 | */ |
81 | 81 | public function flatten($value) { |
82 | - if (is_array($value)) { |
|
82 | + if(is_array($value)) { |
|
83 | 83 | $value = implode(',', $value); |
84 | 84 | } |
85 | 85 |