Skip to content

Commit 83f5b7c

Browse files
committed
5.3 compatibility
1 parent 68c6caf commit 83f5b7c

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/PHPixie/HTTP/Messages/URI.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class URI implements UriInterface
3030
* @const string
3131
*/
3232
const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
33-
33+
3434
/**
3535
* generated uri string cache
3636
* @var string|null
@@ -42,7 +42,7 @@ abstract class URI implements UriInterface
4242
public function __toString()
4343
{
4444
if ($this->uriString === null) {
45-
45+
4646
$uri = '';
4747

4848
if(($scheme = $this->getScheme()) !== '') {
@@ -59,22 +59,22 @@ public function __toString()
5959
if(($fragment = $this->getFragment()) !== '') {
6060
$uri .= '#' . $fragment;
6161
}
62-
62+
6363
$this->uriString = $uri;
6464
}
65-
65+
6666
return $this->uriString;
6767
}
6868

6969
public function getAuthority()
7070
{
7171
$authority = '';
7272
$authority.= $this->getHost();
73-
73+
7474
if (($userInfo = $this->getUserInfo()) !== '') {
7575
$authority = $userInfo . '@' . $authority;
7676
}
77-
77+
7878
$port = $this->getPort();
7979
if ($port !== null) {
8080
$authority .= ':' . $port;
@@ -87,7 +87,7 @@ public function getScheme()
8787
{
8888
return $this->part('scheme');
8989
}
90-
90+
9191
public function getUserInfo()
9292
{
9393
return $this->part('userInfo');
@@ -101,11 +101,11 @@ public function getHost()
101101
public function getPort()
102102
{
103103
$port = $this->part('port');
104-
104+
105105
if($this->isStandardPort($this->getScheme(), $port)) {
106106
$port = null;
107107
}
108-
108+
109109
return $port;
110110
}
111111

@@ -128,8 +128,8 @@ public function withScheme($scheme)
128128
{
129129
$scheme = strtolower($scheme);
130130
$scheme = str_replace('://', '', $scheme);
131-
132-
if (!in_array($scheme, ['', 'http', 'https'], true)) {
131+
132+
if (!in_array($scheme, array('', 'http', 'https'), true)) {
133133
throw new InvalidArgumentException("Unsupported scheme '$scheme', must be either 'http', 'https' or ''");
134134
}
135135

@@ -139,14 +139,14 @@ public function withScheme($scheme)
139139
public function withUserInfo($user, $password = null)
140140
{
141141
$userInfo = $this->normalizePart($user);
142-
142+
143143
if ($userInfo !== '' && $password !== null) {
144144
$userInfo.= ':' . $password;
145145
}
146-
146+
147147
return $this->updatePart('userInfo', $userInfo);
148148
}
149-
149+
150150
protected function updatePart($key, $value)
151151
{
152152
$new = clone $this;
@@ -155,7 +155,7 @@ protected function updatePart($key, $value)
155155

156156
return $new;
157157
}
158-
158+
159159
public function withHost($host)
160160
{
161161
$host = $this->normalizePart($host);
@@ -168,14 +168,14 @@ public function withPort($port)
168168
if (!is_numeric($port)) {
169169
throw new InvalidArgumentException("Port '$port' is not numeric");
170170
}
171-
171+
172172
$port = (int) $port;
173-
173+
174174
if ($port < 1 || $port > 65535) {
175175
throw new InvalidArgumentException("Invalid port '$port' specified");
176176
}
177177
}
178-
178+
179179
return $this->updatePart('port', $port);
180180
}
181181

@@ -197,25 +197,25 @@ public function withFragment($fragment)
197197
$fragment = $this->normalizeFragment($fragment);
198198
return $this->updatePart('fragment', $fragment);
199199
}
200-
200+
201201
protected function normalizeFragment($fragment)
202202
{
203203
$fragment = $this->normalizePart($fragment, '#');
204204
return $this->normalizeQueryString($fragment);
205205
}
206-
206+
207207
protected function normalizePart($part, $prefix = null) {
208208
if($part === null || $part === '') {
209209
return '';
210210
}
211-
211+
212212
if($prefix !== null && $part[0] === $prefix) {
213213
return substr($part, 1);
214214
}
215-
215+
216216
return $part;
217217
}
218-
218+
219219
/**
220220
* Is a given port non-standard for the current scheme?
221221
*
@@ -252,11 +252,11 @@ protected function normalizePath($path)
252252
if (strpos($path, '#') !== false) {
253253
throw new InvalidArgumentException("Path '$path' contains '#'");
254254
}
255-
255+
256256
if ($path === null || $path === '') {
257257
return '/';
258258
}
259-
259+
260260
if($path[0] !== '/') {
261261
$path = '/' . $path;
262262
}
@@ -270,10 +270,10 @@ protected function normalizePath($path)
270270

271271
/**
272272
* Filter a query string to ensure it is propertly encoded.
273-
*
273+
*
274274
* Ensures that the values in the query string are properly urlencoded.
275-
*
276-
* @param string $query
275+
*
276+
* @param string $query
277277
* @return string
278278
*/
279279
protected function normalizeQuery($query)
@@ -283,17 +283,17 @@ protected function normalizeQuery($query)
283283
'Query string must not include a URI fragment'
284284
);
285285
}
286-
287-
$query = $this->normalizePart($query, '?');
288-
286+
287+
$query = $this->normalizePart($query, '?');
288+
289289
$pairs = explode('&', $query);
290-
290+
291291
foreach ($pairs as $pairKey => $pair) {
292292
$pair = explode('=', $pair, 2);
293293
foreach($pair as $key => $value) {
294294
$pair[$key] = $this->normalizeQueryString($value);
295295
}
296-
296+
297297
$parts[$pairKey] = implode('=', $pair);
298298
}
299299

@@ -307,27 +307,27 @@ protected function normalizeQuery($query)
307307
* @return string
308308
*/
309309
protected function normalizeQueryString($value)
310-
{
310+
{
311311
return preg_replace_callback(
312312
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
313313
array($this, 'encodeMatchedQueryPart'),
314314
$value
315315
);
316316
}
317-
317+
318318
protected function encodeMatchedQueryPart($matches) {
319319
return rawurlencode($matches[0]);
320320
}
321-
321+
322322
protected function part($name)
323323
{
324324
if(!array_key_exists($name, $this->parts)) {
325325
$this->requirePart($name);
326326
}
327-
327+
328328
return $this->parts[$name];
329329
}
330-
330+
331331
protected function requirePart($name)
332332
{
333333
if($name === 'port') {
@@ -336,4 +336,4 @@ protected function requirePart($name)
336336
$this->parts[$name] = '';
337337
}
338338
}
339-
}
339+
}

0 commit comments

Comments
 (0)