Skip to content

Commit a799482

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 83cb5aa + 3ce6266 commit a799482

32 files changed

+633
-633
lines changed

ContainerAwareEventManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ContainerAwareEventManager extends EventManager
2727
*
2828
* <event> => <listeners>
2929
*/
30-
private $listeners = array();
31-
private $initialized = array();
30+
private $listeners = [];
31+
private $initialized = [];
3232
private $container;
3333

3434
public function __construct(ContainerInterface $container)

DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ private function addTaggedSubscribers(ContainerBuilder $container)
6565

6666
foreach ($taggedSubscribers as $taggedSubscriber) {
6767
list($id, $tag) = $taggedSubscriber;
68-
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
68+
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
6969
foreach ($connections as $con) {
7070
if (!isset($this->connections[$con])) {
7171
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))));
7272
}
7373

74-
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));
74+
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', [new Reference($id)]);
7575
}
7676
}
7777
}
@@ -88,7 +88,7 @@ private function addTaggedListeners(ContainerBuilder $container)
8888
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
8989
}
9090

91-
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
91+
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
9292
foreach ($connections as $con) {
9393
if (!isset($this->connections[$con])) {
9494
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)
9999
}
100100

101101
// we add one call per event per service so we have the correct order
102-
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $lazy ? $id : new Reference($id)));
102+
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', [[$tag['event']], $lazy ? $id : new Reference($id)]);
103103
}
104104
}
105105
}
@@ -130,12 +130,12 @@ private function getEventManagerDef(ContainerBuilder $container, $name)
130130
*/
131131
private function findAndSortTags($tagName, ContainerBuilder $container)
132132
{
133-
$sortedTags = array();
133+
$sortedTags = [];
134134

135135
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
136136
foreach ($tags as $attributes) {
137137
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
138-
$sortedTags[$priority][] = array($serviceId, $attributes);
138+
$sortedTags[$priority][] = [$serviceId, $attributes];
139139
}
140140
}
141141

Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function loadValuesForChoices(array $choices, $value = null)
7878
{
7979
// Performance optimization
8080
if (empty($choices)) {
81-
return array();
81+
return [];
8282
}
8383

8484
// Optimize performance for single-field identifiers. We already
@@ -87,7 +87,7 @@ public function loadValuesForChoices(array $choices, $value = null)
8787

8888
// Attention: This optimization does not check choices for existence
8989
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
90-
$values = array();
90+
$values = [];
9191

9292
// Maintain order and indices of the given objects
9393
foreach ($choices as $i => $object) {
@@ -115,7 +115,7 @@ public function loadChoicesForValues(array $values, $value = null)
115115
// statements, consequently no test fails when this code is removed.
116116
// https://github.com/symfony/symfony/pull/8981#issuecomment-24230557
117117
if (empty($values)) {
118-
return array();
118+
return [];
119119
}
120120

121121
// Optimize performance in case we have an object loader and
@@ -124,8 +124,8 @@ public function loadChoicesForValues(array $values, $value = null)
124124

125125
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
126126
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
127-
$objectsById = array();
128-
$objects = array();
127+
$objectsById = [];
128+
$objects = [];
129129

130130
// Maintain order and indices from the given $values
131131
// An alternative approach to the following loop is to add the

Form/ChoiceList/IdReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
4343
$this->om = $om;
4444
$this->classMetadata = $classMetadata;
4545
$this->singleId = 1 === \count($ids);
46-
$this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint'));
46+
$this->intId = $this->singleId && \in_array($idType, ['integer', 'smallint', 'bigint']);
4747
$this->idField = current($ids);
4848

4949
// single field association are resolved, since the schema column could be an int

Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ public function getEntitiesByIds($identifier, array $values)
6464
// Guess type
6565
$entity = current($qb->getRootEntities());
6666
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
67-
if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
67+
if (\in_array($metadata->getTypeOfField($identifier), ['integer', 'bigint', 'smallint'])) {
6868
$parameterType = Connection::PARAM_INT_ARRAY;
6969

7070
// Filter out non-integer values (e.g. ""). If we don't, some
7171
// databases such as PostgreSQL fail.
7272
$values = array_values(array_filter($values, function ($v) {
7373
return (string) $v === (string) (int) $v || ctype_digit($v);
7474
}));
75-
} elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
75+
} elseif (\in_array($metadata->getTypeOfField($identifier), ['uuid', 'guid'])) {
7676
$parameterType = Connection::PARAM_STR_ARRAY;
7777

7878
// Like above, but we just filter out empty strings.
@@ -83,7 +83,7 @@ public function getEntitiesByIds($identifier, array $values)
8383
$parameterType = Connection::PARAM_STR_ARRAY;
8484
}
8585
if (!$values) {
86-
return array();
86+
return [];
8787
}
8888

8989
return $qb->andWhere($where)

Form/DataTransformer/CollectionToArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface
3131
public function transform($collection)
3232
{
3333
if (null === $collection) {
34-
return array();
34+
return [];
3535
}
3636

3737
// For cases when the collection getter returns $collection->toArray()
@@ -57,7 +57,7 @@ public function transform($collection)
5757
public function reverseTransform($array)
5858
{
5959
if ('' === $array || null === $array) {
60-
$array = array();
60+
$array = [];
6161
} else {
6262
$array = (array) $array;
6363
}

Form/DoctrineOrmExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public function __construct(ManagerRegistry $registry)
2626

2727
protected function loadTypes()
2828
{
29-
return array(
29+
return [
3030
new EntityType($this->registry),
31-
);
31+
];
3232
}
3333

3434
protected function loadTypeGuesser()

Form/Type/DoctrineType.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ abstract class DoctrineType extends AbstractType
3535
/**
3636
* @var IdReader[]
3737
*/
38-
private $idReaders = array();
38+
private $idReaders = [];
3939

4040
/**
4141
* @var DoctrineChoiceLoader[]
4242
*/
43-
private $choiceLoaders = array();
43+
private $choiceLoaders = [];
4444

4545
/**
4646
* Creates the label for a choice.
@@ -126,11 +126,11 @@ public function configureOptions(OptionsResolver $resolver)
126126
// also if concrete Type can return important QueryBuilder parts to generate
127127
// hash key we go for it as well
128128
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
129-
$hash = CachingFactoryDecorator::generateHash(array(
129+
$hash = CachingFactoryDecorator::generateHash([
130130
$options['em'],
131131
$options['class'],
132132
$qbParts,
133-
));
133+
]);
134134

135135
if (isset($this->choiceLoaders[$hash])) {
136136
return $this->choiceLoaders[$hash];
@@ -167,7 +167,7 @@ public function configureOptions(OptionsResolver $resolver)
167167
// field name. We can only use numeric IDs as names, as we cannot
168168
// guarantee that a non-numeric ID contains a valid form name
169169
if ($idReader->isIntId()) {
170-
return array(__CLASS__, 'createChoiceName');
170+
return [__CLASS__, 'createChoiceName'];
171171
}
172172

173173
// Otherwise, an incrementing integer is used as name automatically
@@ -183,7 +183,7 @@ public function configureOptions(OptionsResolver $resolver)
183183

184184
// If the entity has a single-column ID, use that ID as value
185185
if ($idReader->isSingleId()) {
186-
return array($idReader, 'getIdValue');
186+
return [$idReader, 'getIdValue'];
187187
}
188188

189189
// Otherwise, an incrementing integer is used as value automatically
@@ -221,10 +221,10 @@ public function configureOptions(OptionsResolver $resolver)
221221
// Set the "id_reader" option via the normalizer. This option is not
222222
// supposed to be set by the user.
223223
$idReaderNormalizer = function (Options $options) {
224-
$hash = CachingFactoryDecorator::generateHash(array(
224+
$hash = CachingFactoryDecorator::generateHash([
225225
$options['em'],
226226
$options['class'],
227-
));
227+
]);
228228

229229
// The ID reader is a utility that is needed to read the object IDs
230230
// when generating the field values. The callback generating the
@@ -240,25 +240,25 @@ public function configureOptions(OptionsResolver $resolver)
240240
return $this->idReaders[$hash];
241241
};
242242

243-
$resolver->setDefaults(array(
243+
$resolver->setDefaults([
244244
'em' => null,
245245
'query_builder' => null,
246246
'choices' => null,
247247
'choice_loader' => $choiceLoader,
248-
'choice_label' => array(__CLASS__, 'createChoiceLabel'),
248+
'choice_label' => [__CLASS__, 'createChoiceLabel'],
249249
'choice_name' => $choiceName,
250250
'choice_value' => $choiceValue,
251251
'id_reader' => null, // internal
252252
'choice_translation_domain' => false,
253-
));
253+
]);
254254

255-
$resolver->setRequired(array('class'));
255+
$resolver->setRequired(['class']);
256256

257257
$resolver->setNormalizer('em', $emNormalizer);
258258
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
259259
$resolver->setNormalizer('id_reader', $idReaderNormalizer);
260260

261-
$resolver->setAllowedTypes('em', array('null', 'string', 'Doctrine\Common\Persistence\ObjectManager'));
261+
$resolver->setAllowedTypes('em', ['null', 'string', 'Doctrine\Common\Persistence\ObjectManager']);
262262
}
263263

264264
/**
@@ -279,6 +279,6 @@ public function getParent()
279279

280280
public function reset()
281281
{
282-
$this->choiceLoaders = array();
282+
$this->choiceLoaders = [];
283283
}
284284
}

Form/Type/EntityType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function configureOptions(OptionsResolver $resolver)
4040
};
4141

4242
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
43-
$resolver->setAllowedTypes('query_builder', array('null', 'callable', 'Doctrine\ORM\QueryBuilder'));
43+
$resolver->setAllowedTypes('query_builder', ['null', 'callable', 'Doctrine\ORM\QueryBuilder']);
4444
}
4545

4646
/**
@@ -78,10 +78,10 @@ public function getBlockPrefix()
7878
*/
7979
public function getQueryBuilderPartsForCachingHash($queryBuilder)
8080
{
81-
return array(
81+
return [
8282
$queryBuilder->getQuery()->getSQL(),
83-
array_map(array($this, 'parameterToArray'), $queryBuilder->getParameters()->toArray()),
84-
);
83+
array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()),
84+
];
8585
}
8686

8787
/**
@@ -91,6 +91,6 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder)
9191
*/
9292
private function parameterToArray(Parameter $parameter)
9393
{
94-
return array($parameter->getName(), $parameter->getType(), $parameter->getValue());
94+
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
9595
}
9696
}

Logger/DbalLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function startQuery($sql, array $params = null, array $types = null)
4242
}
4343

4444
if (null !== $this->logger) {
45-
$this->log($sql, null === $params ? array() : $this->normalizeParams($params));
45+
$this->log($sql, null === $params ? [] : $this->normalizeParams($params));
4646
}
4747
}
4848

PropertyInfo/DoctrineExtractor.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(ClassMetadataFactory $classMetadataFactory)
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function getProperties($class, array $context = array())
40+
public function getProperties($class, array $context = [])
4141
{
4242
try {
4343
$metadata = $this->classMetadataFactory->getMetadataFor($class);
@@ -63,7 +63,7 @@ public function getProperties($class, array $context = array())
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function getTypes($class, $property, array $context = array())
66+
public function getTypes($class, $property, array $context = [])
6767
{
6868
try {
6969
$metadata = $this->classMetadataFactory->getMetadataFor($class);
@@ -85,7 +85,7 @@ public function getTypes($class, $property, array $context = array())
8585
$nullable = false;
8686
}
8787

88-
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class));
88+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)];
8989
}
9090

9191
$collectionKeyType = Type::BUILTIN_TYPE_INT;
@@ -112,18 +112,18 @@ public function getTypes($class, $property, array $context = array())
112112
}
113113
}
114114

115-
return array(new Type(
115+
return [new Type(
116116
Type::BUILTIN_TYPE_OBJECT,
117117
false,
118118
'Doctrine\Common\Collections\Collection',
119119
true,
120120
new Type($collectionKeyType),
121121
new Type(Type::BUILTIN_TYPE_OBJECT, false, $class)
122-
));
122+
)];
123123
}
124124

125125
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) {
126-
return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class']));
126+
return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])];
127127
}
128128

129129
if ($metadata->hasField($property)) {
@@ -136,30 +136,30 @@ public function getTypes($class, $property, array $context = array())
136136
case DBALType::DATETIMETZ:
137137
case 'vardatetime':
138138
case DBALType::TIME:
139-
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
139+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')];
140140

141141
case 'date_immutable':
142142
case 'datetime_immutable':
143143
case 'datetimetz_immutable':
144144
case 'time_immutable':
145-
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable'));
145+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')];
146146

147147
case 'dateinterval':
148-
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval'));
148+
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')];
149149

150150
case DBALType::TARRAY:
151-
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
151+
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
152152

153153
case DBALType::SIMPLE_ARRAY:
154-
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)));
154+
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))];
155155

156156
case DBALType::JSON_ARRAY:
157-
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
157+
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
158158

159159
default:
160160
$builtinType = $this->getPhpType($typeOfField);
161161

162-
return $builtinType ? array(new Type($builtinType, $nullable)) : null;
162+
return $builtinType ? [new Type($builtinType, $nullable)] : null;
163163
}
164164
}
165165
}

0 commit comments

Comments
 (0)