Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 1a57364

Browse files
committed
Merge branch 'feature/php-short-array-syntax'
2 parents 07e5538 + 6db9595 commit 1a57364

File tree

11 files changed

+410
-409
lines changed

11 files changed

+410
-409
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $config->fixers(
3232
'object_operator',
3333
'php_closing_tag',
3434
'remove_lines_between_uses',
35+
'short_array_syntax',
3536
'short_tag',
3637
'standardize_not_equal',
3738
'trailing_spaces',

src/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class File extends Uri
1818
{
19-
protected static $validSchemes = array('file');
19+
protected static $validSchemes = ['file'];
2020

2121
/**
2222
* Check if the URI is a valid File URI
@@ -88,7 +88,7 @@ public static function fromWindowsPath($path)
8888
$url = new static('file:');
8989

9090
// Convert directory separators
91-
$path = str_replace(array('/', '\\'), array('%2F', '/'), $path);
91+
$path = str_replace(['/', '\\'], ['%2F', '/'], $path);
9292

9393
// Is this an absolute path?
9494
if (preg_match('|^([a-zA-Z]:)?/|', $path)) {

src/Http.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ class Http extends Uri
1717
/**
1818
* @see Uri::$validSchemes
1919
*/
20-
protected static $validSchemes = array(
20+
protected static $validSchemes = [
2121
'http',
2222
'https'
23-
);
23+
];
2424

2525
/**
2626
* @see Uri::$defaultPorts
2727
*/
28-
protected static $defaultPorts = array(
28+
protected static $defaultPorts = [
2929
'http' => 80,
3030
'https' => 443,
31-
);
31+
];
3232

3333
/**
3434
* @see Uri::$validHostTypes

src/Mailto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class Mailto extends Uri
2121
{
22-
protected static $validSchemes = array('mailto');
22+
protected static $validSchemes = ['mailto'];
2323

2424
/**
2525
* Validator for use when validating email address

src/Uri.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Uri implements UriInterface
114114
*
115115
* @var array
116116
*/
117-
protected static $validSchemes = array();
117+
protected static $validSchemes = [];
118118

119119
/**
120120
* List of default ports per scheme
@@ -125,7 +125,7 @@ class Uri implements UriInterface
125125
*
126126
* @var array
127127
*/
128-
protected static $defaultPorts = array();
128+
protected static $defaultPorts = [];
129129

130130
/**
131131
* @var Escaper
@@ -655,7 +655,7 @@ public function getQuery()
655655
*/
656656
public function getQueryAsArray()
657657
{
658-
$query = array();
658+
$query = [];
659659
if ($this->query) {
660660
parse_str($this->query, $query);
661661
}
@@ -1169,12 +1169,12 @@ public static function merge($baseUri, $relativeUri)
11691169
*/
11701170
protected static function isValidIpAddress($host, $allowed)
11711171
{
1172-
$validatorParams = array(
1172+
$validatorParams = [
11731173
'allowipv4' => (bool) ($allowed & self::HOST_IPV4),
11741174
'allowipv6' => false,
11751175
'allowipvfuture' => false,
11761176
'allowliteral' => false,
1177-
);
1177+
];
11781178

11791179
// Test only IPv4
11801180
$validator = new Validator\Ip($validatorParams);
@@ -1184,12 +1184,12 @@ protected static function isValidIpAddress($host, $allowed)
11841184
}
11851185

11861186
// IPv6 & IPvLiteral must be in literal format
1187-
$validatorParams = array(
1187+
$validatorParams = [
11881188
'allowipv4' => false,
11891189
'allowipv6' => (bool) ($allowed & self::HOST_IPV6),
11901190
'allowipvfuture' => (bool) ($allowed & self::HOST_IPVFUTURE),
11911191
'allowliteral' => true,
1192-
);
1192+
];
11931193
static $regex = '/^\[.*\]$/';
11941194
$validator->setOptions($validatorParams);
11951195
return (preg_match($regex, $host) && $validator->isValid($host));
@@ -1203,9 +1203,9 @@ protected static function isValidIpAddress($host, $allowed)
12031203
*/
12041204
protected static function isValidDnsHostname($host)
12051205
{
1206-
$validator = new Validator\Hostname(array(
1206+
$validator = new Validator\Hostname([
12071207
'allow' => Validator\Hostname::ALLOW_DNS | Validator\Hostname::ALLOW_LOCAL,
1208-
));
1208+
]);
12091209

12101210
return $validator->isValid($host);
12111211
}

src/UriFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ abstract class UriFactory
2626
*
2727
* @var array
2828
*/
29-
protected static $schemeClasses = array(
29+
protected static $schemeClasses = [
3030
'http' => 'Zend\Uri\Http',
3131
'https' => 'Zend\Uri\Http',
3232
'mailto' => 'Zend\Uri\Mailto',
3333
'file' => 'Zend\Uri\File',
3434
'urn' => 'Zend\Uri\Uri',
3535
'tag' => 'Zend\Uri\Uri',
36-
);
36+
];
3737

3838
/**
3939
* Register a scheme-specific class to be used

test/FileTest.php

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class FileTest extends TestCase
3030
*/
3131
public static function validSchemeProvider()
3232
{
33-
return array(
34-
array('file'),
35-
array('FILE'),
36-
array('File'),
37-
);
33+
return [
34+
['file'],
35+
['FILE'],
36+
['File'],
37+
];
3838
}
3939

4040
/**
@@ -44,51 +44,51 @@ public static function validSchemeProvider()
4444
*/
4545
public static function invalidSchemeProvider()
4646
{
47-
return array(
48-
array('mailto'),
49-
array('http'),
50-
array('g'),
51-
array('file:')
52-
);
47+
return [
48+
['mailto'],
49+
['http'],
50+
['g'],
51+
['file:']
52+
];
5353
}
5454

5555
public static function invalidUris()
5656
{
57-
return array(
58-
array('file:foo.bar/baz?bat=boo'),
59-
array('file://foo.bar:80/baz?bat=boo'),
60-
array('file://user:[email protected]:80/baz?bat=boo'),
61-
array('file:///baz?bat=boo'),
62-
);
57+
return [
58+
['file:foo.bar/baz?bat=boo'],
59+
['file://foo.bar:80/baz?bat=boo'],
60+
['file://user:[email protected]:80/baz?bat=boo'],
61+
['file:///baz?bat=boo'],
62+
];
6363
}
6464

6565
public static function validUris()
6666
{
67-
return array(
68-
array('file:///baz'),
69-
array('file://example.com/baz'),
70-
array('file://example.com:2132/baz'),
71-
array('file://example.com:2132/baz#fragment'),
72-
array('file://user:[email protected]:2132/baz'),
73-
array('file://C:/foo bar/baz'),
74-
);
67+
return [
68+
['file:///baz'],
69+
['file://example.com/baz'],
70+
['file://example.com:2132/baz'],
71+
['file://example.com:2132/baz#fragment'],
72+
['file://user:[email protected]:2132/baz'],
73+
['file://C:/foo bar/baz'],
74+
];
7575
}
7676

7777
public static function unixUris()
7878
{
79-
return array(
80-
array('/foo/bar/baz.bat', '/foo/bar/baz.bat'),
81-
array('/foo/bar/../baz.bat', '/foo/baz.bat'),
82-
array('/foo/bar/../../baz.bat', '/baz.bat'),
83-
array('/foo/bar baz.bat', '/foo/bar%20baz.bat'),
84-
);
79+
return [
80+
['/foo/bar/baz.bat', '/foo/bar/baz.bat'],
81+
['/foo/bar/../baz.bat', '/foo/baz.bat'],
82+
['/foo/bar/../../baz.bat', '/baz.bat'],
83+
['/foo/bar baz.bat', '/foo/bar%20baz.bat'],
84+
];
8585
}
8686

8787
public static function windowsUris()
8888
{
89-
return array(
90-
array('C:\Program Files\Zend Framework\README', 'C:/Program%20Files/Zend%20Framework/README'),
91-
);
89+
return [
90+
['C:\Program Files\Zend Framework\README', 'C:/Program%20Files/Zend%20Framework/README'],
91+
];
9292
}
9393

9494
/**
@@ -139,15 +139,15 @@ public function testValidateSchemeInvalid($scheme)
139139
public function testInvalidFileUris($uri)
140140
{
141141
$uri = new FileUri($uri);
142-
$parts = array(
142+
$parts = [
143143
'scheme' => $uri->getScheme(),
144144
'user_info' => $uri->getUserInfo(),
145145
'host' => $uri->getHost(),
146146
'port' => $uri->getPort(),
147147
'path' => $uri->getPath(),
148148
'query' => $uri->getQueryAsArray(),
149149
'fragment' => $uri->getFragment(),
150-
);
150+
];
151151
$this->assertFalse($uri->isValid(), var_export($parts, 1));
152152
}
153153

@@ -157,15 +157,15 @@ public function testInvalidFileUris($uri)
157157
public function testValidFileUris($uri)
158158
{
159159
$uri = new FileUri($uri);
160-
$parts = array(
160+
$parts = [
161161
'scheme' => $uri->getScheme(),
162162
'user_info' => $uri->getUserInfo(),
163163
'host' => $uri->getHost(),
164164
'port' => $uri->getPort(),
165165
'path' => $uri->getPath(),
166166
'query' => $uri->getQueryAsArray(),
167167
'fragment' => $uri->getFragment(),
168-
);
168+
];
169169
$this->assertTrue($uri->isValid(), var_export($parts, 1));
170170
}
171171

test/HttpTest.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,40 @@ class HttpTest extends TestCase
3030
*/
3131
public function validSchemeProvider()
3232
{
33-
return array(
34-
array('http'),
35-
array('https'),
36-
array('HTTP'),
37-
array('Https'),
38-
);
33+
return [
34+
['http'],
35+
['https'],
36+
['HTTP'],
37+
['Https'],
38+
];
3939
}
4040

4141
public function validHostProvider()
4242
{
43-
return array(
44-
array('', false),
45-
array('http', true),
46-
array('http:', false),
47-
array('http:/', false),
48-
array('http://', false),
49-
array('http:///', false),
50-
array('http://www.example.org/', false),
51-
array('www.example.org:80', false),
52-
array('www.example.org', true),
53-
array('plekitööd.ee', true),
54-
array('http://foo', false),
55-
array('foo', true),
56-
array('ftp://user:[email protected]/', false),
57-
array('www.fi/', false),
58-
array('http://1.1.1.1/', false),
59-
array('1.1.1.1', true),
60-
array('1.256.1.1', true), // Hostnames can be only numbers
61-
array('http://[::1]/', false),
62-
array('[::1]', true),
63-
array('http://[2620:0:1cfe:face:b00c::3]/', false),
64-
array('[2620:0:1cfe:face:b00c::3]:80', false),
65-
array('[2620:0:1cfe:face:b00c::3]', true),
66-
);
43+
return [
44+
['', false],
45+
['http', true],
46+
['http:', false],
47+
['http:/', false],
48+
['http://', false],
49+
['http:///', false],
50+
['http://www.example.org/', false],
51+
['www.example.org:80', false],
52+
['www.example.org', true],
53+
['plekitööd.ee', true],
54+
['http://foo', false],
55+
['foo', true],
56+
['ftp://user:[email protected]/', false],
57+
['www.fi/', false],
58+
['http://1.1.1.1/', false],
59+
['1.1.1.1', true],
60+
['1.256.1.1', true], // Hostnames can be only numbers
61+
['http://[::1]/', false],
62+
['[::1]', true],
63+
['http://[2620:0:1cfe:face:b00c::3]/', false],
64+
['[2620:0:1cfe:face:b00c::3]:80', false],
65+
['[2620:0:1cfe:face:b00c::3]', true],
66+
];
6767
}
6868

6969
/**
@@ -73,23 +73,23 @@ public function validHostProvider()
7373
*/
7474
public function invalidSchemeProvider()
7575
{
76-
return array(
77-
array('file'),
78-
array('mailto'),
79-
array('g'),
80-
array('http:')
81-
);
76+
return [
77+
['file'],
78+
['mailto'],
79+
['g'],
80+
['http:']
81+
];
8282
}
8383

8484
public function portNormalizationTestsProvider()
8585
{
86-
return array(
87-
array('http://www.example.com:80/foo/bar', 'http://www.example.com/foo/bar'),
88-
array('http://www.example.com:1234/foo/bar', 'http://www.example.com:1234/foo/bar'),
89-
array('https://www.example.com:443/foo/bar', 'https://www.example.com/foo/bar'),
90-
array('https://www.example.com:80/foo/bar', 'https://www.example.com:80/foo/bar'),
91-
array('http://www.example.com:443/foo/bar', 'http://www.example.com:443/foo/bar'),
92-
);
86+
return [
87+
['http://www.example.com:80/foo/bar', 'http://www.example.com/foo/bar'],
88+
['http://www.example.com:1234/foo/bar', 'http://www.example.com:1234/foo/bar'],
89+
['https://www.example.com:443/foo/bar', 'https://www.example.com/foo/bar'],
90+
['https://www.example.com:80/foo/bar', 'https://www.example.com:80/foo/bar'],
91+
['http://www.example.com:443/foo/bar', 'http://www.example.com:443/foo/bar'],
92+
];
9393
}
9494

9595
/**

0 commit comments

Comments
 (0)