Skip to content

Commit a656dd6

Browse files
committed
Use short-array syntax for lists
1 parent f872c7e commit a656dd6

9 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/HttpFactory/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function createStreamFromFile(string $filename, string $mode = 'r'): Stre
134134
$resource = \fopen($filename, $mode);
135135
\restore_error_handler();
136136
if ($resource === false) {
137-
if ($mode === '' || \in_array($mode[0], array('r', 'w', 'a', 'x', 'c'), true) === false) {
137+
if ($mode === '' || \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true) === false) {
138138
throw new InvalidArgumentException('The mode "' . $mode . '" is invalid.');
139139
}
140140
throw new RuntimeException(\sprintf(

src/HttpMessage/AbstractUri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class AbstractUri
5959
protected function assertHost($host): void
6060
{
6161
$this->assertString($host, 'host');
62-
if (\in_array($host, array('', 'localhost'), true)) {
62+
if (\in_array($host, ['', 'localhost'], true)) {
6363
// An empty host value is equivalent to removing the host.
6464
// No validation required
6565
return;

src/HttpMessage/AssertionTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ trait AssertionTrait
2727
*
2828
* @var numeric-string[]
2929
*/
30-
protected $validProtocolVers = array(
30+
protected $validProtocolVers = [
3131
'0.9',
3232
'1.0',
3333
'1.1',
3434
'2',
3535
'2.0',
3636
'3',
3737
'3.0',
38-
);
38+
];
3939

4040
/**
4141
* Test that value is a string (or optionally numeric)
@@ -130,7 +130,7 @@ private function assertHeaderName($name): void
130130
private function assertHeaderValue($value): void
131131
{
132132
if (\is_scalar($value) && \is_bool($value) === false) {
133-
$value = array((string) $value);
133+
$value = [(string) $value];
134134
}
135135
if (\is_array($value) === false) {
136136
throw new InvalidArgumentException(\sprintf(
@@ -447,7 +447,7 @@ protected function assertStatusCode($code): void
447447
*/
448448
private function iteratorPath(RecursiveIteratorIterator $iterator): string
449449
{
450-
$path = array();
450+
$path = [];
451451
for ($i = 0, $depth = $iterator->getDepth(); $i <= $depth; $i++) {
452452
$key = $iterator->getSubIterator($i)->key();
453453
$path[] = $i > 0

src/HttpMessage/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getHeader(string $name): array
127127
{
128128
$nameLower = \strtolower($name);
129129
if (!isset($this->headerNames[$nameLower])) {
130-
return array();
130+
return [];
131131
}
132132
$name = $this->headerNames[$nameLower];
133133
return $this->headers[$name];

src/HttpMessage/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ private function filterCodePhrase($code, $phrase)
130130
$phrase = ResponseUtil::codePhrase($code);
131131
}
132132
$this->assertReasonPhrase($phrase);
133-
return array($code, $phrase);
133+
return [$code, $phrase];
134134
}
135135
}

src/HttpMessage/ServerRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public function __construct(string $method = 'GET', $uri = '', array $serverPara
127127
? $parsed
128128
: null;
129129
});
130-
$this->registerMediaTypeParser(ContentType::XML_APP, array(__CLASS__, 'parseXml'));
131-
$this->registerMediaTypeParser(ContentType::XML, array(__CLASS__, 'parseXml'));
130+
$this->registerMediaTypeParser(ContentType::XML_APP, [__CLASS__, 'parseXml']);
131+
$this->registerMediaTypeParser(ContentType::XML, [__CLASS__, 'parseXml']);
132132
}
133133

134134
/**

src/HttpMessage/ServerRequestExtended.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getMediaTypeParams(): array
8787
'charset' => null,
8888
);
8989

90-
if ($contentType === array()) {
90+
if ($contentType === []) {
9191
return $params;
9292
}
9393

src/HttpMessage/Utility/ServerRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function fromGlobals($parseStrOpts = array()): ServerRequestExtend
7777
*
7878
* @throws InvalidArgumentException
7979
*/
80-
private static function filesFromGlobals(array $phpFiles, array $path = array()): array
80+
private static function filesFromGlobals(array $phpFiles, array $path = []): array
8181
{
8282
$files = array();
8383
/** @var mixed $value */
@@ -179,15 +179,15 @@ private static function fileFromGlobalCreate(array $fileInfo)
179179
*/
180180
private static function isUploadFileInfoArray(array $array): bool
181181
{
182-
$keysMustHave = array('name', 'type', 'tmp_name', 'size', 'error');
183-
$keysMayHave = array('full_path');
182+
$keysMustHave = ['name', 'type', 'tmp_name', 'size', 'error'];
183+
$keysMayHave = ['full_path'];
184184
$keys = \array_keys($array);
185185
if (\array_intersect($keysMustHave, $keys) !== $keysMustHave) {
186186
// missing must have
187187
return false;
188188
}
189189
// return true if no unknown keys
190-
return \array_diff($keys, \array_merge($keysMustHave, $keysMayHave)) === array();
190+
return \array_diff($keys, \array_merge($keysMustHave, $keysMayHave)) === [];
191191
}
192192

193193
/**

src/HttpMessage/Utility/Uri.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public static function fromParsed(array $parsed): BdkUri
6262
$uriKeys = ['fragment', 'host', 'path', 'port', 'query', 'scheme', 'userInfo'];
6363
$parsed = \array_intersect_key(self::parsedPartsPrep($parsed), \array_flip($uriKeys));
6464
$parsed = \array_filter($parsed, static function ($val) {
65-
return \in_array($val, array(null, ''), true) === false;
65+
return \in_array($val, [null, ''], true) === false;
6666
});
6767
$uri = new BdkUri();
6868
foreach ($parsed as $key => $value) {
6969
$method = 'with' . \ucfirst($key);
7070
/** @var BdkUri */
71-
$uri = \call_user_func_array(array($uri, $method), (array) $value);
71+
$uri = \call_user_func_array([uri, $method], (array) $value);
7272
}
7373
return $uri;
7474
}
@@ -199,7 +199,7 @@ private static function parsedPartsPrep(array $parsed): array
199199
'user' => '',
200200
), $renamed, $parsed);
201201
if (\array_key_exists('userInfo', $parsed) === false) {
202-
$parsed['userInfo'] = array($parsed['user'], $parsed['pass']);
202+
$parsed['userInfo'] = [$parsed['user'], $parsed['pass']];
203203
}
204204
if (\is_array($parsed['userInfo']) === false) {
205205
$parsed['userInfo'] = \explode(':', (string) $parsed['userInfo'], 2);
@@ -282,7 +282,7 @@ private static function pathRemoveDots(string $path): string
282282
if ($path[0] === '/' && (!isset($pathNew[0]) || $pathNew[0] !== '/')) {
283283
// Re-add the leading slash if necessary for cases like "/.."
284284
$pathNew = '/' . $pathNew;
285-
} elseif ($pathNew !== '' && \in_array(\end($segments), array('.', '..'), true)) {
285+
} elseif ($pathNew !== '' && \in_array(\end($segments), ['.', '..'], true)) {
286286
// Add the trailing slash if necessary
287287
$pathNew .= '/';
288288
}
@@ -342,7 +342,7 @@ private static function resolveTargetPath(UriInterface $base, UriInterface $rel)
342342
*/
343343
private static function uriInterfaceToParts(UriInterface $url): array
344344
{
345-
$userInfo = \array_replace(array(null, null), \explode(':', $url->getUserInfo(), 2));
345+
$userInfo = \array_replace([null, null], \explode(':', $url->getUserInfo(), 2));
346346
$parts = array(
347347
'pass' => $userInfo[1],
348348
'user' => $userInfo[0],

0 commit comments

Comments
 (0)