Skip to content

Commit 1b9c105

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents 9708dbe + 76f0eb1 commit 1b9c105

Some content is hidden

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

44 files changed

+630
-630
lines changed

Annotation/Route.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class Route
2424
private $path;
2525
private $localizedPaths = array();
2626
private $name;
27-
private $requirements = array();
28-
private $options = array();
29-
private $defaults = array();
27+
private $requirements = [];
28+
private $options = [];
29+
private $defaults = [];
3030
private $host;
31-
private $methods = array();
32-
private $schemes = array();
31+
private $methods = [];
32+
private $schemes = [];
3333
private $condition;
3434

3535
/**
@@ -134,7 +134,7 @@ public function getDefaults()
134134

135135
public function setSchemes($schemes)
136136
{
137-
$this->schemes = \is_array($schemes) ? $schemes : array($schemes);
137+
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
138138
}
139139

140140
public function getSchemes()
@@ -144,7 +144,7 @@ public function getSchemes()
144144

145145
public function setMethods($methods)
146146
{
147-
$this->methods = \is_array($methods) ? $methods : array($methods);
147+
$this->methods = \is_array($methods) ? $methods : [$methods];
148148
}
149149

150150
public function getMethods()

CHANGELOG.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ CHANGELOG
4747
Before:
4848

4949
```php
50-
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
50+
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
5151
```
5252

5353
After:
5454

5555
```php
5656
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
5757

58-
$router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
58+
$router->generate('blog_show', ['slug' => 'my-blog-post'], UrlGeneratorInterface::ABSOLUTE_URL);
5959
```
6060

6161
2.5.0
@@ -120,7 +120,7 @@ CHANGELOG
120120
```php
121121
$route = new Route();
122122
$route->setPath('/article/{id}');
123-
$route->setMethods(array('POST', 'PUT'));
123+
$route->setMethods(['POST', 'PUT']);
124124
$route->setSchemes('https');
125125
```
126126

@@ -175,10 +175,10 @@ CHANGELOG
175175
used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
176176
will still work, but have been deprecated. The `addPrefix` method should be used for this
177177
use-case instead.
178-
Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
178+
Before: `$parentCollection->addCollection($collection, '/prefix', [...], [...])`
179179
After:
180180
```php
181-
$collection->addPrefix('/prefix', array(...), array(...));
181+
$collection->addPrefix('/prefix', [...], [...]);
182182
$parentCollection->addCollection($collection);
183183
```
184184
* added support for the method default argument values when defining a @Route
@@ -203,7 +203,7 @@ CHANGELOG
203203
(only relevant if you implemented your own RouteCompiler).
204204
* Added possibility to generate relative paths and network paths in the UrlGenerator, e.g.
205205
"../parent-file" and "//example.com/dir/file". The third parameter in
206-
`UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)`
206+
`UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)`
207207
now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for
208208
claritiy. The old method calls with a Boolean parameter will continue to work because they
209209
equal the signature using the constants.

DependencyInjection/RoutingResolverPass.php

+1-1
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

+1-1
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, string $message = null, int $code = 0, \Exception $previous = null)
2626
{

Generator/Dumper/GeneratorDumperInterface.php

+1-1
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

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class PhpGeneratorDumper extends GeneratorDumper
3333
*
3434
* @return string A PHP class representing the generator class
3535
*/
36-
public function dump(array $options = array())
36+
public function dump(array $options = [])
3737
{
38-
$options = array_merge(array(
38+
$options = array_merge([
3939
'class' => 'ProjectUrlGenerator',
4040
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
41-
), $options);
41+
], $options);
4242

4343
return <<<EOF
4444
<?php
@@ -80,11 +80,11 @@ public function __construct(RequestContext \$context, LoggerInterface \$logger =
8080
*/
8181
private function generateDeclaredRoutes()
8282
{
83-
$routes = "array(\n";
83+
$routes = "[\n";
8484
foreach ($this->getRoutes()->all() as $name => $route) {
8585
$compiledRoute = $route->compile();
8686

87-
$properties = array();
87+
$properties = [];
8888
$properties[] = $compiledRoute->getVariables();
8989
$properties[] = $route->getDefaults();
9090
$properties[] = $route->getRequirements();
@@ -94,7 +94,7 @@ private function generateDeclaredRoutes()
9494

9595
$routes .= sprintf(" '%s' => %s,\n", $name, PhpMatcherDumper::export($properties));
9696
}
97-
$routes .= ' )';
97+
$routes .= ' ]';
9898

9999
return $routes;
100100
}
@@ -107,7 +107,7 @@ private function generateDeclaredRoutes()
107107
private function generateGenerateMethod()
108108
{
109109
return <<<'EOF'
110-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
110+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
111111
{
112112
$locale = $parameters['_locale']
113113
?? $this->context->getParameter('_locale')

Generator/UrlGenerator.php

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

7070
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
7171
{
@@ -110,7 +110,7 @@ public function isStrictRequirements()
110110
/**
111111
* {@inheritdoc}
112112
*/
113-
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
113+
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
114114
{
115115
$locale = $parameters['_locale']
116116
?? $this->context->getParameter('_locale')
@@ -133,7 +133,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
133133
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
134134
* it does not match the requirement
135135
*/
136-
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
136+
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
137137
{
138138
$variables = array_flip($variables);
139139
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@@ -152,11 +152,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
152152
// check requirement
153153
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
154154
if ($this->strictRequirements) {
155-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
155+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
156156
}
157157

158158
if ($this->logger) {
159-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
159+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
160160
}
161161

162162
return;
@@ -182,7 +182,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
182182
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
183183
// so we need to encode them as they are not used for this purpose here
184184
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
185-
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
185+
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
186186
if ('/..' === substr($url, -3)) {
187187
$url = substr($url, 0, -2).'%2E%2E';
188188
} elseif ('/.' === substr($url, -2)) {
@@ -206,11 +206,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
206206
if ('variable' === $token[0]) {
207207
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
208208
if ($this->strictRequirements) {
209-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
209+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
210210
}
211211

212212
if ($this->logger) {
213-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
213+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
214214
}
215215

216216
return;
@@ -264,11 +264,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
264264
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
265265
// "/" and "?" can be left decoded for better user experience, see
266266
// http://tools.ietf.org/html/rfc3986#section-3.4
267-
$url .= '?'.strtr($query, array('%2F' => '/'));
267+
$url .= '?'.strtr($query, ['%2F' => '/']);
268268
}
269269

270270
if ('' !== $fragment) {
271-
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
271+
$url .= '#'.strtr(rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
272272
}
273273

274274
return $url;

Generator/UrlGeneratorInterface.php

+1-1
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/AnnotationFileLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function findClass($file)
104104

105105
if (true === $namespace && T_STRING === $token[0]) {
106106
$namespace = $token[1];
107-
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_NS_SEPARATOR, T_STRING))) {
107+
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) {
108108
$namespace .= $tokens[$i][1];
109109
}
110110
$token = $tokens[$i];
@@ -121,7 +121,7 @@ protected function findClass($file)
121121
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
122122
$skipClassToken = true;
123123
break;
124-
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
124+
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
125125
break;
126126
}
127127
}

Loader/Configurator/Traits/RouteTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ final public function methods(array $methods)
120120
*/
121121
final public function controller($controller)
122122
{
123-
$this->route->addDefaults(array('_controller' => $controller));
123+
$this->route->addDefaults(['_controller' => $controller]);
124124

125125
return $this;
126126
}

Matcher/Dumper/MatcherDumperInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface MatcherDumperInterface
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.

Matcher/TraceableUrlMatcher.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TraceableUrlMatcher extends UrlMatcher
3131

3232
public function getTraces($pathinfo)
3333
{
34-
$this->traces = array();
34+
$this->traces = [];
3535

3636
try {
3737
$this->match($pathinfo);
@@ -57,7 +57,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
5757

5858
if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) {
5959
// does it match without any requirements?
60-
$r = new Route($route->getPath(), $route->getDefaults(), array(), $route->getOptions());
60+
$r = new Route($route->getPath(), $route->getDefaults(), [], $route->getOptions());
6161
$cr = $r->compile();
6262
if (!preg_match($cr->getRegex(), $pathinfo)) {
6363
$this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name, $route);
@@ -66,7 +66,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
6666
}
6767

6868
foreach ($route->getRequirements() as $n => $regex) {
69-
$r = new Route($route->getPath(), $route->getDefaults(), array($n => $regex), $route->getOptions());
69+
$r = new Route($route->getPath(), $route->getDefaults(), [$n => $regex], $route->getOptions());
7070
$cr = $r->compile();
7171

7272
if (\in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) {
@@ -80,7 +80,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
8080
}
8181

8282
// check host requirement
83-
$hostMatches = array();
83+
$hostMatches = [];
8484
if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) {
8585
$this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route);
8686

@@ -105,7 +105,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
105105

106106
// check condition
107107
if ($condition = $route->getCondition()) {
108-
if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) {
108+
if (!$this->getExpressionLanguage()->evaluate($condition, ['context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)])) {
109109
$this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $condition), self::ROUTE_ALMOST_MATCHES, $name, $route);
110110

111111
continue;
@@ -131,11 +131,11 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
131131

132132
private function addTrace($log, $level = self::ROUTE_DOES_NOT_MATCH, $name = null, $route = null)
133133
{
134-
$this->traces[] = array(
134+
$this->traces[] = [
135135
'log' => $log,
136136
'name' => $name,
137137
'level' => $level,
138138
'path' => null !== $route ? $route->getPath() : null,
139-
);
139+
];
140140
}
141141
}

RequestContext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RequestContext
3131
private $httpPort;
3232
private $httpsPort;
3333
private $queryString;
34-
private $parameters = array();
34+
private $parameters = [];
3535

3636
public function __construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '')
3737
{

RouteCollection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class RouteCollection implements \IteratorAggregate, \Countable
2828
/**
2929
* @var Route[]
3030
*/
31-
private $routes = array();
31+
private $routes = [];
3232

3333
/**
3434
* @var array
3535
*/
36-
private $resources = array();
36+
private $resources = [];
3737

3838
public function __clone()
3939
{
@@ -138,7 +138,7 @@ public function addCollection(self $collection)
138138
* @param array $defaults An array of default values
139139
* @param array $requirements An array of requirements
140140
*/
141-
public function addPrefix($prefix, array $defaults = array(), array $requirements = array())
141+
public function addPrefix($prefix, array $defaults = [], array $requirements = [])
142142
{
143143
$prefix = trim(trim($prefix), '/');
144144

@@ -177,7 +177,7 @@ public function addNamePrefix(string $prefix)
177177
* @param array $defaults An array of default values
178178
* @param array $requirements An array of requirements
179179
*/
180-
public function setHost($pattern, array $defaults = array(), array $requirements = array())
180+
public function setHost($pattern, array $defaults = [], array $requirements = [])
181181
{
182182
foreach ($this->routes as $route) {
183183
$route->setHost($pattern);

0 commit comments

Comments
 (0)