Completed
Push — master ( 77d52d...114bc4 )
by mains
02:34
created
php/Requests/libary/Requests/Exception/HTTP/417.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_417 extends Requests_Exception_HTTP {
13
+class Requests_Exception_HTTP_417 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/305.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_305 extends Requests_Exception_HTTP {
13
+class Requests_Exception_HTTP_305 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/Hooks.php 1 patch
Braces   +18 added lines, -9 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_Hooks implements Requests_Hooker {
15
+class Requests_Hooks implements Requests_Hooker
16
+{
16 17
 	/**
17 18
 	 * Registered callbacks for each hook
18 19
 	 *
@@ -23,7 +24,8 @@  discard block
 block discarded – undo
23 24
 	/**
24 25
 	 * Constructor
25 26
 	 */
26
-	public function __construct() {
27
+	public function __construct()
28
+	{
27 29
 		// pass
28 30
 	}
29 31
 
@@ -34,11 +36,14 @@  discard block
 block discarded – undo
34 36
 	 * @param callback $callback Function/method to call on event
35 37
 	 * @param int $priority Priority number. <0 is executed earlier, >0 is executed later
36 38
 	 */
37
-	public function register($hook, $callback, $priority = 0) {
38
-		if (!isset($this->hooks[$hook])) {
39
+	public function register($hook, $callback, $priority = 0)
40
+	{
41
+		if (!isset($this->hooks[$hook]))
42
+		{
39 43
 			$this->hooks[$hook] = array();
40 44
 		}
41
-		if (!isset($this->hooks[$hook][$priority])) {
45
+		if (!isset($this->hooks[$hook][$priority]))
46
+		{
42 47
 			$this->hooks[$hook][$priority] = array();
43 48
 		}
44 49
 
@@ -52,13 +57,17 @@  discard block
 block discarded – undo
52 57
 	 * @param array $parameters Parameters to pass to callbacks
53 58
 	 * @return boolean Successfulness
54 59
 	 */
55
-	public function dispatch($hook, $parameters = array()) {
56
-		if (empty($this->hooks[$hook])) {
60
+	public function dispatch($hook, $parameters = array())
61
+	{
62
+		if (empty($this->hooks[$hook]))
63
+		{
57 64
 			return false;
58 65
 		}
59 66
 
60
-		foreach ($this->hooks[$hook] as $priority => $hooked) {
61
-			foreach ($hooked as $callback) {
67
+		foreach ($this->hooks[$hook] as $priority => $hooked)
68
+		{
69
+			foreach ($hooked as $callback)
70
+			{
62 71
 				call_user_func_array($callback, $parameters);
63 72
 			}
64 73
 		}
Please login to merge, or discard this patch.
php/Requests/libary/Requests/SSL.php 1 patch
Braces   +40 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
  * @package Requests
15 15
  * @subpackage Utilities
16 16
  */
17
-class Requests_SSL {
17
+class Requests_SSL
18
+{
18 19
 	/**
19 20
 	 * Verify the certificate against common name and subject alternative names
20 21
 	 *
@@ -29,10 +30,12 @@  discard block
 block discarded – undo
29 30
 	 * @param array $cert Certificate data from openssl_x509_parse()
30 31
 	 * @return bool
31 32
 	 */
32
-	public static function verify_certificate($host, $cert) {
33
+	public static function verify_certificate($host, $cert)
34
+	{
33 35
 		// Calculate the valid wildcard match if the host is not an IP address
34 36
 		$parts = explode('.', $host);
35
-		if (ip2long($host) === false) {
37
+		if (ip2long($host) === false)
38
+		{
36 39
 			$parts[0] = '*';
37 40
 		}
38 41
 		$wildcard = implode('.', $parts);
@@ -40,11 +43,14 @@  discard block
 block discarded – undo
40 43
 		$has_dns_alt = false;
41 44
 
42 45
 		// Check the subjectAltName
43
-		if (!empty($cert['extensions']) && !empty($cert['extensions']['subjectAltName'])) {
46
+		if (!empty($cert['extensions']) && !empty($cert['extensions']['subjectAltName']))
47
+		{
44 48
 			$altnames = explode(',', $cert['extensions']['subjectAltName']);
45
-			foreach ($altnames as $altname) {
49
+			foreach ($altnames as $altname)
50
+			{
46 51
 				$altname = trim($altname);
47
-				if (strpos($altname, 'DNS:') !== 0) {
52
+				if (strpos($altname, 'DNS:') !== 0)
53
+				{
48 54
 					continue;
49 55
 				}
50 56
 
@@ -54,7 +60,8 @@  discard block
 block discarded – undo
54 60
 				$altname = trim(substr($altname, 4));
55 61
 
56 62
 				// Check for a match
57
-				if (self::match_domain($host, $altname) === true) {
63
+				if (self::match_domain($host, $altname) === true)
64
+				{
58 65
 					return true;
59 66
 				}
60 67
 			}
@@ -62,9 +69,11 @@  discard block
 block discarded – undo
62 69
 
63 70
 		// Fall back to checking the common name if we didn't get any dNSName
64 71
 		// alt names, as per RFC2818
65
-		if (!$has_dns_alt && !empty($cert['subject']['CN'])) {
72
+		if (!$has_dns_alt && !empty($cert['subject']['CN']))
73
+		{
66 74
 			// Check for a match
67
-			if (self::match_domain($host, $cert['subject']['CN']) === true) {
75
+			if (self::match_domain($host, $cert['subject']['CN']) === true)
76
+			{
68 77
 				return true;
69 78
 			}
70 79
 		}
@@ -88,27 +97,33 @@  discard block
 block discarded – undo
88 97
 	 * @param string $reference Reference dNSName
89 98
 	 * @return boolean Is the name valid?
90 99
 	 */
91
-	public static function verify_reference_name($reference) {
100
+	public static function verify_reference_name($reference)
101
+	{
92 102
 		$parts = explode('.', $reference);
93 103
 
94 104
 		// Check the first part of the name
95 105
 		$first = array_shift($parts);
96 106
 
97
-		if (strpos($first, '*') !== false) {
107
+		if (strpos($first, '*') !== false)
108
+		{
98 109
 			// Check that the wildcard is the full part
99
-			if ($first !== '*') {
110
+			if ($first !== '*')
111
+			{
100 112
 				return false;
101 113
 			}
102 114
 
103 115
 			// Check that we have at least 3 components (including first)
104
-			if (count($parts) < 2) {
116
+			if (count($parts) < 2)
117
+			{
105 118
 				return false;
106 119
 			}
107 120
 		}
108 121
 
109 122
 		// Check the remaining parts
110
-		foreach ($parts as $part) {
111
-			if (strpos($part, '*') !== false) {
123
+		foreach ($parts as $part)
124
+		{
125
+			if (strpos($part, '*') !== false)
126
+			{
112 127
 				return false;
113 128
 			}
114 129
 		}
@@ -124,25 +139,30 @@  discard block
 block discarded – undo
124 139
 	 * @param string $reference dNSName to match against
125 140
 	 * @return boolean Does the domain match?
126 141
 	 */
127
-	public static function match_domain($host, $reference) {
142
+	public static function match_domain($host, $reference)
143
+	{
128 144
 		// Check if the reference is blacklisted first
129
-		if (self::verify_reference_name($reference) !== true) {
145
+		if (self::verify_reference_name($reference) !== true)
146
+		{
130 147
 			return false;
131 148
 		}
132 149
 
133 150
 		// Check for a direct match
134
-		if ($host === $reference) {
151
+		if ($host === $reference)
152
+		{
135 153
 			return true;
136 154
 		}
137 155
 
138 156
 		// Calculate the valid wildcard match if the host is not an IP address
139 157
 		// Also validates that the host has 3 parts or more, as per Firefox's
140 158
 		// ruleset.
141
-		if (ip2long($host) === false) {
159
+		if (ip2long($host) === false)
160
+		{
142 161
 			$parts = explode('.', $host);
143 162
 			$parts[0] = '*';
144 163
 			$wildcard = implode('.', $parts);
145
-			if ($wildcard === $reference) {
164
+			if ($wildcard === $reference)
165
+			{
146 166
 				return true;
147 167
 			}
148 168
 		}
Please login to merge, or discard this patch.
php/Requests/libary/Requests/IPv6.php 1 patch
Braces   +56 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
  * @package Requests
16 16
  * @subpackage Utilities
17 17
  */
18
-class Requests_IPv6 {
18
+class Requests_IPv6
19
+{
19 20
 	/**
20 21
 	 * Uncompresses an IPv6 address
21 22
 	 *
@@ -34,8 +35,10 @@  discard block
 block discarded – undo
34 35
 	 * @param string $ip An IPv6 address
35 36
 	 * @return string The uncompressed IPv6 address
36 37
 	 */
37
-	public static function uncompress($ip) {
38
-		if (substr_count($ip, '::') !== 1) {
38
+	public static function uncompress($ip)
39
+	{
40
+		if (substr_count($ip, '::') !== 1)
41
+		{
39 42
 			return $ip;
40 43
 		}
41 44
 
@@ -43,25 +46,30 @@  discard block
 block discarded – undo
43 46
 		$c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':');
44 47
 		$c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');
45 48
 
46
-		if (strpos($ip2, '.') !== false) {
49
+		if (strpos($ip2, '.') !== false)
50
+		{
47 51
 			$c2++;
48 52
 		}
49 53
 		// ::
50
-		if ($c1 === -1 && $c2 === -1) {
54
+		if ($c1 === -1 && $c2 === -1)
55
+		{
51 56
 			$ip = '0:0:0:0:0:0:0:0';
52 57
 		}
53 58
 		// ::xxx
54
-		else if ($c1 === -1) {
59
+		else if ($c1 === -1)
60
+		{
55 61
 			$fill = str_repeat('0:', 7 - $c2);
56 62
 			$ip = str_replace('::', $fill, $ip);
57 63
 		}
58 64
 		// xxx::
59
-		else if ($c2 === -1) {
65
+		else if ($c2 === -1)
66
+		{
60 67
 			$fill = str_repeat(':0', 7 - $c1);
61 68
 			$ip = str_replace('::', $fill, $ip);
62 69
 		}
63 70
 		// xxx::xxx
64
-		else {
71
+		else
72
+		{
65 73
 			$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
66 74
 			$ip = str_replace('::', $fill, $ip);
67 75
 		}
@@ -82,7 +90,8 @@  discard block
 block discarded – undo
82 90
 	 * @param string $ip An IPv6 address
83 91
 	 * @return string The compressed IPv6 address
84 92
 	 */
85
-	public static function compress($ip) {
93
+	public static function compress($ip)
94
+	{
86 95
 		// Prepare the IP to be compressed
87 96
 		$ip = self::uncompress($ip);
88 97
 		$ip_parts = self::split_v6_v4($ip);
@@ -91,11 +100,14 @@  discard block
 block discarded – undo
91 100
 		$ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]);
92 101
 
93 102
 		// Find bunches of zeros
94
-		if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) {
103
+		if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE))
104
+		{
95 105
 			$max = 0;
96 106
 			$pos = null;
97
-			foreach ($matches[0] as $match) {
98
-				if (strlen($match[0]) > $max) {
107
+			foreach ($matches[0] as $match)
108
+			{
109
+				if (strlen($match[0]) > $max)
110
+				{
99 111
 					$max = strlen($match[0]);
100 112
 					$pos = $match[1];
101 113
 				}
@@ -104,10 +116,12 @@  discard block
 block discarded – undo
104 116
 			$ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max);
105 117
 		}
106 118
 
107
-		if ($ip_parts[1] !== '') {
119
+		if ($ip_parts[1] !== '')
120
+		{
108 121
 			return implode(':', $ip_parts);
109 122
 		}
110
-		else {
123
+		else
124
+		{
111 125
 			return $ip_parts[0];
112 126
 		}
113 127
 	}
@@ -124,14 +138,17 @@  discard block
 block discarded – undo
124 138
 	 * @param string $ip An IPv6 address
125 139
 	 * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part
126 140
 	 */
127
-	protected static function split_v6_v4($ip) {
128
-		if (strpos($ip, '.') !== false) {
141
+	protected static function split_v6_v4($ip)
142
+	{
143
+		if (strpos($ip, '.') !== false)
144
+		{
129 145
 			$pos = strrpos($ip, ':');
130 146
 			$ipv6_part = substr($ip, 0, $pos);
131 147
 			$ipv4_part = substr($ip, $pos + 1);
132 148
 			return array($ipv6_part, $ipv4_part);
133 149
 		}
134
-		else {
150
+		else
151
+		{
135 152
 			return array($ip, '');
136 153
 		}
137 154
 	}
@@ -144,46 +161,57 @@  discard block
 block discarded – undo
144 161
 	 * @param string $ip An IPv6 address
145 162
 	 * @return bool true if $ip is a valid IPv6 address
146 163
 	 */
147
-	public static function check_ipv6($ip) {
164
+	public static function check_ipv6($ip)
165
+	{
148 166
 		$ip = self::uncompress($ip);
149 167
 		list($ipv6, $ipv4) = self::split_v6_v4($ip);
150 168
 		$ipv6 = explode(':', $ipv6);
151 169
 		$ipv4 = explode('.', $ipv4);
152
-		if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) {
153
-			foreach ($ipv6 as $ipv6_part) {
170
+		if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4)
171
+		{
172
+			foreach ($ipv6 as $ipv6_part)
173
+			{
154 174
 				// The section can't be empty
155
-				if ($ipv6_part === '') {
175
+				if ($ipv6_part === '')
176
+				{
156 177
 					return false;
157 178
 				}
158 179
 
159 180
 				// Nor can it be over four characters
160
-				if (strlen($ipv6_part) > 4) {
181
+				if (strlen($ipv6_part) > 4)
182
+				{
161 183
 					return false;
162 184
 				}
163 185
 
164 186
 				// Remove leading zeros (this is safe because of the above)
165 187
 				$ipv6_part = ltrim($ipv6_part, '0');
166
-				if ($ipv6_part === '') {
188
+				if ($ipv6_part === '')
189
+				{
167 190
 					$ipv6_part = '0';
168 191
 				}
169 192
 
170 193
 				// Check the value is valid
171 194
 				$value = hexdec($ipv6_part);
172
-				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
195
+				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
196
+				{
173 197
 					return false;
174 198
 				}
175 199
 			}
176
-			if (count($ipv4) === 4) {
177
-				foreach ($ipv4 as $ipv4_part) {
200
+			if (count($ipv4) === 4)
201
+			{
202
+				foreach ($ipv4 as $ipv4_part)
203
+				{
178 204
 					$value = (int) $ipv4_part;
179
-					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) {
205
+					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
206
+					{
180 207
 						return false;
181 208
 					}
182 209
 				}
183 210
 			}
184 211
 			return true;
185 212
 		}
186
-		else {
213
+		else
214
+		{
187 215
 			return false;
188 216
 		}
189 217
 	}
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Response/Headers.php 1 patch
Braces   +22 added lines, -11 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_Response_Headers extends Requests_Utility_CaseInsensitiveDictionary {
13
+class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictionary
14
+{
14 15
 	/**
15 16
 	 * Get the given header
16 17
 	 *
@@ -23,9 +24,11 @@  discard block
 block discarded – undo
23 24
 	 * @param string $key
24 25
 	 * @return string Header value
25 26
 	 */
26
-	public function offsetGet($key) {
27
+	public function offsetGet($key)
28
+	{
27 29
 		$key = strtolower($key);
28
-		if (!isset($this->data[$key])) {
30
+		if (!isset($this->data[$key]))
31
+		{
29 32
 			return null;
30 33
 		}
31 34
 
@@ -40,14 +43,17 @@  discard block
 block discarded – undo
40 43
 	 * @param string $key Item name
41 44
 	 * @param string $value Item value
42 45
 	 */
43
-	public function offsetSet($key, $value) {
44
-		if ($key === null) {
46
+	public function offsetSet($key, $value)
47
+	{
48
+		if ($key === null)
49
+		{
45 50
 			throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
46 51
 		}
47 52
 
48 53
 		$key = strtolower($key);
49 54
 
50
-		if (!isset($this->data[$key])) {
55
+		if (!isset($this->data[$key]))
56
+		{
51 57
 			$this->data[$key] = array();
52 58
 		}
53 59
 
@@ -60,9 +66,11 @@  discard block
 block discarded – undo
60 66
 	 * @param string $key
61 67
 	 * @return array Header values
62 68
 	 */
63
-	public function getValues($key) {
69
+	public function getValues($key)
70
+	{
64 71
 		$key = strtolower($key);
65
-		if (!isset($this->data[$key])) {
72
+		if (!isset($this->data[$key]))
73
+		{
66 74
 			return null;
67 75
 		}
68 76
 
@@ -78,8 +86,10 @@  discard block
 block discarded – undo
78 86
 	 * @param string|array $value Value to flatten
79 87
 	 * @return string Flattened value
80 88
 	 */
81
-	public function flatten($value) {
82
-		if (is_array($value)) {
89
+	public function flatten($value)
90
+	{
91
+		if (is_array($value))
92
+		{
83 93
 			$value = implode(',', $value);
84 94
 		}
85 95
 
@@ -92,7 +102,8 @@  discard block
 block discarded – undo
92 102
 	 * Converts the internal
93 103
 	 * @return ArrayIterator
94 104
 	 */
95
-	public function getIterator() {
105
+	public function getIterator()
106
+	{
96 107
 		return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten'));
97 108
 	}
98 109
 }
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Response.php 1 patch
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,11 +12,13 @@  discard block
 block discarded – undo
12 12
  * Contains a response from Requests::request()
13 13
  * @package Requests
14 14
  */
15
-class Requests_Response {
15
+class Requests_Response
16
+{
16 17
 	/**
17 18
 	 * Constructor
18 19
 	 */
19
-	public function __construct() {
20
+	public function __construct()
21
+	{
20 22
 		$this->headers = new Requests_Response_Headers();
21 23
 		$this->cookies = new Requests_Cookie_Jar();
22 24
 	}
@@ -95,7 +97,8 @@  discard block
 block discarded – undo
95 97
 	 *
96 98
 	 * @return boolean True if redirect (3xx status), false if not.
97 99
 	 */
98
-	public function is_redirect() {
100
+	public function is_redirect()
101
+	{
99 102
 		$code = $this->status_code;
100 103
 		return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400;
101 104
 	}
@@ -107,13 +110,17 @@  discard block
 block discarded – undo
107 110
 	 * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
108 111
 	 * @param boolean $allow_redirects Set to false to throw on a 3xx as well
109 112
 	 */
110
-	public function throw_for_status($allow_redirects = true) {
111
-		if ($this->is_redirect()) {
112
-			if (!$allow_redirects) {
113
+	public function throw_for_status($allow_redirects = true)
114
+	{
115
+		if ($this->is_redirect())
116
+		{
117
+			if (!$allow_redirects)
118
+			{
113 119
 				throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
114 120
 			}
115 121
 		}
116
-		elseif (!$this->success) {
122
+		elseif (!$this->success)
123
+		{
117 124
 			$exception = Requests_Exception_HTTP::get_class($this->status_code);
118 125
 			throw new $exception(null, $this);
119 126
 		}
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Proxy.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
  * @subpackage Proxy
21 21
  * @since 1.6
22 22
  */
23
-interface Requests_Proxy {
23
+interface Requests_Proxy
24
+{
24 25
 	/**
25 26
 	 * Register hooks as needed
26 27
 	 *
Please login to merge, or discard this patch.
php/Requests/libary/Requests/Exception.php 1 patch
Braces   +8 added lines, -4 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 extends Exception {
13
+class Requests_Exception extends Exception
14
+{
14 15
 	/**
15 16
 	 * Type of exception
16 17
 	 *
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
 	 * @param mixed $data Associated data
34 35
 	 * @param integer $code Exception numerical code, if applicable
35 36
 	 */
36
-	public function __construct($message, $type, $data = null, $code = 0) {
37
+	public function __construct($message, $type, $data = null, $code = 0)
38
+	{
37 39
 		parent::__construct($message, $code);
38 40
 
39 41
 		$this->type = $type;
@@ -46,7 +48,8 @@  discard block
 block discarded – undo
46 48
 	 * @codeCoverageIgnore
47 49
 	 * @return string
48 50
 	 */
49
-	public function getType() {
51
+	public function getType()
52
+	{
50 53
 		return $this->type;
51 54
 	}
52 55
 
@@ -56,7 +59,8 @@  discard block
 block discarded – undo
56 59
 	 * @codeCoverageIgnore
57 60
 	 * @return mixed
58 61
 	 */
59
-	public function getData() {
62
+	public function getData()
63
+	{
60 64
 		return $this->data;
61 65
 	}
62 66
 }
63 67
\ No newline at end of file
Please login to merge, or discard this patch.