Skip to content

Commit

Permalink
switched array() to []
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 16, 2019
1 parent c149387 commit 3ce4d61
Show file tree
Hide file tree
Showing 76 changed files with 1,366 additions and 1,366 deletions.
2 changes: 1 addition & 1 deletion AcceptHeader.php
Expand Up @@ -24,7 +24,7 @@ class AcceptHeader
/**
* @var AcceptHeaderItem[]
*/
private $items = array();
private $items = [];

/**
* @var bool
Expand Down
6 changes: 3 additions & 3 deletions AcceptHeaderItem.php
Expand Up @@ -21,13 +21,13 @@ class AcceptHeaderItem
private $value;
private $quality = 1.0;
private $index = 0;
private $attributes = array();
private $attributes = [];

/**
* @param string $value
* @param array $attributes
*/
public function __construct($value, array $attributes = array())
public function __construct($value, array $attributes = [])
{
$this->value = $value;
foreach ($attributes as $name => $value) {
Expand All @@ -46,7 +46,7 @@ public static function fromString($itemValue)
{
$bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$value = array_shift($bits);
$attributes = array();
$attributes = [];

$lastNullAttribute = null;
foreach ($bits as $bit) {
Expand Down
6 changes: 3 additions & 3 deletions BinaryFileResponse.php
Expand Up @@ -44,7 +44,7 @@ class BinaryFileResponse extends Response
* @param bool $autoEtag Whether the ETag header should be automatically set
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
*/
public function __construct($file, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
public function __construct($file, $status = 200, $headers = [], $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
{
parent::__construct(null, $status, $headers);

Expand All @@ -66,7 +66,7 @@ public function __construct($file, $status = 200, $headers = array(), $public =
*
* @return static
*/
public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
public static function create($file = null, $status = 200, $headers = [], $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
{
return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified);
}
Expand Down Expand Up @@ -239,7 +239,7 @@ public function prepare(Request $request)
if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) {
$range = $request->headers->get('Range');

list($start, $end) = explode('-', substr($range, 6), 2) + array(0);
list($start, $end) = explode('-', substr($range, 6), 2) + [0];

$end = ('' === $end) ? $fileSize - 1 : (int) $end;

Expand Down
6 changes: 3 additions & 3 deletions Cookie.php
Expand Up @@ -41,15 +41,15 @@ class Cookie
*/
public static function fromString($cookie, $decode = false)
{
$data = array(
$data = [
'expires' => 0,
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => false,
'raw' => !$decode,
'samesite' => null,
);
];
foreach (explode(';', $cookie) as $part) {
if (false === strpos($part, '=')) {
$key = trim($part);
Expand Down Expand Up @@ -128,7 +128,7 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
$sameSite = strtolower($sameSite);
}

if (!\in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
if (!\in_array($sameSite, [self::SAMESITE_LAX, self::SAMESITE_STRICT, null], true)) {
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
}

Expand Down
4 changes: 2 additions & 2 deletions ExpressionRequestMatcher.php
Expand Up @@ -35,13 +35,13 @@ public function matches(Request $request)
throw new \LogicException('Unable to match the request as the expression language is not available.');
}

return $this->language->evaluate($this->expression, array(
return $this->language->evaluate($this->expression, [
'request' => $request,
'method' => $request->getMethod(),
'path' => rawurldecode($request->getPathInfo()),
'host' => $request->getHost(),
'ip' => $request->getClientIp(),
'attributes' => $request->attributes->all(),
)) && parent::matches($request);
]) && parent::matches($request);
}
}
2 changes: 1 addition & 1 deletion File/MimeType/ExtensionGuesser.php
Expand Up @@ -37,7 +37,7 @@ class ExtensionGuesser implements ExtensionGuesserInterface
*
* @var array
*/
protected $guessers = array();
protected $guessers = [];

/**
* Returns the singleton instance.
Expand Down
2 changes: 1 addition & 1 deletion File/MimeType/MimeTypeGuesser.php
Expand Up @@ -51,7 +51,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
*
* @var array
*/
protected $guessers = array();
protected $guessers = [];

/**
* Returns the singleton instance.
Expand Down
4 changes: 2 additions & 2 deletions File/UploadedFile.php
Expand Up @@ -249,15 +249,15 @@ public static function getMaxFilesize()
*/
public function getErrorMessage()
{
static $errors = array(
static $errors = [
UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).',
UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.',
UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.',
UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.',
UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.',
);
];

$errorCode = $this->error;
$maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
Expand Down
16 changes: 8 additions & 8 deletions FileBag.php
Expand Up @@ -21,22 +21,22 @@
*/
class FileBag extends ParameterBag
{
private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
private static $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type'];

/**
* @param array $parameters An array of HTTP files
*/
public function __construct(array $parameters = array())
public function __construct(array $parameters = [])
{
$this->replace($parameters);
}

/**
* {@inheritdoc}
*/
public function replace(array $files = array())
public function replace(array $files = [])
{
$this->parameters = array();
$this->parameters = [];
$this->add($files);
}

Expand All @@ -55,7 +55,7 @@ public function set($key, $value)
/**
* {@inheritdoc}
*/
public function add(array $files = array())
public function add(array $files = [])
{
foreach ($files as $key => $file) {
$this->set($key, $file);
Expand Down Expand Up @@ -87,7 +87,7 @@ protected function convertFileInformation($file)
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
}
} else {
$file = array_map(array($this, 'convertFileInformation'), $file);
$file = array_map([$this, 'convertFileInformation'], $file);
if (array_keys($keys) === $keys) {
$file = array_filter($file);
}
Expand Down Expand Up @@ -130,13 +130,13 @@ protected function fixPhpFilesArray($data)
}

foreach ($data['name'] as $key => $name) {
$files[$key] = $this->fixPhpFilesArray(array(
$files[$key] = $this->fixPhpFilesArray([
'error' => $data['error'][$key],
'name' => $name,
'type' => $data['type'][$key],
'tmp_name' => $data['tmp_name'][$key],
'size' => $data['size'][$key],
));
]);
}

return $files;
Expand Down
22 changes: 11 additions & 11 deletions HeaderBag.php
Expand Up @@ -18,13 +18,13 @@
*/
class HeaderBag implements \IteratorAggregate, \Countable
{
protected $headers = array();
protected $cacheControl = array();
protected $headers = [];
protected $cacheControl = [];

/**
* @param array $headers An array of HTTP headers
*/
public function __construct(array $headers = array())
public function __construct(array $headers = [])
{
foreach ($headers as $key => $values) {
$this->set($key, $values);
Expand Down Expand Up @@ -80,9 +80,9 @@ public function keys()
*
* @param array $headers An array of HTTP headers
*/
public function replace(array $headers = array())
public function replace(array $headers = [])
{
$this->headers = array();
$this->headers = [];
$this->add($headers);
}

Expand Down Expand Up @@ -114,10 +114,10 @@ public function get($key, $default = null, $first = true)

if (!array_key_exists($key, $headers)) {
if (null === $default) {
return $first ? null : array();
return $first ? null : [];
}

return $first ? $default : array($default);
return $first ? $default : [$default];
}

if ($first) {
Expand Down Expand Up @@ -148,7 +148,7 @@ public function set($key, $values, $replace = true)
}
} else {
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = array($values);
$this->headers[$key] = [$values];
} else {
$this->headers[$key][] = $values;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public function remove($key)
unset($this->headers[$key]);

if ('cache-control' === $key) {
$this->cacheControl = array();
$this->cacheControl = [];
}
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public function count()

protected function getCacheControlHeader()
{
$parts = array();
$parts = [];
ksort($this->cacheControl);
foreach ($this->cacheControl as $key => $value) {
if (true === $value) {
Expand All @@ -320,7 +320,7 @@ protected function getCacheControlHeader()
*/
protected function parseCacheControl($header)
{
$cacheControl = array();
$cacheControl = [];
preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true);
Expand Down
4 changes: 2 additions & 2 deletions IpUtils.php
Expand Up @@ -18,7 +18,7 @@
*/
class IpUtils
{
private static $checkedIps = array();
private static $checkedIps = [];

/**
* This class should not be instantiated.
Expand All @@ -38,7 +38,7 @@ private function __construct()
public static function checkIp($requestIp, $ips)
{
if (!\is_array($ips)) {
$ips = array($ips);
$ips = [$ips];
}

$method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4';
Expand Down
12 changes: 6 additions & 6 deletions JsonResponse.php
Expand Up @@ -39,7 +39,7 @@ class JsonResponse extends Response
* @param array $headers An array of response headers
* @param bool $json If the data is already a JSON string
*/
public function __construct($data = null, $status = 200, $headers = array(), $json = false)
public function __construct($data = null, $status = 200, $headers = [], $json = false)
{
parent::__construct('', $status, $headers);

Expand All @@ -64,15 +64,15 @@ public function __construct($data = null, $status = 200, $headers = array(), $js
*
* @return static
*/
public static function create($data = null, $status = 200, $headers = array())
public static function create($data = null, $status = 200, $headers = [])
{
return new static($data, $status, $headers);
}

/**
* Make easier the creation of JsonResponse from raw json.
*/
public static function fromJsonString($data = null, $status = 200, $headers = array())
public static function fromJsonString($data = null, $status = 200, $headers = [])
{
return new static($data, $status, $headers, true);
}
Expand All @@ -94,11 +94,11 @@ public function setCallback($callback = null)
// JsonpCallbackValidator is released under the MIT License. See https://github.com/willdurand/JsonpCallbackValidator/blob/v1.1.0/LICENSE for details.
// (c) William Durand <william.durand1@gmail.com>
$pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*(?:\[(?:"(?:\\\.|[^"\\\])*"|\'(?:\\\.|[^\'\\\])*\'|\d+)\])*?$/u';
$reserved = array(
$reserved = [
'break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while',
'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export',
'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false',
);
];
$parts = explode('.', $callback);
foreach ($parts as $part) {
if (!preg_match($pattern, $part) || \in_array($part, $reserved, true)) {
Expand Down Expand Up @@ -137,7 +137,7 @@ public function setJson($json)
*
* @throws \InvalidArgumentException
*/
public function setData($data = array())
public function setData($data = [])
{
if (\defined('HHVM_VERSION')) {
// HHVM does not trigger any warnings and let exceptions
Expand Down
12 changes: 6 additions & 6 deletions ParameterBag.php
Expand Up @@ -26,7 +26,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
/**
* @param array $parameters An array of parameters
*/
public function __construct(array $parameters = array())
public function __construct(array $parameters = [])
{
$this->parameters = $parameters;
}
Expand Down Expand Up @@ -56,7 +56,7 @@ public function keys()
*
* @param array $parameters An array of parameters
*/
public function replace(array $parameters = array())
public function replace(array $parameters = [])
{
$this->parameters = $parameters;
}
Expand All @@ -66,7 +66,7 @@ public function replace(array $parameters = array())
*
* @param array $parameters An array of parameters
*/
public function add(array $parameters = array())
public function add(array $parameters = [])
{
$this->parameters = array_replace($this->parameters, $parameters);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public function getAlnum($key, $default = '')
public function getDigits($key, $default = '')
{
// we need to remove - and + because they're allowed in the filter
return str_replace(array('-', '+'), '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT));
return str_replace(['-', '+'], '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT));
}

/**
Expand Down Expand Up @@ -195,13 +195,13 @@ public function getBoolean($key, $default = false)
*
* @return mixed
*/
public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = array())
public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = [])
{
$value = $this->get($key, $default);

// Always turn $options into an array - this allows filter_var option shortcuts.
if (!\is_array($options) && $options) {
$options = array('flags' => $options);
$options = ['flags' => $options];
}

// Add a convenience check for arrays.
Expand Down

0 comments on commit 3ce4d61

Please sign in to comment.