Skip to content

Commit 67146f6

Browse files
committed
switched array() to []
1 parent 445d362 commit 67146f6

File tree

61 files changed

+1210
-1210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1210
-1210
lines changed

Annotation/Route.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class Route
2323
{
2424
private $path;
2525
private $name;
26-
private $requirements = array();
27-
private $options = array();
28-
private $defaults = array();
26+
private $requirements = [];
27+
private $options = [];
28+
private $defaults = [];
2929
private $host;
30-
private $methods = array();
31-
private $schemes = array();
30+
private $methods = [];
31+
private $schemes = [];
3232
private $condition;
3333

3434
/**
@@ -114,7 +114,7 @@ public function getDefaults()
114114

115115
public function setSchemes($schemes)
116116
{
117-
$this->schemes = \is_array($schemes) ? $schemes : array($schemes);
117+
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
118118
}
119119

120120
public function getSchemes()
@@ -124,7 +124,7 @@ public function getSchemes()
124124

125125
public function setMethods($methods)
126126
{
127-
$this->methods = \is_array($methods) ? $methods : array($methods);
127+
$this->methods = \is_array($methods) ? $methods : [$methods];
128128
}
129129

130130
public function getMethods()

CompiledRoute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CompiledRoute implements \Serializable
3737
* @param array $hostVariables An array of host variables
3838
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
3939
*/
40-
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
40+
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
4141
{
4242
$this->staticPrefix = (string) $staticPrefix;
4343
$this->regex = $regex;
@@ -54,7 +54,7 @@ public function __construct($staticPrefix, $regex, array $tokens, array $pathVar
5454
*/
5555
public function serialize()
5656
{
57-
return serialize(array(
57+
return serialize([
5858
'vars' => $this->variables,
5959
'path_prefix' => $this->staticPrefix,
6060
'path_regex' => $this->regex,
@@ -63,7 +63,7 @@ public function serialize()
6363
'host_regex' => $this->hostRegex,
6464
'host_tokens' => $this->hostTokens,
6565
'host_vars' => $this->hostVariables,
66-
));
66+
]);
6767
}
6868

6969
/**
@@ -72,7 +72,7 @@ public function serialize()
7272
public function unserialize($serialized)
7373
{
7474
if (\PHP_VERSION_ID >= 70000) {
75-
$data = unserialize($serialized, array('allowed_classes' => false));
75+
$data = unserialize($serialized, ['allowed_classes' => false]);
7676
} else {
7777
$data = unserialize($serialized);
7878
}

DependencyInjection/RoutingResolverPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function process(ContainerBuilder $container)
4343
$definition = $container->getDefinition($this->resolverServiceId);
4444

4545
foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) {
46-
$definition->addMethodCall('addLoader', array(new Reference($id)));
46+
$definition->addMethodCall('addLoader', [new Reference($id)]);
4747
}
4848
}
4949
}

Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
2222
{
23-
protected $allowedMethods = array();
23+
protected $allowedMethods = [];
2424

2525
public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
2626
{

Generator/Dumper/GeneratorDumperInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface GeneratorDumperInterface
2828
*
2929
* @return string Executable code
3030
*/
31-
public function dump(array $options = array());
31+
public function dump(array $options = []);
3232

3333
/**
3434
* Gets the routes to dump.

Generator/Dumper/PhpGeneratorDumper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class PhpGeneratorDumper extends GeneratorDumper
3131
*
3232
* @return string A PHP class representing the generator class
3333
*/
34-
public function dump(array $options = array())
34+
public function dump(array $options = [])
3535
{
36-
$options = array_merge(array(
36+
$options = array_merge([
3737
'class' => 'ProjectUrlGenerator',
3838
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
39-
), $options);
39+
], $options);
4040

4141
return <<<EOF
4242
<?php
@@ -80,7 +80,7 @@ private function generateDeclaredRoutes()
8080
foreach ($this->getRoutes()->all() as $name => $route) {
8181
$compiledRoute = $route->compile();
8282

83-
$properties = array();
83+
$properties = [];
8484
$properties[] = $compiledRoute->getVariables();
8585
$properties[] = $route->getDefaults();
8686
$properties[] = $route->getRequirements();

Generator/UrlGenerator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
4545
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
4646
* "'" and """ (are used as delimiters in HTML).
4747
*/
48-
protected $decodedChars = array(
48+
protected $decodedChars = [
4949
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
5050
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
5151
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
@@ -63,7 +63,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
6363
'%21' => '!',
6464
'%2A' => '*',
6565
'%7C' => '|',
66-
);
66+
];
6767

6868
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null)
6969
{
@@ -107,7 +107,7 @@ public function isStrictRequirements()
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
110+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
111111
{
112112
if (null === $route = $this->routes->get($name)) {
113113
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
@@ -124,7 +124,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
124124
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
125125
* it does not match the requirement
126126
*/
127-
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
127+
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
128128
{
129129
$variables = array_flip($variables);
130130
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@@ -143,11 +143,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
143143
// check requirement
144144
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
145145
if ($this->strictRequirements) {
146-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
146+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
147147
}
148148

149149
if ($this->logger) {
150-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
150+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
151151
}
152152

153153
return;
@@ -173,7 +173,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
173173
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
174174
// so we need to encode them as they are not used for this purpose here
175175
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
176-
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
176+
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
177177
if ('/..' === substr($url, -3)) {
178178
$url = substr($url, 0, -2).'%2E%2E';
179179
} elseif ('/.' === substr($url, -2)) {
@@ -197,11 +197,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
197197
if ('variable' === $token[0]) {
198198
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
199199
if ($this->strictRequirements) {
200-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
200+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
201201
}
202202

203203
if ($this->logger) {
204-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
204+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
205205
}
206206

207207
return;
@@ -258,11 +258,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
258258
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
259259
// "/" and "?" can be left decoded for better user experience, see
260260
// http://tools.ietf.org/html/rfc3986#section-3.4
261-
$url .= '?'.strtr($query, array('%2F' => '/'));
261+
$url .= '?'.strtr($query, ['%2F' => '/']);
262262
}
263263

264264
if ('' !== $fragment) {
265-
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
265+
$url .= '#'.strtr(rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
266266
}
267267

268268
return $url;

Generator/UrlGeneratorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
8282
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
8383
* it does not match the requirement
8484
*/
85-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH);
85+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH);
8686
}

Loader/AnnotationClassLoader.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,17 @@ protected function getGlobals(\ReflectionClass $class)
255255

256256
private function resetGlobals()
257257
{
258-
return array(
258+
return [
259259
'path' => '',
260-
'requirements' => array(),
261-
'options' => array(),
262-
'defaults' => array(),
263-
'schemes' => array(),
264-
'methods' => array(),
260+
'requirements' => [],
261+
'options' => [],
262+
'defaults' => [],
263+
'schemes' => [],
264+
'methods' => [],
265265
'host' => '',
266266
'condition' => '',
267267
'name' => '',
268-
);
268+
];
269269
}
270270

271271
protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition)

Loader/AnnotationFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function findClass($file)
105105

106106
if (true === $namespace && T_STRING === $token[0]) {
107107
$namespace = $token[1];
108-
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) {
108+
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) {
109109
$namespace .= $tokens[$i][1];
110110
}
111111
$token = $tokens[$i];
@@ -122,7 +122,7 @@ protected function findClass($file)
122122
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
123123
$skipClassToken = true;
124124
break;
125-
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
125+
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
126126
break;
127127
}
128128
}

0 commit comments

Comments
 (0)