Skip to content

Commit 32c7238

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: fixed tests fixed CS fixed CS 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 e69b7a1 + c948191 commit 32c7238

File tree

63 files changed

+1236
-1236
lines changed

Some content is hidden

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

63 files changed

+1236
-1236
lines changed

Annotation/Route.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
class Route
2323
{
2424
private $path;
25-
private $localizedPaths = array();
25+
private $localizedPaths = [];
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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ CHANGELOG
5252
Before:
5353

5454
```php
55-
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
55+
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
5656
```
5757

5858
After:
5959

6060
```php
6161
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
6262

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

6666
2.5.0
@@ -125,7 +125,7 @@ CHANGELOG
125125
```php
126126
$route = new Route();
127127
$route->setPath('/article/{id}');
128-
$route->setMethods(array('POST', 'PUT'));
128+
$route->setMethods(['POST', 'PUT']);
129129
$route->setSchemes('https');
130130
```
131131

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

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(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
40+
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
4141
{
4242
$this->staticPrefix = $staticPrefix;
4343
$this->regex = $regex;
@@ -54,7 +54,7 @@ public function __construct(string $staticPrefix, string $regex, array $tokens,
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,15 +63,15 @@ public function serialize()
6363
'host_regex' => $this->hostRegex,
6464
'host_tokens' => $this->hostTokens,
6565
'host_vars' => $this->hostVariables,
66-
));
66+
]);
6767
}
6868

6969
/**
7070
* {@inheritdoc}
7171
*/
7272
public function unserialize($serialized)
7373
{
74-
$data = unserialize($serialized, array('allowed_classes' => false));
74+
$data = unserialize($serialized, ['allowed_classes' => false]);
7575

7676
$this->variables = $data['vars'];
7777
$this->staticPrefix = $data['path_prefix'];

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, string $message = null, int $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: 7 additions & 7 deletions
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

Lines changed: 11 additions & 11 deletions
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
$route = null;
116116
$locale = $parameters['_locale']
@@ -141,7 +141,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB
141141
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
142142
* it does not match the requirement
143143
*/
144-
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
144+
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
145145
{
146146
$variables = array_flip($variables);
147147
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@@ -160,11 +160,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
160160
// check requirement
161161
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
162162
if ($this->strictRequirements) {
163-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
163+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
164164
}
165165

166166
if ($this->logger) {
167-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
167+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
168168
}
169169

170170
return;
@@ -190,7 +190,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
190190
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
191191
// so we need to encode them as they are not used for this purpose here
192192
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
193-
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
193+
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
194194
if ('/..' === substr($url, -3)) {
195195
$url = substr($url, 0, -2).'%2E%2E';
196196
} elseif ('/.' === substr($url, -2)) {
@@ -214,11 +214,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
214214
if ('variable' === $token[0]) {
215215
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
216216
if ($this->strictRequirements) {
217-
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
217+
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
218218
}
219219

220220
if ($this->logger) {
221-
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
221+
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
222222
}
223223

224224
return;
@@ -272,11 +272,11 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
272272
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
273273
// "/" and "?" can be left decoded for better user experience, see
274274
// http://tools.ietf.org/html/rfc3986#section-3.4
275-
$url .= '?'.strtr($query, array('%2F' => '/'));
275+
$url .= '?'.strtr($query, ['%2F' => '/']);
276276
}
277277

278278
if ('' !== $fragment) {
279-
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
279+
$url .= '#'.strtr(rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
280280
}
281281

282282
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
165165

166166
$path = $annot->getLocalizedPaths() ?: $annot->getPath();
167167
$prefix = $globals['localized_paths'] ?: $globals['path'];
168-
$paths = array();
168+
$paths = [];
169169

170170
if (\is_array($path)) {
171171
if (!\is_array($prefix)) {
@@ -312,18 +312,18 @@ protected function getGlobals(\ReflectionClass $class)
312312

313313
private function resetGlobals()
314314
{
315-
return array(
315+
return [
316316
'path' => null,
317-
'localized_paths' => array(),
318-
'requirements' => array(),
319-
'options' => array(),
320-
'defaults' => array(),
321-
'schemes' => array(),
322-
'methods' => array(),
317+
'localized_paths' => [],
318+
'requirements' => [],
319+
'options' => [],
320+
'defaults' => [],
321+
'schemes' => [],
322+
'methods' => [],
323323
'host' => '',
324324
'condition' => '',
325325
'name' => '',
326-
);
326+
];
327327
}
328328

329329
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
@@ -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/AddTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait AddTrait
3434
*/
3535
final public function add(string $name, $path): RouteConfigurator
3636
{
37-
$paths = array();
37+
$paths = [];
3838
$parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
3939

4040
if (\is_array($path)) {

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 1 addition & 1 deletion
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
}

Loader/ObjectRouteLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function load($resource, $type = null)
6363
throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
6464
}
6565

66-
if (!\is_callable(array($loaderObject, $method))) {
66+
if (!\is_callable([$loaderObject, $method])) {
6767
throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
6868
}
6969

0 commit comments

Comments
 (0)