Permalink
Browse files

minor #29903 Move from array() to [] (fabpot)

This PR was squashed before being merged into the 3.4 branch (closes #29903).

Discussion
----------

Move from array() to []

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

37ab4cd fixed CS
1429267 fixed short array CS in comments
2524083 fixed CS in ExpressionLanguage fixtures
ec7dcb2 fixed CS in generated files
afaa13e fixed CS on generated container files
7ffd8d3 fixed CS on Form PHP templates
0ba1acc fixed CS on YAML fixtures
ac9d6cf fixed fixtures
33a001e switched array() to []
  • Loading branch information...
fabpot committed Jan 16, 2019
2 parents c7f46e4 + 37ab4cd commit b6b59769b9fb2a28172479bc242155b88dc823e2
Showing 2,373 changed files with 33,434 additions and 33,431 deletions.
@@ -5,26 +5,26 @@ if (!file_exists(__DIR__.'/src')) {
}
return PhpCsFixer\Config::create()
->setRules(array(
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit48Migration:risky' => true,
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
'array_syntax' => array('syntax' => 'short'),
'array_syntax' => ['syntax' => 'short'],
'fopen_flags' => false,
'ordered_imports' => true,
'protected_to_private' => false,
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
'phpdoc_types_order' => array('null_adjustment' => 'always_last', 'sort_algorithm' => 'none'),
))
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
])
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->append(array(__FILE__))
->exclude(array(
->append([__FILE__])
->exclude([
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
'Symfony/Component/DependencyInjection/Tests/Fixtures',
'Symfony/Component/Routing/Tests/Fixtures/dumper',
@@ -38,7 +38,7 @@ return PhpCsFixer\Config::create()
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
// explicit trigger_error tests
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
))
])
// Support for older PHPunit version
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
// file content autogenerated by `var_export`
@@ -27,8 +27,8 @@ class ContainerAwareEventManager extends EventManager
*
* <event> => <listeners>
*/
private $listeners = array();
private $initialized = array();
private $listeners = [];
private $initialized = [];
private $container;
public function __construct(ContainerInterface $container)
@@ -33,7 +33,7 @@ class DoctrineDataCollector extends DataCollector
/**
* @var DebugStack[]
*/
private $loggers = array();
private $loggers = [];
public function __construct(ManagerRegistry $registry)
{
@@ -58,24 +58,24 @@ public function addLogger($name, DebugStack $logger)
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$queries = array();
$queries = [];
foreach ($this->loggers as $name => $logger) {
$queries[$name] = $this->sanitizeQueries($name, $logger->queries);
}
$this->data = array(
$this->data = [
'queries' => $queries,
'connections' => $this->connections,
'managers' => $this->managers,
);
];
}
public function reset()
{
$this->data = array();
$this->data = [];
foreach ($this->loggers as $logger) {
$logger->queries = array();
$logger->queries = [];
$logger->currentQuery = 0;
}
}
@@ -133,10 +133,10 @@ private function sanitizeQuery($connectionName, $query)
{
$query['explainable'] = true;
if (null === $query['params']) {
$query['params'] = array();
$query['params'] = [];
}
if (!\is_array($query['params'])) {
$query['params'] = array($query['params']);
$query['params'] = [$query['params']];
}
foreach ($query['params'] as $j => $param) {
if (isset($query['types'][$j])) {
@@ -184,26 +184,26 @@ private function sanitizeParam($var)
$className = \get_class($var);
return method_exists($var, '__toString') ?
array(sprintf('Object(%s): "%s"', $className, $var->__toString()), false) :
array(sprintf('Object(%s)', $className), false);
[sprintf('Object(%s): "%s"', $className, $var->__toString()), false] :
[sprintf('Object(%s)', $className), false];
}
if (\is_array($var)) {
$a = array();
$a = [];
$original = true;
foreach ($var as $k => $v) {
list($value, $orig) = $this->sanitizeParam($v);
$original = $original && $orig;
$a[$k] = $value;
}
return array($a, $original);
return [$a, $original];
}
if (\is_resource($var)) {
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
return [sprintf('Resource(%s)', get_resource_type($var)), false];
}
return array($var, true);
return [$var, true];
}
}
@@ -27,12 +27,12 @@ abstract class AbstractDoctrineExtension extends Extension
/**
* Used inside metadata driver method to simplify aggregation of data.
*/
protected $aliasMap = array();
protected $aliasMap = [];
/**
* Used inside metadata driver method to simplify aggregation of data.
*/
protected $drivers = array();
protected $drivers = [];
/**
* @param array $objectManager A configured object manager
@@ -46,10 +46,10 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
// automatically register bundle mappings
foreach (array_keys($container->getParameter('kernel.bundles')) as $bundle) {
if (!isset($objectManager['mappings'][$bundle])) {
$objectManager['mappings'][$bundle] = array(
$objectManager['mappings'][$bundle] = [
'mapping' => true,
'is_bundle' => true,
);
];
}
}
}
@@ -59,11 +59,11 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
continue;
}
$mappingConfig = array_replace(array(
$mappingConfig = array_replace([
'dir' => false,
'type' => false,
'prefix' => false,
), (array) $mappingConfig);
], (array) $mappingConfig);
$mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
// a bundle configuration is detected by realizing that the specified dir is not absolute and existing
@@ -153,7 +153,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
}
if (!$bundleConfig['dir']) {
if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp'])) {
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
} else {
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
@@ -197,25 +197,25 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont
}
$mappingDriverDef->setArguments($args);
} elseif ('annotation' == $driverType) {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
array_values($driverPaths),
));
]);
} else {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
array_values($driverPaths),
));
]);
}
$mappingDriverDef->setPublic(false);
if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) {
$mappingDriverDef->setArguments(array(array_flip($driverPaths)));
$mappingDriverDef->addMethodCall('setGlobalBasename', array('mapping'));
$mappingDriverDef->setArguments([array_flip($driverPaths)]);
$mappingDriverDef->addMethodCall('setGlobalBasename', ['mapping']);
}
$container->setDefinition($mappingService, $mappingDriverDef);
foreach ($driverPaths as $prefix => $driverPath) {
$chainDriverDef->addMethodCall('addDriver', array(new Reference($mappingService), $prefix));
$chainDriverDef->addMethodCall('addDriver', [new Reference($mappingService), $prefix]);
}
}
@@ -240,7 +240,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
}
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp'])) {
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
'You can register them by adding a new driver to the '.
@@ -326,11 +326,11 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$cacheDef = new Definition($memcacheClass);
$memcacheInstance = new Definition($memcacheInstanceClass);
$memcacheInstance->setPrivate(true);
$memcacheInstance->addMethodCall('connect', array(
$memcacheInstance->addMethodCall('connect', [
$memcacheHost, $memcachePort,
));
]);
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)), $memcacheInstance);
$cacheDef->addMethodCall('setMemcache', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)))));
$cacheDef->addMethodCall('setMemcache', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)))]);
break;
case 'memcached':
$memcachedClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcached.class').'%';
@@ -340,11 +340,11 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$cacheDef = new Definition($memcachedClass);
$memcachedInstance = new Definition($memcachedInstanceClass);
$memcachedInstance->setPrivate(true);
$memcachedInstance->addMethodCall('addServer', array(
$memcachedInstance->addMethodCall('addServer', [
$memcachedHost, $memcachedPort,
));
]);
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance);
$cacheDef->addMethodCall('setMemcached', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))));
$cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))]);
break;
case 'redis':
$redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%';
@@ -354,11 +354,11 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$cacheDef = new Definition($redisClass);
$redisInstance = new Definition($redisInstanceClass);
$redisInstance->setPrivate(true);
$redisInstance->addMethodCall('connect', array(
$redisInstance->addMethodCall('connect', [
$redisHost, $redisPort,
));
]);
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)), $redisInstance);
$cacheDef->addMethodCall('setRedis', array(new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))));
$cacheDef->addMethodCall('setRedis', [new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))]);
break;
case 'apc':
case 'apcu':
@@ -387,7 +387,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
$cacheDriver['namespace'] = $namespace;
}
$cacheDef->addMethodCall('setNamespace', array($cacheDriver['namespace']));
$cacheDef->addMethodCall('setNamespace', [$cacheDriver['namespace']]);
$container->setDefinition($cacheDriverServiceId, $cacheDef);
@@ -410,10 +410,10 @@ protected function fixManagersAutoMappings(array $managerConfigs, array $bundles
continue 2;
}
}
$managerConfigs[$autoMappedManager]['mappings'][$bundle] = array(
$managerConfigs[$autoMappedManager]['mappings'][$bundle] = [
'mapping' => true,
'is_bundle' => true,
);
];
}
$managerConfigs[$autoMappedManager]['auto_mapping'] = false;
}
@@ -65,13 +65,13 @@ private function addTaggedSubscribers(ContainerBuilder $container)
foreach ($taggedSubscribers as $taggedSubscriber) {
list($id, $tag) = $taggedSubscriber;
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
foreach ($connections as $con) {
if (!isset($this->connections[$con])) {
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
}
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', [new Reference($id)]);
}
}
}
@@ -88,7 +88,7 @@ private function addTaggedListeners(ContainerBuilder $container)
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
}
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
foreach ($connections as $con) {
if (!isset($this->connections[$con])) {
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
@@ -99,7 +99,7 @@ private function addTaggedListeners(ContainerBuilder $container)
}
// we add one call per event per service so we have the correct order
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $lazy ? $id : new Reference($id)));
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', [[$tag['event']], $lazy ? $id : new Reference($id)]);
}
}
}
@@ -130,12 +130,12 @@ private function getEventManagerDef(ContainerBuilder $container, $name)
*/
private function findAndSortTags($tagName, ContainerBuilder $container)
{
$sortedTags = array();
$sortedTags = [];
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
$sortedTags[$priority][] = array($serviceId, $attributes);
$sortedTags[$priority][] = [$serviceId, $attributes];
}
}
@@ -50,7 +50,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
/**
* List of potential container parameters that hold the object manager name
* to register the mappings with the correct metadata driver, for example
* array('acme.manager', 'doctrine.default_entity_manager').
* ['acme.manager', 'doctrine.default_entity_manager'].
*
* @var string[]
*/
@@ -117,7 +117,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
* register alias
* @param string[] $aliasMap Map of alias to namespace
*/
public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = array())
public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = [])
{
$this->driver = $driver;
$this->namespaces = $namespaces;
@@ -146,7 +146,7 @@ public function process(ContainerBuilder $container)
// Definition for a Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
$chainDriverDef = $container->getDefinition($chainDriverDefService);
foreach ($this->namespaces as $namespace) {
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
$chainDriverDef->addMethodCall('addDriver', [$mappingDriverDef, $namespace]);
}
if (!\count($this->aliasMap)) {
@@ -157,7 +157,7 @@ public function process(ContainerBuilder $container)
// Definition of the Doctrine\...\Configuration class specific to the Doctrine flavour.
$configurationServiceDefinition = $container->getDefinition($configurationServiceName);
foreach ($this->aliasMap as $alias => $namespace) {
$configurationServiceDefinition->addMethodCall($this->registerAliasMethodName, array($alias, $namespace));
$configurationServiceDefinition->addMethodCall($this->registerAliasMethodName, [$alias, $namespace]);
}
}
Oops, something went wrong.

1 comment on commit b6b5976

@martinlabuschin

This comment has been minimized.

Copy link

martinlabuschin commented on b6b5976 Jan 24, 2019

lgtm

Please sign in to comment.