diff --git a/.php_cs.dist b/.php_cs.dist index 61ade31715..d8e4788c66 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -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` diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index 20aaae85a1..66b99ecf62 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -27,8 +27,8 @@ class ContainerAwareEventManager extends EventManager * * => */ - private $listeners = array(); - private $initialized = array(); + private $listeners = []; + private $initialized = []; private $container; public function __construct(ContainerInterface $container) diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php index 92a7b673e2..104fd30e72 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php @@ -65,13 +65,13 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface 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 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface 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 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface } // 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 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface */ 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]; } } diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index 4b7b1ebe34..0ed66f8c44 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -78,7 +78,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface { // Performance optimization if (empty($choices)) { - return array(); + return []; } // Optimize performance for single-field identifiers. We already @@ -87,7 +87,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface // Attention: This optimization does not check choices for existence if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) { - $values = array(); + $values = []; // Maintain order and indices of the given objects foreach ($choices as $i => $object) { @@ -115,7 +115,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface // statements, consequently no test fails when this code is removed. // https://github.com/symfony/symfony/pull/8981#issuecomment-24230557 if (empty($values)) { - return array(); + return []; } // Optimize performance in case we have an object loader and @@ -124,8 +124,8 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) { $unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values); - $objectsById = array(); - $objects = array(); + $objectsById = []; + $objects = []; // Maintain order and indices from the given $values // An alternative approach to the following loop is to add the diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php index 381d02fcbe..3509d9b03b 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php @@ -43,7 +43,7 @@ class IdReader $this->om = $om; $this->classMetadata = $classMetadata; $this->singleId = 1 === \count($ids); - $this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint')); + $this->intId = $this->singleId && \in_array($idType, ['integer', 'smallint', 'bigint']); $this->idField = current($ids); // single field association are resolved, since the schema column could be an int diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php index a2f1fa7ae8..96f5e2f5f1 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php @@ -64,7 +64,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface // Guess type $entity = current($qb->getRootEntities()); $metadata = $qb->getEntityManager()->getClassMetadata($entity); - if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) { + if (\in_array($metadata->getTypeOfField($identifier), ['integer', 'bigint', 'smallint'])) { $parameterType = Connection::PARAM_INT_ARRAY; // Filter out non-integer values (e.g. ""). If we don't, some @@ -72,7 +72,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface $values = array_values(array_filter($values, function ($v) { return (string) $v === (string) (int) $v || ctype_digit($v); })); - } elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) { + } elseif (\in_array($metadata->getTypeOfField($identifier), ['uuid', 'guid'])) { $parameterType = Connection::PARAM_STR_ARRAY; // Like above, but we just filter out empty strings. @@ -83,7 +83,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface $parameterType = Connection::PARAM_STR_ARRAY; } if (!$values) { - return array(); + return []; } return $qb->andWhere($where) diff --git a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php index 4010512ba9..3202dae97f 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php @@ -31,7 +31,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface public function transform($collection) { if (null === $collection) { - return array(); + return []; } // For cases when the collection getter returns $collection->toArray() @@ -57,7 +57,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface public function reverseTransform($array) { if ('' === $array || null === $array) { - $array = array(); + $array = []; } else { $array = (array) $array; } diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php index fe86b103cb..891754a1da 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php @@ -26,9 +26,9 @@ class DoctrineOrmExtension extends AbstractExtension protected function loadTypes() { - return array( + return [ new EntityType($this->registry), - ); + ]; } protected function loadTypeGuesser() diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 2ade084ea5..6be2e5828c 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -35,12 +35,12 @@ abstract class DoctrineType extends AbstractType /** * @var IdReader[] */ - private $idReaders = array(); + private $idReaders = []; /** * @var DoctrineChoiceLoader[] */ - private $choiceLoaders = array(); + private $choiceLoaders = []; /** * Creates the label for a choice. @@ -126,11 +126,11 @@ abstract class DoctrineType extends AbstractType // also if concrete Type can return important QueryBuilder parts to generate // hash key we go for it as well if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) { - $hash = CachingFactoryDecorator::generateHash(array( + $hash = CachingFactoryDecorator::generateHash([ $options['em'], $options['class'], $qbParts, - )); + ]); if (isset($this->choiceLoaders[$hash])) { return $this->choiceLoaders[$hash]; @@ -167,7 +167,7 @@ abstract class DoctrineType extends AbstractType // field name. We can only use numeric IDs as names, as we cannot // guarantee that a non-numeric ID contains a valid form name if ($idReader->isIntId()) { - return array(__CLASS__, 'createChoiceName'); + return [__CLASS__, 'createChoiceName']; } // Otherwise, an incrementing integer is used as name automatically @@ -183,7 +183,7 @@ abstract class DoctrineType extends AbstractType // If the entity has a single-column ID, use that ID as value if ($idReader->isSingleId()) { - return array($idReader, 'getIdValue'); + return [$idReader, 'getIdValue']; } // Otherwise, an incrementing integer is used as value automatically @@ -221,10 +221,10 @@ abstract class DoctrineType extends AbstractType // Set the "id_reader" option via the normalizer. This option is not // supposed to be set by the user. $idReaderNormalizer = function (Options $options) { - $hash = CachingFactoryDecorator::generateHash(array( + $hash = CachingFactoryDecorator::generateHash([ $options['em'], $options['class'], - )); + ]); // The ID reader is a utility that is needed to read the object IDs // when generating the field values. The callback generating the @@ -240,25 +240,25 @@ abstract class DoctrineType extends AbstractType return $this->idReaders[$hash]; }; - $resolver->setDefaults(array( + $resolver->setDefaults([ 'em' => null, 'query_builder' => null, 'choices' => null, 'choice_loader' => $choiceLoader, - 'choice_label' => array(__CLASS__, 'createChoiceLabel'), + 'choice_label' => [__CLASS__, 'createChoiceLabel'], 'choice_name' => $choiceName, 'choice_value' => $choiceValue, 'id_reader' => null, // internal 'choice_translation_domain' => false, - )); + ]); - $resolver->setRequired(array('class')); + $resolver->setRequired(['class']); $resolver->setNormalizer('em', $emNormalizer); $resolver->setNormalizer('query_builder', $queryBuilderNormalizer); $resolver->setNormalizer('id_reader', $idReaderNormalizer); - $resolver->setAllowedTypes('em', array('null', 'string', 'Doctrine\Common\Persistence\ObjectManager')); + $resolver->setAllowedTypes('em', ['null', 'string', 'Doctrine\Common\Persistence\ObjectManager']); } /** @@ -279,6 +279,6 @@ abstract class DoctrineType extends AbstractType public function reset() { - $this->choiceLoaders = array(); + $this->choiceLoaders = []; } } diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index 2adb82fad3..b6c598350c 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -40,7 +40,7 @@ class EntityType extends DoctrineType }; $resolver->setNormalizer('query_builder', $queryBuilderNormalizer); - $resolver->setAllowedTypes('query_builder', array('null', 'callable', 'Doctrine\ORM\QueryBuilder')); + $resolver->setAllowedTypes('query_builder', ['null', 'callable', 'Doctrine\ORM\QueryBuilder']); } /** @@ -78,10 +78,10 @@ class EntityType extends DoctrineType */ public function getQueryBuilderPartsForCachingHash($queryBuilder) { - return array( + return [ $queryBuilder->getQuery()->getSQL(), - array_map(array($this, 'parameterToArray'), $queryBuilder->getParameters()->toArray()), - ); + array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()), + ]; } /** @@ -91,6 +91,6 @@ class EntityType extends DoctrineType */ private function parameterToArray(Parameter $parameter) { - return array($parameter->getName(), $parameter->getType(), $parameter->getValue()); + return [$parameter->getName(), $parameter->getType(), $parameter->getValue()]; } } diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 0200c2657a..63880a6d61 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -42,7 +42,7 @@ class DbalLogger implements SQLLogger } if (null !== $this->logger) { - $this->log($sql, null === $params ? array() : $this->normalizeParams($params)); + $this->log($sql, null === $params ? [] : $this->normalizeParams($params)); } } diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 2a41422e00..41d004d4e2 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -37,7 +37,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE /** * {@inheritdoc} */ - public function getProperties($class, array $context = array()) + public function getProperties($class, array $context = []) { try { $metadata = $this->classMetadataFactory->getMetadataFor($class); @@ -63,7 +63,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = array()) + public function getTypes($class, $property, array $context = []) { try { $metadata = $this->classMetadataFactory->getMetadataFor($class); @@ -85,7 +85,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE $nullable = false; } - return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)); + return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)]; } $collectionKeyType = Type::BUILTIN_TYPE_INT; @@ -112,18 +112,18 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE } } - return array(new Type( + return [new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type($collectionKeyType), new Type(Type::BUILTIN_TYPE_OBJECT, false, $class) - )); + )]; } if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) { - return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])); + return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])]; } if ($metadata->hasField($property)) { @@ -136,30 +136,30 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE case DBALType::DATETIMETZ: case 'vardatetime': case DBALType::TIME: - return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')); + return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')]; case 'date_immutable': case 'datetime_immutable': case 'datetimetz_immutable': case 'time_immutable': - return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')); + return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')]; case 'dateinterval': - return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')); + return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')]; case DBALType::TARRAY: - return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)); + return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)]; case DBALType::SIMPLE_ARRAY: - return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))); + return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))]; case DBALType::JSON_ARRAY: - return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)); + return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)]; default: $builtinType = $this->getPhpType($typeOfField); - return $builtinType ? array(new Type($builtinType, $nullable)) : null; + return $builtinType ? [new Type($builtinType, $nullable)] : null; } } } diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index 5e41b10e14..64515fac71 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -53,8 +53,8 @@ class DoctrineTokenProvider implements TokenProviderInterface // the alias for lastUsed works around case insensitivity in PostgreSQL $sql = 'SELECT class, username, value, lastUsed AS last_used' .' FROM rememberme_token WHERE series=:series'; - $paramValues = array('series' => $series); - $paramTypes = array('series' => \PDO::PARAM_STR); + $paramValues = ['series' => $series]; + $paramTypes = ['series' => \PDO::PARAM_STR]; $stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes); $row = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -71,8 +71,8 @@ class DoctrineTokenProvider implements TokenProviderInterface public function deleteTokenBySeries($series) { $sql = 'DELETE FROM rememberme_token WHERE series=:series'; - $paramValues = array('series' => $series); - $paramTypes = array('series' => \PDO::PARAM_STR); + $paramValues = ['series' => $series]; + $paramTypes = ['series' => \PDO::PARAM_STR]; $this->conn->executeUpdate($sql, $paramValues, $paramTypes); } @@ -83,16 +83,16 @@ class DoctrineTokenProvider implements TokenProviderInterface { $sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed' .' WHERE series=:series'; - $paramValues = array( + $paramValues = [ 'value' => $tokenValue, 'lastUsed' => $lastUsed, 'series' => $series, - ); - $paramTypes = array( + ]; + $paramTypes = [ 'value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, 'series' => \PDO::PARAM_STR, - ); + ]; $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); if ($updated < 1) { throw new TokenNotFoundException('No token found.'); @@ -107,20 +107,20 @@ class DoctrineTokenProvider implements TokenProviderInterface $sql = 'INSERT INTO rememberme_token' .' (class, username, series, value, lastUsed)' .' VALUES (:class, :username, :series, :value, :lastUsed)'; - $paramValues = array( + $paramValues = [ 'class' => $token->getClass(), 'username' => $token->getUsername(), 'series' => $token->getSeries(), 'value' => $token->getTokenValue(), 'lastUsed' => $token->getLastUsed(), - ); - $paramTypes = array( + ]; + $paramTypes = [ 'class' => \PDO::PARAM_STR, 'username' => \PDO::PARAM_STR, 'series' => \PDO::PARAM_STR, 'value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, - ); + ]; $this->conn->executeUpdate($sql, $paramValues, $paramTypes); } } diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 726548e174..769e9bb20e 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -48,7 +48,7 @@ class EntityUserProvider implements UserProviderInterface { $repository = $this->getRepository(); if (null !== $this->property) { - $user = $repository->findOneBy(array($this->property => $username)); + $user = $repository->findOneBy([$this->property => $username]); } else { if (!$repository instanceof UserLoaderInterface) { throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository))); diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index 06dc628475..3f6ffeebb6 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -42,10 +42,10 @@ class DoctrineTestHelper $config = self::createTestConfiguration(); } - $params = array( + $params = [ 'driver' => 'pdo_sqlite', 'memory' => true, - ); + ]; return EntityManager::create($params, $config); } @@ -56,7 +56,7 @@ class DoctrineTestHelper public static function createTestConfiguration() { $config = new Configuration(); - $config->setEntityNamespaces(array('SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures')); + $config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']); $config->setAutoGenerateProxyClasses(true); $config->setProxyDir(\sys_get_temp_dir()); $config->setProxyNamespace('SymfonyTests\Doctrine'); diff --git a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php index b7cbafa947..e7df3702eb 100644 --- a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php +++ b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php @@ -24,7 +24,7 @@ final class TestRepositoryFactory implements RepositoryFactory /** * @var ObjectRepository[] */ - private $repositoryList = array(); + private $repositoryList = []; /** * {@inheritdoc} diff --git a/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php b/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php index f40d1ca710..2e97edb1d2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php @@ -43,15 +43,15 @@ class ContainerAwareEventManagerTest extends TestCase $this->evm->addEventListener('foo', 'bar'); $this->evm->addEventListener('foo', $listener = new MyListener()); - $listeners = array('foo' => array('_service_bar' => 'bar', spl_object_hash($listener) => $listener)); + $listeners = ['foo' => ['_service_bar' => 'bar', spl_object_hash($listener) => $listener]]; $this->assertSame($listeners, $this->evm->getListeners()); $this->assertSame($listeners['foo'], $this->evm->getListeners('foo')); $this->evm->removeEventListener('foo', $listener); - $this->assertSame(array('_service_bar' => 'bar'), $this->evm->getListeners('foo')); + $this->assertSame(['_service_bar' => 'bar'], $this->evm->getListeners('foo')); $this->evm->removeEventListener('foo', 'bar'); - $this->assertSame(array(), $this->evm->getListeners('foo')); + $this->assertSame([], $this->evm->getListeners('foo')); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php index 7e99a7d935..8ae9a912b4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php @@ -44,7 +44,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase $abstractDefinition = new Definition('stdClass'); $abstractDefinition->setAbstract(true); - $abstractDefinition->addTag('doctrine.event_listener', array('event' => 'test')); + $abstractDefinition->addTag('doctrine.event_listener', ['event' => 'test']); $container->setDefinition('a', $abstractDefinition); @@ -58,44 +58,44 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase $container ->register('a', 'stdClass') ->setPublic(false) - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'bar', - )) - ->addTag('doctrine.event_listener', array( + ]) + ->addTag('doctrine.event_listener', [ 'event' => 'foo', 'priority' => -5, - )) - ->addTag('doctrine.event_listener', array( + ]) + ->addTag('doctrine.event_listener', [ 'event' => 'foo_bar', 'priority' => 3, 'lazy' => true, - )) + ]) ; $container ->register('b', 'stdClass') - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'foo', - )) + ]) ; $container ->register('c', 'stdClass') - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'foo_bar', 'priority' => 4, - )) + ]) ; $this->process($container); $methodCalls = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls(); $this->assertEquals( - array( - array('addEventListener', array(array('foo_bar'), new Reference('c'))), - array('addEventListener', array(array('foo_bar'), new Reference('a'))), - array('addEventListener', array(array('bar'), new Reference('a'))), - array('addEventListener', array(array('foo'), new Reference('b'))), - array('addEventListener', array(array('foo'), new Reference('a'))), - ), + [ + ['addEventListener', [['foo_bar'], new Reference('c')]], + ['addEventListener', [['foo_bar'], new Reference('a')]], + ['addEventListener', [['bar'], new Reference('a')]], + ['addEventListener', [['foo'], new Reference('b')]], + ['addEventListener', [['foo'], new Reference('a')]], + ], $methodCalls ); @@ -113,42 +113,42 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase $container ->register('a', 'stdClass') - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'onFlush', - )) + ]) ; $container ->register('b', 'stdClass') - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'onFlush', 'connection' => 'default', - )) + ]) ; $container ->register('c', 'stdClass') - ->addTag('doctrine.event_listener', array( + ->addTag('doctrine.event_listener', [ 'event' => 'onFlush', 'connection' => 'second', - )) + ]) ; $this->process($container); $this->assertEquals( - array( - array('addEventListener', array(array('onFlush'), new Reference('a'))), - array('addEventListener', array(array('onFlush'), new Reference('b'))), - ), + [ + ['addEventListener', [['onFlush'], new Reference('a')]], + ['addEventListener', [['onFlush'], new Reference('b')]], + ], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() ); $this->assertEquals( - array( - array('addEventListener', array(array('onFlush'), new Reference('a'))), - array('addEventListener', array(array('onFlush'), new Reference('c'))), - ), + [ + ['addEventListener', [['onFlush'], new Reference('a')]], + ['addEventListener', [['onFlush'], new Reference('c')]], + ], $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls() ); } @@ -159,42 +159,42 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase $container ->register('a', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'event' => 'onFlush', - )) + ]) ; $container ->register('b', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'event' => 'onFlush', 'connection' => 'default', - )) + ]) ; $container ->register('c', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'event' => 'onFlush', 'connection' => 'second', - )) + ]) ; $this->process($container); $this->assertEquals( - array( - array('addEventSubscriber', array(new Reference('a'))), - array('addEventSubscriber', array(new Reference('b'))), - ), + [ + ['addEventSubscriber', [new Reference('a')]], + ['addEventSubscriber', [new Reference('b')]], + ], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() ); $this->assertEquals( - array( - array('addEventSubscriber', array(new Reference('a'))), - array('addEventSubscriber', array(new Reference('c'))), - ), + [ + ['addEventSubscriber', [new Reference('a')]], + ['addEventSubscriber', [new Reference('c')]], + ], $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls() ); } @@ -209,39 +209,39 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase ; $container ->register('b', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'priority' => 5, - )) + ]) ; $container ->register('c', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'priority' => 10, - )) + ]) ; $container ->register('d', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'priority' => 10, - )) + ]) ; $container ->register('e', 'stdClass') - ->addTag('doctrine.event_subscriber', array( + ->addTag('doctrine.event_subscriber', [ 'priority' => 10, - )) + ]) ; $this->process($container); $this->assertEquals( - array( - array('addEventSubscriber', array(new Reference('c'))), - array('addEventSubscriber', array(new Reference('d'))), - array('addEventSubscriber', array(new Reference('e'))), - array('addEventSubscriber', array(new Reference('b'))), - array('addEventSubscriber', array(new Reference('a'))), - ), + [ + ['addEventSubscriber', [new Reference('c')]], + ['addEventSubscriber', [new Reference('d')]], + ['addEventSubscriber', [new Reference('e')]], + ['addEventSubscriber', [new Reference('b')]], + ['addEventSubscriber', [new Reference('a')]], + ], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() ); } @@ -252,9 +252,9 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase $this->process($container); - $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()); + $this->assertEquals([], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()); - $this->assertEquals(array(), $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()); + $this->assertEquals([], $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()); } private function process(ContainerBuilder $container) @@ -267,7 +267,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase { $container = new ContainerBuilder(); - $connections = array('default' => 'doctrine.dbal.default_connection'); + $connections = ['default' => 'doctrine.dbal.default_connection']; $container->register('doctrine.dbal.default_connection.event_manager', 'stdClass'); $container->register('doctrine.dbal.default_connection', 'stdClass'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php index 90dd145592..0bb2642a76 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php @@ -16,17 +16,17 @@ class RegisterMappingsPassTest extends TestCase public function testNoDriverParmeterException() { $container = $this->createBuilder(); - $this->process($container, array( + $this->process($container, [ 'manager.param.one', 'manager.param.two', - )); + ]); } private function process(ContainerBuilder $container, array $managerParamNames) { $pass = new ConcreteMappingsPass( new Definition('\stdClass'), - array(), + [], $managerParamNames, 'some.%s.metadata_driver' ); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php index d98b0ef93a..ff29145e33 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php @@ -25,7 +25,7 @@ class SingleIntIdEntity public $name; /** @Column(type="array", nullable=true) */ - public $phoneNumbers = array(); + public $phoneNumbers = []; public function __construct($id, $name) { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index 211cb12e4d..3abdb3578a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -34,17 +34,17 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') - ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) + ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query->expects($this->once()) ->method('setParameter') - ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2), $expectedType) + ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2], $expectedType) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') - ->setConstructorArgs(array($em)) - ->setMethods(array('getQuery')) + ->setConstructorArgs([$em]) + ->setMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -55,7 +55,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->from($classname, 'e'); $loader = new ORMQueryBuilderLoader($qb); - $loader->getEntitiesByIds('id', array(1, 2)); + $loader->getEntitiesByIds('id', [1, 2]); } public function testFilterNonIntegerValues() @@ -63,17 +63,17 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') - ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) + ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query->expects($this->once()) ->method('setParameter') - ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2, 3, '9223372036854775808'), Connection::PARAM_INT_ARRAY) + ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') - ->setConstructorArgs(array($em)) - ->setMethods(array('getQuery')) + ->setConstructorArgs([$em]) + ->setMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -84,7 +84,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->from('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', 'e'); $loader = new ORMQueryBuilderLoader($qb); - $loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo', '9223372036854775808')); + $loader->getEntitiesByIds('id', [1, '', 2, 3, 'foo', '9223372036854775808']); } /** @@ -95,17 +95,17 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') - ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) + ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query->expects($this->once()) ->method('setParameter') - ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'), Connection::PARAM_STR_ARRAY) + ->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') - ->setConstructorArgs(array($em)) - ->setMethods(array('getQuery')) + ->setConstructorArgs([$em]) + ->setMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) @@ -116,7 +116,7 @@ class ORMQueryBuilderLoaderTest extends TestCase ->from($entityClass, 'e'); $loader = new ORMQueryBuilderLoader($qb); - $loader->getEntitiesByIds('id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499')); + $loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']); } public function testEmbeddedIdentifierName() @@ -130,17 +130,17 @@ class ORMQueryBuilderLoaderTest extends TestCase $em = DoctrineTestHelper::createTestEntityManager(); $query = $this->getMockBuilder('QueryMock') - ->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute')) + ->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute']) ->getMock(); $query->expects($this->once()) ->method('setParameter') - ->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY) + ->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY) ->willReturn($query); $qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder') - ->setConstructorArgs(array($em)) - ->setMethods(array('getQuery')) + ->setConstructorArgs([$em]) + ->setMethods(['getQuery']) ->getMock(); $qb->expects($this->once()) ->method('getQuery') @@ -150,14 +150,14 @@ class ORMQueryBuilderLoaderTest extends TestCase ->from('Symfony\Bridge\Doctrine\Tests\Fixtures\EmbeddedIdentifierEntity', 'e'); $loader = new ORMQueryBuilderLoader($qb); - $loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo')); + $loader->getEntitiesByIds('id.value', [1, '', 2, 3, 'foo']); } public function provideGuidEntityClasses() { - return array( - array('Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'), - array('Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'), - ); + return [ + ['Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'], + ['Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'], + ]; } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index fa3ff911ad..e6e85f4d3f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -32,10 +32,10 @@ class CollectionToArrayTransformerTest extends TestCase public function testTransform() { - $array = array( + $array = [ 2 => 'foo', 3 => 'bar', - ); + ]; $this->assertSame($array, $this->transformer->transform(new ArrayCollection($array))); } @@ -49,17 +49,17 @@ class CollectionToArrayTransformerTest extends TestCase */ public function testTransformArray() { - $array = array( + $array = [ 2 => 'foo', 3 => 'bar', - ); + ]; $this->assertSame($array, $this->transformer->transform($array)); } public function testTransformNull() { - $this->assertSame(array(), $this->transformer->transform(null)); + $this->assertSame([], $this->transformer->transform(null)); } /** @@ -72,10 +72,10 @@ class CollectionToArrayTransformerTest extends TestCase public function testReverseTransform() { - $array = array( + $array = [ 2 => 'foo', 3 => 'bar', - ); + ]; $this->assertEquals(new ArrayCollection($array), $this->transformer->reverseTransform($array)); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 0eda4a3ba6..c323385ff1 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -29,54 +29,54 @@ class DoctrineOrmTypeGuesserTest extends TestCase public function requiredProvider() { - $return = array(); + $return = []; // Simple field, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); - $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); + $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // Simple field, nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); - $return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)); + $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; // One-to-one, nullable (by default) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); - $mapping = array('joinColumns' => array(array())); + $mapping = ['joinColumns' => [[]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); - $return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)); + $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, nullable (explicit) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); - $mapping = array('joinColumns' => array(array('nullable' => true))); + $mapping = ['joinColumns' => [['nullable' => true]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); - $return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)); + $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); - $mapping = array('joinColumns' => array(array('nullable' => false))); + $mapping = ['joinColumns' => [['nullable' => false]]]; $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); - $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); + $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // One-to-many, no clue $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); - $return[] = array($classMetadata, null); + $return[] = [$classMetadata, null]; return $return; } @@ -87,7 +87,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata)); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); - $registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em))); + $registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em])); return new DoctrineOrmTypeGuesser($registry); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index f4f7effa61..afdeb5f720 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -42,10 +42,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase ->method('getManagerForClass') ->will($this->returnValue($this->em)); - return array( + return [ new CoreExtension(), new DoctrineOrmExtension($manager), - ); + ]; } protected function setUp() @@ -55,9 +55,9 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase parent::setUp(); $schemaTool = new SchemaTool($this->em); - $classes = array( + $classes = [ $this->em->getClassMetadata(self::ENTITY_CLASS), - ); + ]; try { $schemaTool->dropSchema($classes); @@ -90,9 +90,9 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [ 'class' => self::ENTITY_CLASS, - )); + ]); // force loading of the choice list $form->createView(); @@ -108,10 +108,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [ 'class' => self::ENTITY_CLASS, 'choices' => $choices, - )); + ]); // force loading of the choice list $form->createView(); @@ -127,10 +127,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase $this->setMaxRunningTime(1); for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( + $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [ 'class' => self::ENTITY_CLASS, 'preferred_choices' => $choices, - )); + ]); // force loading of the choice list $form->createView(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index d60992fcf1..2869c2b804 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -65,7 +65,7 @@ class EntityTypeTest extends BaseTypeTest parent::setUp(); $schemaTool = new SchemaTool($this->em); - $classes = array( + $classes = [ $this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_NO_TO_STRING_CLASS), @@ -74,7 +74,7 @@ class EntityTypeTest extends BaseTypeTest $this->em->getClassMetadata(self::SINGLE_STRING_CASTABLE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS), - ); + ]; try { $schemaTool->dropSchema($classes); @@ -97,9 +97,9 @@ class EntityTypeTest extends BaseTypeTest protected function getExtensions() { - return array_merge(parent::getExtensions(), array( + return array_merge(parent::getExtensions(), [ new DoctrineOrmExtension($this->emRegistry), - )); + ]); } protected function persist(array $entities) @@ -126,9 +126,9 @@ class EntityTypeTest extends BaseTypeTest */ public function testInvalidClassOption() { - $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'class' => 'foo', - )); + ]); } public function testSetDataToUninitializedEntityWithNonRequired() @@ -136,16 +136,16 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', - )); + ]); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']); } public function testSetDataToUninitializedEntityWithNonRequiredToString() @@ -153,16 +153,16 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, - )) + ]) ->createView(); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $view->vars['choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')], $view->vars['choices']); } public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder() @@ -170,19 +170,19 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); $qb = $this->em->createQueryBuilder()->select('e')->from(self::SINGLE_IDENT_CLASS, 'e'); - $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', 'query_builder' => $qb, - )) + ]) ->createView(); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $view->vars['choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')], $view->vars['choices']); } /** @@ -190,11 +190,11 @@ class EntityTypeTest extends BaseTypeTest */ public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure() { - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => new \stdClass(), - )); + ]); } /** @@ -202,13 +202,13 @@ class EntityTypeTest extends BaseTypeTest */ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder() { - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function () { return new \stdClass(); }, - )); + ]); $field->submit('2'); } @@ -218,26 +218,26 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function () { return; }, - )); + ]); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']); } public function testSetDataSingleNull() { - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $field->setData(null); $this->assertNull($field->getData()); @@ -246,30 +246,30 @@ class EntityTypeTest extends BaseTypeTest public function testSetDataMultipleExpandedNull() { - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $field->setData(null); $this->assertNull($field->getData()); - $this->assertSame(array(), $field->getViewData()); + $this->assertSame([], $field->getViewData()); } public function testSetDataMultipleNonExpandedNull() { - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $field->setData(null); $this->assertNull($field->getData()); - $this->assertSame(array(), $field->getViewData()); + $this->assertSame([], $field->getViewData()); } public function testSubmitSingleNonExpandedSingleIdentifier() @@ -277,15 +277,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -302,15 +302,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); - $this->persist(array($innerEntity1, $innerEntity2, $entity1, $entity2)); + $this->persist([$innerEntity1, $innerEntity2, $entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -324,15 +324,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new CompositeIntIdEntity(10, 20, 'Foo'); $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); // the collection key is used here $field->submit('1'); @@ -348,23 +348,23 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); - $this->assertSame(array('1', '3'), $field->getViewData()); + $this->assertSame(['1', '3'], $field->getViewData()); } public function testSubmitMultipleNonExpandedSingleAssocIdentifier() @@ -377,23 +377,23 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $entity3 = new SingleAssociationToIntIdEntity($innerEntity3, 'Baz'); - $this->persist(array($innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3)); + $this->persist([$innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); - $this->assertSame(array('1', '3'), $field->getViewData()); + $this->assertSame(['1', '3'], $field->getViewData()); } public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData() @@ -402,29 +402,29 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $existing = new ArrayCollection(array(0 => $entity2)); + $existing = new ArrayCollection([0 => $entity2]); $field->setData($existing); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); // entry with index 0 ($entity2) was replaced - $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); + $expected = new ArrayCollection([0 => $entity1, 1 => $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); - $this->assertSame(array('1', '3'), $field->getViewData()); + $this->assertSame(['1', '3'], $field->getViewData()); } public function testSubmitMultipleNonExpandedCompositeIdentifier() @@ -433,24 +433,24 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); // because of the composite key collection keys are used - $field->submit(array('0', '2')); + $field->submit(['0', '2']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); - $this->assertSame(array('0', '2'), $field->getViewData()); + $this->assertSame(['0', '2'], $field->getViewData()); } public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData() @@ -459,29 +459,29 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $existing = new ArrayCollection(array(0 => $entity2)); + $existing = new ArrayCollection([0 => $entity2]); $field->setData($existing); - $field->submit(array('0', '2')); + $field->submit(['0', '2']); // entry with index 0 ($entity2) was replaced - $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); + $expected = new ArrayCollection([0 => $entity1, 1 => $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); - $this->assertSame(array('0', '2'), $field->getViewData()); + $this->assertSame(['0', '2'], $field->getViewData()); } public function testSubmitSingleExpanded() @@ -489,15 +489,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -515,19 +515,19 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Bar'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); @@ -544,19 +544,19 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(-1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('-1')); + $field->submit(['-1']); - $expected = new ArrayCollection(array($entity1)); + $expected = new ArrayCollection([$entity1]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); @@ -569,15 +569,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -591,15 +591,15 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleStringCastableIdEntity(1, 'Foo'); $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -617,29 +617,29 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $existing = new ArrayCollection(array(0 => $entity2)); + $existing = new ArrayCollection([0 => $entity2]); $field->setData($existing); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); // entry with index 0 ($entity2) was replaced - $expected = new ArrayCollection(array(0 => $entity1, 1 => $entity3)); + $expected = new ArrayCollection([0 => $entity1, 1 => $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); // same object still, useful if it is a PersistentCollection $this->assertSame($existing, $field->getData()); - $this->assertSame(array('1', '3'), $field->getViewData()); + $this->assertSame(['1', '3'], $field->getViewData()); } public function testSubmitMultipleNonExpandedStringCastableIdentifier() @@ -648,23 +648,23 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); - $this->assertSame(array('1', '3'), $field->getViewData()); + $this->assertSame(['1', '3'], $field->getViewData()); } public function testSubmitMultipleStringCastableIdentifierExpanded() @@ -673,19 +673,19 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleStringCastableIdEntity(2, 'Bar'); $entity3 = new SingleStringCastableIdEntity(3, 'Bar'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => true, 'expanded' => true, 'em' => 'default', 'class' => self::SINGLE_STRING_CASTABLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); - $field->submit(array('1', '3')); + $field->submit(['1', '3']); - $expected = new ArrayCollection(array($entity1, $entity3)); + $expected = new ArrayCollection([$entity1, $entity3]); $this->assertTrue($field->isSynchronized()); $this->assertEquals($expected, $field->getData()); @@ -703,19 +703,19 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, // not all persisted entities should be displayed - 'choices' => array($entity1, $entity2), + 'choices' => [$entity1, $entity2], 'choice_label' => 'name', - )); + ]); $field->submit('2'); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized()); $this->assertSame($entity2, $field->getData()); $this->assertSame('2', $field->getViewData()); @@ -726,18 +726,18 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', 'choice_value' => 'name', - )); + ]); $field->submit('Bar'); - $this->assertEquals(array('Foo' => new ChoiceView($entity1, 'Foo', 'Foo'), 'Bar' => new ChoiceView($entity2, 'Bar', 'Bar')), $field->createView()->vars['choices']); + $this->assertEquals(['Foo' => new ChoiceView($entity1, 'Foo', 'Foo'), 'Bar' => new ChoiceView($entity2, 'Bar', 'Bar')], $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); $this->assertSame('Bar', $field->getViewData()); @@ -748,9 +748,9 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new GroupableEntity(1, 'Foo', 'BazGroup'); $entity2 = new GroupableEntity(2, 'Bar', 'BooGroup'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, 'choice_label' => 'name', @@ -761,14 +761,14 @@ class EntityTypeTest extends BaseTypeTest return $entity->groupName.'/'.$entity->name; }, - )); + ]); $field->submit('BooGroup/Bar'); - $this->assertEquals(array( + $this->assertEquals([ 'BazGroup/Foo' => new ChoiceView($entity1, 'BazGroup/Foo', 'Foo'), 'BooGroup/Bar' => new ChoiceView($entity2, 'BooGroup/Bar', 'Bar'), - ), $field->createView()->vars['choices']); + ], $field->createView()->vars['choices']); $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); $this->assertSame('BooGroup/Bar', $field->getViewData()); @@ -779,13 +779,13 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Bar'); - $this->persist(array($entity1, $entity2)); + $this->persist([$entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $this->em->clear(); @@ -805,29 +805,29 @@ class EntityTypeTest extends BaseTypeTest $item3 = new GroupableEntity(3, 'Baz', 'Group2'); $item4 = new GroupableEntity(4, 'Boo!', null); - $this->persist(array($item1, $item2, $item3, $item4)); + $this->persist([$item1, $item2, $item3, $item4]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, - 'choices' => array($item1, $item2, $item3, $item4), + 'choices' => [$item1, $item2, $item3, $item4], 'choice_label' => 'name', 'group_by' => 'groupName', - )); + ]); $field->submit('2'); $this->assertSame('2', $field->getViewData()); - $this->assertEquals(array( - 'Group1' => new ChoiceGroupView('Group1', array( + $this->assertEquals([ + 'Group1' => new ChoiceGroupView('Group1', [ 1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar'), - )), - 'Group2' => new ChoiceGroupView('Group2', array( + ]), + 'Group2' => new ChoiceGroupView('Group2', [ 3 => new ChoiceView($item3, '3', 'Baz'), - )), + ]), 4 => new ChoiceView($item4, '4', 'Boo!'), - ), $field->createView()->vars['choices']); + ], $field->createView()->vars['choices']); } public function testPreferredChoices() @@ -836,17 +836,17 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - 'preferred_choices' => array($entity3, $entity2), + 'preferred_choices' => [$entity3, $entity2], 'choice_label' => 'name', - )); + ]); - $this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['preferred_choices']); - $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo')), $field->createView()->vars['choices']); + $this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['preferred_choices']); + $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo')], $field->createView()->vars['choices']); } public function testOverrideChoicesWithPreferredChoices() @@ -855,18 +855,18 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - 'choices' => array($entity2, $entity3), - 'preferred_choices' => array($entity3), + 'choices' => [$entity2, $entity3], + 'preferred_choices' => [$entity3], 'choice_label' => 'name', - )); + ]); - $this->assertEquals(array(3 => new ChoiceView($entity3, '3', 'Baz')), $field->createView()->vars['preferred_choices']); - $this->assertEquals(array(2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); + $this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz')], $field->createView()->vars['preferred_choices']); + $this->assertEquals([2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']); } public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier() @@ -875,14 +875,14 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - 'choices' => array($entity1, $entity2), + 'choices' => [$entity1, $entity2], 'choice_label' => 'name', - )); + ]); $field->submit('3'); @@ -898,14 +898,14 @@ class EntityTypeTest extends BaseTypeTest $entity1 = new SingleAssociationToIntIdEntity($innerEntity1, 'Foo'); $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); - $this->persist(array($innerEntity1, $innerEntity2, $entity1, $entity2)); + $this->persist([$innerEntity1, $innerEntity2, $entity1, $entity2]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, - 'choices' => array($entity1, $entity2), + 'choices' => [$entity1, $entity2], 'choice_label' => 'name', - )); + ]); $field->submit('3'); @@ -919,14 +919,14 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, - 'choices' => array($entity1, $entity2), + 'choices' => [$entity1, $entity2], 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -940,17 +940,17 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); $repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repository->createQueryBuilder('e') ->where('e.id IN (1, 2)'), 'choice_label' => 'name', - )); + ]); $field->submit('3'); @@ -968,17 +968,17 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleAssociationToIntIdEntity($innerEntity2, 'Bar'); $entity3 = new SingleAssociationToIntIdEntity($innerEntity3, 'Baz'); - $this->persist(array($innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3)); + $this->persist([$innerEntity1, $innerEntity2, $innerEntity3, $entity1, $entity2, $entity3]); $repository = $this->em->getRepository(self::SINGLE_ASSOC_IDENT_CLASS); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_ASSOC_IDENT_CLASS, 'query_builder' => $repository->createQueryBuilder('e') ->where('e.entity IN (1, 2)'), 'choice_label' => 'name', - )); + ]); $field->submit('3'); @@ -992,9 +992,9 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repository) { @@ -1002,7 +1002,7 @@ class EntityTypeTest extends BaseTypeTest ->where('e.id IN (1, 2)'); }, 'choice_label' => 'name', - )); + ]); $field->submit('3'); @@ -1016,9 +1016,9 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new CompositeIntIdEntity(30, 40, 'Bar'); $entity3 = new CompositeIntIdEntity(50, 60, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repository) { @@ -1026,7 +1026,7 @@ class EntityTypeTest extends BaseTypeTest ->where('e.id1 IN (10, 50)'); }, 'choice_label' => 'name', - )); + ]); $field->submit('2'); @@ -1038,15 +1038,15 @@ class EntityTypeTest extends BaseTypeTest { $entity1 = new SingleStringIdEntity('foo', 'Foo'); - $this->persist(array($entity1)); + $this->persist([$entity1]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::SINGLE_STRING_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); $field->submit('foo'); @@ -1059,15 +1059,15 @@ class EntityTypeTest extends BaseTypeTest { $entity1 = new CompositeStringIdEntity('foo1', 'foo2', 'Foo'); - $this->persist(array($entity1)); + $this->persist([$entity1]); - $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $field = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'multiple' => false, 'expanded' => false, 'em' => 'default', 'class' => self::COMPOSITE_STRING_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); // the collection key is used here $field->submit('0'); @@ -1087,11 +1087,11 @@ class EntityTypeTest extends BaseTypeTest ->with(self::SINGLE_IDENT_CLASS) ->will($this->returnValue($this->em)); - $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'choice_label' => 'name', - )); + ]); } public function testExplicitEm() @@ -1102,11 +1102,11 @@ class EntityTypeTest extends BaseTypeTest $this->emRegistry->expects($this->never()) ->method('getManagerForClass'); - $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => $this->em, 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', - )); + ]); } public function testLoaderCaching() @@ -1115,7 +1115,7 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); $repo = $this->em->getRepository(self::SINGLE_IDENT_CLASS); @@ -1130,35 +1130,35 @@ class EntityTypeTest extends BaseTypeTest $formBuilder = $factory->createNamedBuilder('form', FormTypeTest::TESTED_TYPE); - $formBuilder->add('property1', static::TESTED_TYPE, array( + $formBuilder->add('property1', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'), - )); + ]); - $formBuilder->add('property2', static::TESTED_TYPE, array( + $formBuilder->add('property2', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'); }, - )); + ]); - $formBuilder->add('property3', static::TESTED_TYPE, array( + $formBuilder->add('property3', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id IN (1, 2)'); }, - )); + ]); $form = $formBuilder->getForm(); - $form->submit(array( + $form->submit([ 'property1' => 1, 'property2' => 1, 'property3' => 2, - )); + ]); $choiceLoader1 = $form->get('property1')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); @@ -1175,7 +1175,7 @@ class EntityTypeTest extends BaseTypeTest $entity2 = new SingleIntIdEntity(2, 'Bar'); $entity3 = new SingleIntIdEntity(3, 'Baz'); - $this->persist(array($entity1, $entity2, $entity3)); + $this->persist([$entity1, $entity2, $entity3]); $repo = $this->em->getRepository(self::SINGLE_IDENT_CLASS); @@ -1190,35 +1190,35 @@ class EntityTypeTest extends BaseTypeTest $formBuilder = $factory->createNamedBuilder('form', FormTypeTest::TESTED_TYPE); - $formBuilder->add('property1', static::TESTED_TYPE, array( + $formBuilder->add('property1', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1), - )); + ]); - $formBuilder->add('property2', static::TESTED_TYPE, array( + $formBuilder->add('property2', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1); }, - )); + ]); - $formBuilder->add('property3', static::TESTED_TYPE, array( + $formBuilder->add('property3', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('e')->where('e.id = :id')->setParameter('id', 1); }, - )); + ]); $form = $formBuilder->getForm(); - $form->submit(array( + $form->submit([ 'property1' => 1, 'property2' => 1, 'property3' => 2, - )); + ]); $choiceLoader1 = $form->get('property1')->getConfig()->getOption('choice_loader'); $choiceLoader2 = $form->get('property2')->getConfig()->getOption('choice_loader'); @@ -1242,21 +1242,21 @@ class EntityTypeTest extends BaseTypeTest public function testPassDisabledAsOption() { - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'disabled' => true, 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $this->assertTrue($form->isDisabled()); } public function testPassIdAndNameToView() { - $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, array( + $view = $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->createView(); $this->assertEquals('name', $view->vars['id']); @@ -1266,10 +1266,10 @@ class EntityTypeTest extends BaseTypeTest public function testStripLeadingUnderscoresAndDigitsFromId() { - $view = $this->factory->createNamed('_09name', static::TESTED_TYPE, null, array( + $view = $this->factory->createNamed('_09name', static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->createView(); $this->assertEquals('name', $view->vars['id']); @@ -1280,10 +1280,10 @@ class EntityTypeTest extends BaseTypeTest public function testPassIdAndNameToViewWithParent() { $view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) - ->add('child', static::TESTED_TYPE, array( + ->add('child', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->getForm() ->createView(); @@ -1296,10 +1296,10 @@ class EntityTypeTest extends BaseTypeTest { $builder = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', FormTypeTest::TESTED_TYPE); - $builder->get('child')->add('grand_child', static::TESTED_TYPE, array( + $builder->get('child')->add('grand_child', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $view = $builder->getForm()->createView(); $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); @@ -1309,11 +1309,11 @@ class EntityTypeTest extends BaseTypeTest public function testPassTranslationDomainToView() { - $view = $this->factory->create(static::TESTED_TYPE, null, array( + $view = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'translation_domain' => 'domain', - )) + ]) ->createView(); $this->assertSame('domain', $view->vars['translation_domain']); @@ -1322,13 +1322,13 @@ class EntityTypeTest extends BaseTypeTest public function testInheritTranslationDomainFromParent() { $view = $this->factory - ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( + ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [ 'translation_domain' => 'domain', - )) - ->add('child', static::TESTED_TYPE, array( + ]) + ->add('child', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->getForm() ->createView(); @@ -1338,14 +1338,14 @@ class EntityTypeTest extends BaseTypeTest public function testPreferOwnTranslationDomain() { $view = $this->factory - ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( + ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [ 'translation_domain' => 'parent_domain', - )) - ->add('child', static::TESTED_TYPE, array( + ]) + ->add('child', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'translation_domain' => 'domain', - )) + ]) ->getForm() ->createView(); @@ -1356,10 +1356,10 @@ class EntityTypeTest extends BaseTypeTest { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) - ->add('child', static::TESTED_TYPE, array( + ->add('child', static::TESTED_TYPE, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->getForm() ->createView(); @@ -1368,11 +1368,11 @@ class EntityTypeTest extends BaseTypeTest public function testPassLabelToView() { - $view = $this->factory->createNamed('__test___field', static::TESTED_TYPE, null, array( + $view = $this->factory->createNamed('__test___field', static::TESTED_TYPE, null, [ 'label' => 'My label', 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->createView(); $this->assertSame('My label', $view->vars['label']); @@ -1380,10 +1380,10 @@ class EntityTypeTest extends BaseTypeTest public function testPassMultipartFalseToView() { - $view = $this->factory->create(static::TESTED_TYPE, null, array( + $view = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )) + ]) ->createView(); $this->assertFalse($view->vars['multipart']); @@ -1391,10 +1391,10 @@ class EntityTypeTest extends BaseTypeTest public function testSubmitNull($expected = null, $norm = null, $view = null) { - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, - )); + ]); $form->submit(null); $this->assertNull($form->getData()); @@ -1404,11 +1404,11 @@ class EntityTypeTest extends BaseTypeTest public function testSubmitNullExpanded() { - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'expanded' => true, - )); + ]); $form->submit(null); $this->assertNull($form->getData()); @@ -1418,82 +1418,82 @@ class EntityTypeTest extends BaseTypeTest public function testSubmitNullMultiple() { - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, - )); + ]); $form->submit(null); $collection = new ArrayCollection(); $this->assertEquals($collection, $form->getData()); $this->assertEquals($collection, $form->getNormData()); - $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); + $this->assertSame([], $form->getViewData(), 'View data is always an array'); } public function testSubmitNullExpandedMultiple() { - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'expanded' => true, 'multiple' => true, - )); + ]); $form->submit(null); $collection = new ArrayCollection(); $this->assertEquals($collection, $form->getData()); $this->assertEquals($collection, $form->getNormData()); - $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); + $this->assertSame([], $form->getViewData(), 'View data is always an array'); } public function testSetDataEmptyArraySubmitNullMultiple() { - $emptyArray = array(); - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $emptyArray = []; + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, - )); + ]); $form->setData($emptyArray); $form->submit(null); $this->assertInternalType('array', $form->getData()); - $this->assertEquals(array(), $form->getData()); - $this->assertEquals(array(), $form->getNormData()); - $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); + $this->assertEquals([], $form->getData()); + $this->assertEquals([], $form->getNormData()); + $this->assertSame([], $form->getViewData(), 'View data is always an array'); } public function testSetDataNonEmptyArraySubmitNullMultiple() { $entity1 = new SingleIntIdEntity(1, 'Foo'); - $this->persist(array($entity1)); - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $this->persist([$entity1]); + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, - )); - $existing = array(0 => $entity1); + ]); + $existing = [0 => $entity1]; $form->setData($existing); $form->submit(null); $this->assertInternalType('array', $form->getData()); - $this->assertEquals(array(), $form->getData()); - $this->assertEquals(array(), $form->getNormData()); - $this->assertSame(array(), $form->getViewData(), 'View data is always an array'); + $this->assertEquals([], $form->getData()); + $this->assertEquals([], $form->getNormData()); + $this->assertSame([], $form->getViewData(), 'View data is always an array'); } public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = null) { $emptyData = '1'; $entity1 = new SingleIntIdEntity(1, 'Foo'); - $this->persist(array($entity1)); + $this->persist([$entity1]); - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'empty_data' => $emptyData, - )); + ]); $form->submit(null); $this->assertSame($emptyData, $form->getViewData()); @@ -1503,19 +1503,19 @@ class EntityTypeTest extends BaseTypeTest public function testSubmitNullMultipleUsesDefaultEmptyData() { - $emptyData = array('1'); + $emptyData = ['1']; $entity1 = new SingleIntIdEntity(1, 'Foo'); - $this->persist(array($entity1)); + $this->persist([$entity1]); - $form = $this->factory->create(static::TESTED_TYPE, null, array( + $form = $this->factory->create(static::TESTED_TYPE, null, [ 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'multiple' => true, 'empty_data' => $emptyData, - )); + ]); $form->submit(null); - $collection = new ArrayCollection(array($entity1)); + $collection = new ArrayCollection([$entity1]); $this->assertSame($emptyData, $form->getViewData()); $this->assertEquals($collection, $form->getNormData()); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 38bbed1294..10c403f461 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -25,8 +25,8 @@ class DbalLoggerTest extends TestCase $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') - ->setConstructorArgs(array($logger, null)) - ->setMethods(array('log')) + ->setConstructorArgs([$logger, null]) + ->setMethods(['log']) ->getMock() ; @@ -41,14 +41,14 @@ class DbalLoggerTest extends TestCase public function getLogFixtures() { - return array( - array('SQL', null, array()), - array('SQL', array(), array()), - array('SQL', array('foo' => 'bar'), array('foo' => 'bar')), - array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), - array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), - array('SQL', array('foo' => ''), array('foo' => '')), - ); + return [ + ['SQL', null, []], + ['SQL', [], []], + ['SQL', ['foo' => 'bar'], ['foo' => 'bar']], + ['SQL', ['foo' => "\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]], + ['SQL', ['foo' => "bar\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]], + ['SQL', ['foo' => ''], ['foo' => '']], + ]; } public function testLogNonUtf8() @@ -57,21 +57,21 @@ class DbalLoggerTest extends TestCase $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') - ->setConstructorArgs(array($logger, null)) - ->setMethods(array('log')) + ->setConstructorArgs([$logger, null]) + ->setMethods(['log']) ->getMock() ; $dbalLogger ->expects($this->once()) ->method('log') - ->with('SQL', array('utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE)) + ->with('SQL', ['utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE]) ; - $dbalLogger->startQuery('SQL', array( + $dbalLogger->startQuery('SQL', [ 'utf8' => 'foo', 'nonutf8' => "\x7F\xFF", - )); + ]); } public function testLogNonUtf8Array() @@ -80,29 +80,29 @@ class DbalLoggerTest extends TestCase $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') - ->setConstructorArgs(array($logger, null)) - ->setMethods(array('log')) + ->setConstructorArgs([$logger, null]) + ->setMethods(['log']) ->getMock() ; $dbalLogger ->expects($this->once()) ->method('log') - ->with('SQL', array( + ->with('SQL', [ 'utf8' => 'foo', - array( + [ 'nonutf8' => DbalLogger::BINARY_DATA_VALUE, - ), - ) + ], + ] ) ; - $dbalLogger->startQuery('SQL', array( + $dbalLogger->startQuery('SQL', [ 'utf8' => 'foo', - array( + [ 'nonutf8' => "\x7F\xFF", - ), - )); + ], + ]); } public function testLogLongString() @@ -111,8 +111,8 @@ class DbalLoggerTest extends TestCase $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') - ->setConstructorArgs(array($logger, null)) - ->setMethods(array('log')) + ->setConstructorArgs([$logger, null]) + ->setMethods(['log']) ->getMock() ; @@ -124,13 +124,13 @@ class DbalLoggerTest extends TestCase $dbalLogger ->expects($this->once()) ->method('log') - ->with('SQL', array('short' => $shortString, 'long' => substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6).' [...]')) + ->with('SQL', ['short' => $shortString, 'long' => substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6).' [...]']) ; - $dbalLogger->startQuery('SQL', array( + $dbalLogger->startQuery('SQL', [ 'short' => $shortString, 'long' => $longString, - )); + ]); } public function testLogUTF8LongString() @@ -139,12 +139,12 @@ class DbalLoggerTest extends TestCase $dbalLogger = $this ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') - ->setConstructorArgs(array($logger, null)) - ->setMethods(array('log')) + ->setConstructorArgs([$logger, null]) + ->setMethods(['log']) ->getMock() ; - $testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í'); + $testStringArray = ['é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í']; $testStringCount = \count($testStringArray); $shortString = ''; @@ -158,12 +158,12 @@ class DbalLoggerTest extends TestCase $dbalLogger ->expects($this->once()) ->method('log') - ->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]')) + ->with('SQL', ['short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]']) ; - $dbalLogger->startQuery('SQL', array( + $dbalLogger->startQuery('SQL', [ 'short' => $shortString, 'long' => $longString, - )); + ]); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php index 490a48cfe6..e5ebeeacf8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php @@ -30,7 +30,7 @@ class ManagerRegistryTest extends TestCase { $container = new \LazyServiceProjectServiceContainer(); - $registry = new TestManagerRegistry('name', array(), array('defaultManager' => 'foo'), 'defaultConnection', 'defaultManager', 'proxyInterfaceName'); + $registry = new TestManagerRegistry('name', [], ['defaultManager' => 'foo'], 'defaultConnection', 'defaultManager', 'proxyInterfaceName'); $registry->setTestContainer($container); $foo = $container->get('foo'); diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index dcb52718b1..cad2dfeaac 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -30,8 +30,8 @@ class DoctrineExtractorTest extends TestCase protected function setUp() { - $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'), true); - $entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config); + $config = Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true); + $entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config); if (!DBALType::hasType('foo')) { DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType'); @@ -44,7 +44,7 @@ class DoctrineExtractorTest extends TestCase public function testGetProperties() { $this->assertEquals( - array( + [ 'id', 'guid', 'time', @@ -62,7 +62,7 @@ class DoctrineExtractorTest extends TestCase 'bar', 'indexedBar', 'indexedFoo', - ), + ], $this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy') ); } @@ -74,10 +74,10 @@ class DoctrineExtractorTest extends TestCase } $this->assertEquals( - array( + [ 'id', 'embedded', - ), + ], $this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded') ); } @@ -87,7 +87,7 @@ class DoctrineExtractorTest extends TestCase */ public function testExtract($property, array $type = null) { - $this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array())); + $this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, [])); } public function testExtractWithEmbedded() @@ -96,16 +96,16 @@ class DoctrineExtractorTest extends TestCase $this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.'); } - $expectedTypes = array(new Type( + $expectedTypes = [new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable' - )); + )]; $actualTypes = $this->extractor->getTypes( 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded', 'embedded', - array() + [] ); $this->assertEquals($expectedTypes, $actualTypes); @@ -113,47 +113,47 @@ class DoctrineExtractorTest extends TestCase public function typesProvider() { - return array( - array('id', array(new Type(Type::BUILTIN_TYPE_INT))), - array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))), - array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))), - array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), - array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))), - array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))), - array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))), - array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))), - array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))), - array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))), - array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))), - array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))), - array('bar', array(new Type( + return [ + ['id', [new Type(Type::BUILTIN_TYPE_INT)]], + ['guid', [new Type(Type::BUILTIN_TYPE_STRING)]], + ['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]], + ['time', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]], + ['timeImmutable', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]], + ['dateInterval', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval')]], + ['float', [new Type(Type::BUILTIN_TYPE_FLOAT)]], + ['decimal', [new Type(Type::BUILTIN_TYPE_STRING)]], + ['bool', [new Type(Type::BUILTIN_TYPE_BOOL)]], + ['binary', [new Type(Type::BUILTIN_TYPE_RESOURCE)]], + ['json', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]], + ['foo', [new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')]], + ['bar', [new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation') - ))), - array('indexedBar', array(new Type( + )]], + ['indexedBar', [new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation') - ))), - array('indexedFoo', array(new Type( + )]], + ['indexedFoo', [new Type( Type::BUILTIN_TYPE_OBJECT, false, 'Doctrine\Common\Collections\Collection', true, new Type(Type::BUILTIN_TYPE_STRING), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation') - ))), - array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))), - array('customFoo', null), - array('notMapped', null), - ); + )]], + ['simpleArray', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))]], + ['customFoo', null], + ['notMapped', null], + ]; } public function testGetPropertiesCatchException() diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 8d0a938114..1b8cba50f3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -38,7 +38,7 @@ class DoctrineFooType extends Type */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - return $platform->getClobTypeDeclarationSQL(array()); + return $platform->getClobTypeDeclarationSQL([]); } /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 9d0f79948b..7188a3abc1 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -145,7 +145,7 @@ class EntityUserProviderTest extends TestCase $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); - $user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1)); + $user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', ['id1' => 1, 'id2' => 1]); $this->assertTrue($provider->supportsClass(\get_class($user2))); } @@ -196,7 +196,7 @@ class EntityUserProviderTest extends TestCase private function getObjectManager($repository) { $em = $this->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager') - ->setMethods(array('getClassMetadata', 'getRepository')) + ->setMethods(['getClassMetadata', 'getRepository']) ->getMockForAbstractClass(); $em->expects($this->any()) ->method('getRepository') @@ -208,8 +208,8 @@ class EntityUserProviderTest extends TestCase private function createSchema($em) { $schemaTool = new SchemaTool($em); - $schemaTool->createSchema(array( + $schemaTool->createSchema([ $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\User'), - )); + ]); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index d8b55eb808..60007eb8a3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -90,7 +90,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase protected function createRepositoryMock() { $repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository') - ->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName')) + ->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName']) ->getMock() ; @@ -118,8 +118,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->getMock() ; $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') - ->setConstructorArgs(array($reflParser, 'property-name')) - ->setMethods(array('getValue')) + ->setConstructorArgs([$reflParser, 'property-name']) + ->setMethods(['getValue']) ->getMock() ; $refl @@ -127,7 +127,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->method('getValue') ->will($this->returnValue(true)) ; - $classMetadata->reflFields = array('name' => $refl); + $classMetadata->reflFields = ['name' => $refl]; $em->expects($this->any()) ->method('getClassMetadata') ->will($this->returnValue($classMetadata)) @@ -144,7 +144,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase private function createSchema(ObjectManager $em) { $schemaTool = new SchemaTool($em); - $schemaTool->createSchema(array( + $schemaTool->createSchema([ $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'), @@ -156,7 +156,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'), $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity'), - )); + ]); } /** @@ -164,11 +164,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testValidateUniqueness() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); @@ -190,19 +190,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) - ->setCause(array($entity1)) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateCustomErrorPath() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'errorPath' => 'bar', - )); + ]); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); @@ -216,18 +216,18 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.bar') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) - ->setCause(array($entity1)) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessWithNull() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $entity1 = new SingleIntIdEntity(1, null); $entity2 = new SingleIntIdEntity(2, null); @@ -243,12 +243,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testValidateUniquenessWithIgnoreNullDisabled() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name', 'name2'), + 'fields' => ['name', 'name2'], 'em' => self::EM_NAME, 'ignoreNull' => false, - )); + ]); $entity1 = new DoubleNameEntity(1, 'Foo', null); $entity2 = new DoubleNameEntity(2, 'Foo', null); @@ -270,7 +270,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue('Foo') - ->setCause(array($entity1)) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } @@ -280,12 +280,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name', 'name2'), + 'fields' => ['name', 'name2'], 'em' => self::EM_NAME, 'ignoreNull' => true, - )); + ]); $entity1 = new SingleIntIdEntity(1, null); @@ -294,12 +294,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name', 'name2'), + 'fields' => ['name', 'name2'], 'em' => self::EM_NAME, 'ignoreNull' => true, - )); + ]); $entity1 = new DoubleNullableNameEntity(1, null, 'Foo'); $entity2 = new DoubleNullableNameEntity(2, null, 'Foo'); @@ -322,12 +322,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testValidateUniquenessWithValidCustomErrorPath() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name', 'name2'), + 'fields' => ['name', 'name2'], 'em' => self::EM_NAME, 'errorPath' => 'name2', - )); + ]); $entity1 = new DoubleNameEntity(1, 'Foo', 'Bar'); $entity2 = new DoubleNameEntity(2, 'Foo', 'Bar'); @@ -349,24 +349,24 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name2') ->setParameter('{{ value }}', '"Bar"') ->setInvalidValue('Bar') - ->setCause(array($entity1)) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessUsingCustomRepositoryMethod() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', - )); + ]); $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue(array())) + ->will($this->returnValue([])) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); @@ -382,12 +382,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testValidateUniquenessWithUnrewoundArray() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', - )); + ]); $entity = new SingleIntIdEntity(1, 'foo'); @@ -396,9 +396,9 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->method('findByCustom') ->will( $this->returnCallback(function () use ($entity) { - $returnValue = array( + $returnValue = [ $entity, - ); + ]; next($returnValue); return $returnValue; @@ -420,12 +420,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testValidateResultTypes($entity1, $result) { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', - )); + ]); $repository = $this->createRepositoryMock(); $repository->expects($this->once()) @@ -446,20 +446,20 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase { $entity = new SingleIntIdEntity(1, 'foo'); - return array( - array($entity, array($entity)), - array($entity, new \ArrayIterator(array($entity))), - array($entity, new ArrayCollection(array($entity))), - ); + return [ + [$entity, [$entity]], + [$entity, new \ArrayIterator([$entity])], + [$entity, new ArrayCollection([$entity])], + ]; } public function testAssociatedEntity() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('single'), + 'fields' => ['single'], 'em' => self::EM_NAME, - )); + ]); $entity1 = new SingleIntIdEntity(1, 'foo'); $associated = new AssociationEntity(); @@ -485,17 +485,17 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->setParameter('{{ value }}', 'foo') ->setInvalidValue($entity1) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) - ->setCause(array($associated, $associated2)) + ->setCause([$associated, $associated2]) ->assertRaised(); } public function testValidateUniquenessNotToStringEntityWithAssociatedEntity() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('single'), + 'fields' => ['single'], 'em' => self::EM_NAME, - )); + ]); $entity1 = new SingleIntIdNoToStringEntity(1, 'foo'); $associated = new AssociationEntity2(); @@ -522,19 +522,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.single') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($entity1) - ->setCause(array($associated, $associated2)) + ->setCause([$associated, $associated2]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testAssociatedEntityWithNull() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('single'), + 'fields' => ['single'], 'em' => self::EM_NAME, 'ignoreNull' => false, - )); + ]); $associated = new AssociationEntity(); $associated->single = null; @@ -552,19 +552,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase $repository = $this->createRepositoryMock(); $this->repositoryFactory->setRepository($this->em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', $repository); - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('phoneNumbers'), + 'fields' => ['phoneNumbers'], 'em' => self::EM_NAME, 'repositoryMethod' => 'findByCustom', - )); + ]); $entity1 = new SingleIntIdEntity(1, 'foo'); $entity1->phoneNumbers[] = 123; $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue(array($entity1))) + ->will($this->returnValue([$entity1])) ; $this->em->persist($entity1); @@ -580,8 +580,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase $this->buildViolation('myMessage') ->atPath('property.path.phoneNumbers') ->setParameter('{{ value }}', 'array') - ->setInvalidValue(array(123)) - ->setCause(array($entity1)) + ->setInvalidValue([123]) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } @@ -592,11 +592,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testDedicatedEntityManagerNullObject() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $this->em = null; $this->registry = $this->createRegistryMock($this->em); @@ -614,11 +614,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testEntityManagerNullObject() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], // no "em" option set - )); + ]); $this->em = null; $this->registry = $this->createRegistryMock($this->em); @@ -643,11 +643,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase $this->validator = $this->createValidator(); $this->validator->initialize($this->context); - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $entity = new SingleIntIdEntity(1, null); @@ -660,12 +660,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testValidateInheritanceUniqueness() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\Person', - )); + ]); $entity1 = new Person(1, 'Foo'); $entity2 = new Employee(2, 'Foo'); @@ -687,8 +687,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name') ->setInvalidValue('Foo') ->setCode('23bd9dbf-6b9b-41cd-a99e-4844bcf3077f') - ->setCause(array($entity1)) - ->setParameters(array('{{ value }}' => '"Foo"')) + ->setCause([$entity1]) + ->setParameters(['{{ value }}' => '"Foo"']) ->assertRaised(); } @@ -698,12 +698,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testInvalidateRepositoryForInheritance() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, 'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', - )); + ]); $entity = new Person(1, 'Foo'); $this->validator->validate($entity, $constraint); @@ -711,11 +711,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase public function testValidateUniquenessWithCompositeObjectNoToStringIdEntity() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('objectOne', 'objectTwo'), + 'fields' => ['objectOne', 'objectTwo'], 'em' => self::EM_NAME, - )); + ]); $objectOne = new SingleIntIdNoToStringEntity(1, 'foo'); $objectTwo = new SingleIntIdNoToStringEntity(2, 'bar'); @@ -739,18 +739,18 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.objectOne') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($objectOne) - ->setCause(array($entity)) + ->setCause([$entity]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } public function testValidateUniquenessWithCustomDoctrineTypeValue() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $existingEntity = new SingleIntIdStringWrapperNameEntity(1, new StringWrapper('foo')); @@ -767,7 +767,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name') ->setParameter('{{ value }}', $expectedValue) ->setInvalidValue($existingEntity->name) - ->setCause(array($existingEntity)) + ->setCause([$existingEntity]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } @@ -777,11 +777,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase */ public function testValidateUniquenessCause() { - $constraint = new UniqueEntity(array( + $constraint = new UniqueEntity([ 'message' => 'myMessage', - 'fields' => array('name'), + 'fields' => ['name'], 'em' => self::EM_NAME, - )); + ]); $entity1 = new SingleIntIdEntity(1, 'Foo'); $entity2 = new SingleIntIdEntity(2, 'Foo'); @@ -803,7 +803,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase ->atPath('property.path.name') ->setParameter('{{ value }}', '"Foo"') ->setInvalidValue($entity2) - ->setCause(array($entity1)) + ->setCause([$entity1]) ->setCode(UniqueEntity::NOT_UNIQUE_ERROR) ->assertRaised(); } diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php index c9b13dcf59..2c319709eb 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php @@ -30,17 +30,17 @@ class UniqueEntity extends Constraint public $em = null; public $entityClass = null; public $repositoryMethod = 'findBy'; - public $fields = array(); + public $fields = []; public $errorPath = null; public $ignoreNull = true; - protected static $errorNames = array( + protected static $errorNames = [ self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR', - ); + ]; public function getRequiredOptions() { - return array('fields'); + return ['fields']; } /** diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 161a187ff9..47cb2bd730 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -81,7 +81,7 @@ class UniqueEntityValidator extends ConstraintValidator $class = $em->getClassMetadata(\get_class($entity)); /* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */ - $criteria = array(); + $criteria = []; $hasNullValue = false; foreach ($fields as $fieldName) { @@ -149,15 +149,15 @@ class UniqueEntityValidator extends ConstraintValidator if ($result instanceof \Iterator) { $result->rewind(); if ($result instanceof \Countable && 1 < \count($result)) { - $result = array($result->current(), $result->current()); + $result = [$result->current(), $result->current()]; } else { $result = $result->current(); - $result = null === $result ? array() : array($result); + $result = null === $result ? [] : [$result]; } } elseif (\is_array($result)) { reset($result); } else { - $result = null === $result ? array() : array($result); + $result = null === $result ? [] : [$result]; } /* If no entity matched the query criteria or a single entity matched, @@ -197,7 +197,7 @@ class UniqueEntityValidator extends ConstraintValidator } else { // this case might happen if the non unique column has a custom doctrine type and its value is an object // in which case we cannot get any identifiers for it - $identifiers = array(); + $identifiers = []; } } else { $identifiers = $class->getIdentifierValues($value); diff --git a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php index 65e99f6f87..c27b0803e2 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php @@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent; */ class ChromePhpHandler extends BaseChromePhpHandler { - private $headers = array(); + private $headers = []; /** * @var Response @@ -40,7 +40,7 @@ class ChromePhpHandler extends BaseChromePhpHandler if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) { $this->sendHeaders = false; - $this->headers = array(); + $this->headers = []; return; } @@ -49,7 +49,7 @@ class ChromePhpHandler extends BaseChromePhpHandler foreach ($this->headers as $header => $content) { $this->response->headers->set($header, $content); } - $this->headers = array(); + $this->headers = []; } /** diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index 9956edad38..9c3ec5f981 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent; */ class FirePHPHandler extends BaseFirePHPHandler { - private $headers = array(); + private $headers = []; /** * @var Response @@ -42,7 +42,7 @@ class FirePHPHandler extends BaseFirePHPHandler if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent')) && !$request->headers->has('X-FirePHP-Version')) { self::$sendHeaders = false; - $this->headers = array(); + $this->headers = []; return; } @@ -51,7 +51,7 @@ class FirePHPHandler extends BaseFirePHPHandler foreach ($this->headers as $header => $content) { $this->response->headers->set($header, $content); } - $this->headers = array(); + $this->headers = []; } /** diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php index 2f60299881..cb8ec23b5d 100644 --- a/src/Symfony/Bridge/Monolog/Logger.php +++ b/src/Symfony/Bridge/Monolog/Logger.php @@ -31,7 +31,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface return \call_user_func_array(array($logger, 'getLogs'), \func_get_args()); } - return array(); + return []; } /** diff --git a/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php b/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php index 11547be22b..7bf03a036a 100644 --- a/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php @@ -31,11 +31,11 @@ class TokenProcessor { $records['extra']['token'] = null; if (null !== $token = $this->tokenStorage->getToken()) { - $records['extra']['token'] = array( + $records['extra']['token'] = [ 'username' => $token->getUsername(), 'authenticated' => $token->isAuthenticated(), 'roles' => array_map(function ($role) { return $role->getRole(); }, $token->getRoles()), - ); + ]; } return $records; diff --git a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php index 9c32e756c5..c8e21f13d5 100644 --- a/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php @@ -26,7 +26,7 @@ class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface public function __construct(array $extraFields = null) { // Pass an empty array as the default null value would access $_SERVER - parent::__construct(array(), $extraFields); + parent::__construct([], $extraFields); } public function onKernelRequest(GetResponseEvent $event) diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 0764f89151..0f042a90ae 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -38,13 +38,13 @@ class ConsoleHandlerTest extends TestCase public function testIsHandling() { $handler = new ConsoleHandler(); - $this->assertFalse($handler->isHandling(array()), '->isHandling returns false when no output is set'); + $this->assertFalse($handler->isHandling([]), '->isHandling returns false when no output is set'); } /** * @dataProvider provideVerbosityMappingTests */ - public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array()) + public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = []) { $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock(); $output @@ -53,7 +53,7 @@ class ConsoleHandlerTest extends TestCase ->will($this->returnValue($verbosity)) ; $handler = new ConsoleHandler($output, true, $map); - $this->assertSame($isHandling, $handler->isHandling(array('level' => $level)), + $this->assertSame($isHandling, $handler->isHandling(['level' => $level]), '->isHandling returns correct value depending on console verbosity and log level' ); @@ -61,7 +61,7 @@ class ConsoleHandlerTest extends TestCase $levelName = Logger::getLevelName($level); $levelName = sprintf('%-9s', $levelName); - $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock(); + $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(['doWrite'])->getMock(); $realOutput->setVerbosity($verbosity); if ($realOutput->isDebug()) { $log = "16:21:54 $levelName [app] My info message\n"; @@ -74,38 +74,38 @@ class ConsoleHandlerTest extends TestCase ->with($log, false); $handler = new ConsoleHandler($realOutput, true, $map); - $infoRecord = array( + $infoRecord = [ 'message' => 'My info message', - 'context' => array(), + 'context' => [], 'level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), - 'extra' => array(), - ); + 'extra' => [], + ]; $this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.'); } public function provideVerbosityMappingTests() { - return array( - array(OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true), - array(OutputInterface::VERBOSITY_QUIET, Logger::WARNING, false), - array(OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true), - array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false), - array(OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true), - array(OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false), - array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true), - array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false), - array(OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true), - array(OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true), - array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, array( + return [ + [OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true], + [OutputInterface::VERBOSITY_QUIET, Logger::WARNING, false], + [OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true], + [OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false], + [OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true], + [OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false], + [OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true], + [OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false], + [OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true], + [OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true], + [OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, [ OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE, - )), - array(OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, array( + ]], + [OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, [ OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE, - )), - ); + ]], + ]; } public function testVerbosityChanged() @@ -122,10 +122,10 @@ class ConsoleHandlerTest extends TestCase ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) ; $handler = new ConsoleHandler($output); - $this->assertFalse($handler->isHandling(array('level' => Logger::NOTICE)), + $this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]), 'when verbosity is set to quiet, the handler does not handle the log' ); - $this->assertTrue($handler->isHandling(array('level' => Logger::NOTICE)), + $this->assertTrue($handler->isHandling(['level' => Logger::NOTICE]), 'since the verbosity of the output increased externally, the handler is now handling the log' ); } @@ -155,15 +155,15 @@ class ConsoleHandlerTest extends TestCase $handler = new ConsoleHandler(null, false); $handler->setOutput($output); - $infoRecord = array( + $infoRecord = [ 'message' => 'My info message', - 'context' => array(), + 'context' => [], 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), - 'extra' => array(), - ); + 'extra' => [], + ]; $this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.'); } diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php index 3c34f065eb..b04678106c 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php @@ -28,28 +28,28 @@ class NotFoundActivationStrategyTest extends TestCase $requestStack = new RequestStack(); $requestStack->push(Request::create($url)); - $strategy = new NotFoundActivationStrategy($requestStack, array('^/foo', 'bar'), Logger::WARNING); + $strategy = new NotFoundActivationStrategy($requestStack, ['^/foo', 'bar'], Logger::WARNING); $this->assertEquals($expected, $strategy->isHandlerActivated($record)); } public function isActivatedProvider() { - return array( - array('/test', array('level' => Logger::DEBUG), false), - array('/foo', array('level' => Logger::DEBUG, 'context' => $this->getContextException(404)), false), - array('/baz/bar', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false), - array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false), - array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true), + return [ + ['/test', ['level' => Logger::DEBUG], false], + ['/foo', ['level' => Logger::DEBUG, 'context' => $this->getContextException(404)], false], + ['/baz/bar', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false], + ['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false], + ['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true], - array('/test', array('level' => Logger::ERROR), true), - array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), true), - array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true), - ); + ['/test', ['level' => Logger::ERROR], true], + ['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], true], + ['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true], + ]; } protected function getContextException($code) { - return array('exception' => new HttpException($code)); + return ['exception' => new HttpException($code)]; } } diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php index e78acf47b5..1b01348639 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/TokenProcessorTest.php @@ -25,12 +25,12 @@ class TokenProcessorTest extends TestCase { public function testProcessor() { - $token = new UsernamePasswordToken('user', 'password', 'provider', array('ROLE_USER')); + $token = new UsernamePasswordToken('user', 'password', 'provider', ['ROLE_USER']); $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage->method('getToken')->willReturn($token); $processor = new TokenProcessor($tokenStorage); - $record = array('extra' => array()); + $record = ['extra' => []]; $record = $processor($record); $this->assertArrayHasKey('token', $record['extra']); diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 4c5432f260..a29edd9078 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -73,7 +73,7 @@ class ClockMock { $self = \get_called_class(); - $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); + $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index dc6df3f9b9..d18e161dd9 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -54,9 +54,9 @@ class DeprecationErrorHandler if (false === $mode) { $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); } - if (DeprecationErrorHandler::MODE_DISABLED !== $mode - && DeprecationErrorHandler::MODE_WEAK !== $mode - && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode + if (self::MODE_DISABLED !== $mode + && self::MODE_WEAK !== $mode + && self::MODE_WEAK_VENDORS !== $mode && (!isset($mode[0]) || '/' !== $mode[0]) ) { $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; @@ -92,21 +92,21 @@ class DeprecationErrorHandler return false; }; - $deprecations = array( + $deprecations = [ 'unsilencedCount' => 0, 'remainingCount' => 0, 'legacyCount' => 0, 'otherCount' => 0, 'remaining vendorCount' => 0, - 'unsilenced' => array(), - 'remaining' => array(), - 'legacy' => array(), - 'other' => array(), - 'remaining vendor' => array(), - ); - $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { + 'unsilenced' => [], + 'remaining' => [], + 'legacy' => [], + 'other' => [], + 'remaining vendor' => [], + ]; + $deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { $mode = $getMode(); - if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) { + if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) { $ErrorHandler = $UtilPrefix.'ErrorHandler'; return $ErrorHandler::handleError($type, $msg, $file, $line, $context); @@ -114,7 +114,7 @@ class DeprecationErrorHandler $trace = debug_backtrace(); $group = 'other'; - $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file); + $isVendor = self::MODE_WEAK_VENDORS === $mode && $inVendors($file); $i = \count($trace); while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { @@ -131,7 +131,7 @@ class DeprecationErrorHandler // \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest() // then we need to use the serialized information to determine // if the error has been triggered from vendor code. - $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); + $isVendor = self::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); } else { $class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class']; $method = $trace[$i]['function']; @@ -168,13 +168,13 @@ class DeprecationErrorHandler exit(1); } - if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) { + if ('legacy' !== $group && self::MODE_WEAK !== $mode) { $ref = &$deprecations[$group][$msg]['count']; ++$ref; $ref = &$deprecations[$group][$msg][$class.'::'.$method]; ++$ref; } - } elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) { + } elseif (self::MODE_WEAK !== $mode) { $ref = &$deprecations[$group][$msg]['count']; ++$ref; } @@ -184,7 +184,7 @@ class DeprecationErrorHandler if (null !== $oldErrorHandler) { restore_error_handler(); - if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) { + if ([$UtilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) { restore_error_handler(); self::register($mode); } @@ -207,7 +207,7 @@ class DeprecationErrorHandler $currErrorHandler = set_error_handler('var_dump'); restore_error_handler(); - if (DeprecationErrorHandler::MODE_WEAK === $mode) { + if (self::MODE_WEAK === $mode) { $colorize = function ($str) { return $str; }; } if ($currErrorHandler !== $deprecationHandler) { @@ -218,8 +218,8 @@ class DeprecationErrorHandler return $b['count'] - $a['count']; }; - $groups = array('unsilenced', 'remaining'); - if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) { + $groups = ['unsilenced', 'remaining']; + if (self::MODE_WEAK_VENDORS === $mode) { $groups[] = 'remaining vendor'; } array_push($groups, 'legacy', 'other'); @@ -255,11 +255,11 @@ class DeprecationErrorHandler $displayDeprecations($deprecations); // store failing status - $isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; + $isFailing = self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; // reset deprecations array foreach ($deprecations as $group => $arrayOrInt) { - $deprecations[$group] = \is_int($arrayOrInt) ? 0 : array(); + $deprecations[$group] = \is_int($arrayOrInt) ? 0 : []; } register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) { @@ -270,7 +270,7 @@ class DeprecationErrorHandler } } $displayDeprecations($deprecations); - if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { + if ($isFailing || self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { exit(1); } }); @@ -280,8 +280,8 @@ class DeprecationErrorHandler public static function collectDeprecations($outputFile) { - $deprecations = array(); - $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) { + $deprecations = []; + $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { if ($previousErrorHandler) { return $previousErrorHandler($type, $msg, $file, $line, $context); @@ -293,7 +293,7 @@ class DeprecationErrorHandler return $ErrorHandler::handleError($type, $msg, $file, $line, $context); } - $deprecations[] = array(error_reporting(), $msg, $file); + $deprecations[] = [error_reporting(), $msg, $file]; }); register_shutdown_function(function () use ($outputFile, &$deprecations) { diff --git a/src/Symfony/Bridge/PhpUnit/DnsMock.php b/src/Symfony/Bridge/PhpUnit/DnsMock.php index 790cfa91af..a58bf2efcd 100644 --- a/src/Symfony/Bridge/PhpUnit/DnsMock.php +++ b/src/Symfony/Bridge/PhpUnit/DnsMock.php @@ -16,8 +16,8 @@ namespace Symfony\Bridge\PhpUnit; */ class DnsMock { - private static $hosts = array(); - private static $dnsTypes = array( + private static $hosts = []; + private static $dnsTypes = [ 'A' => DNS_A, 'MX' => DNS_MX, 'NS' => DNS_NS, @@ -30,7 +30,7 @@ class DnsMock 'NAPTR' => DNS_NAPTR, 'TXT' => DNS_TXT, 'HINFO' => DNS_HINFO, - ); + ]; /** * Configures the mock values for DNS queries. @@ -68,7 +68,7 @@ class DnsMock if (!self::$hosts) { return \getmxrr($hostname, $mxhosts, $weight); } - $mxhosts = $weight = array(); + $mxhosts = $weight = []; if (isset(self::$hosts[$hostname])) { foreach (self::$hosts[$hostname] as $record) { @@ -125,7 +125,7 @@ class DnsMock $ips = false; if (isset(self::$hosts[$hostname])) { - $ips = array(); + $ips = []; foreach (self::$hosts[$hostname] as $record) { if ('A' === $record['type']) { @@ -149,11 +149,11 @@ class DnsMock if (DNS_ANY === $type) { $type = DNS_ALL; } - $records = array(); + $records = []; foreach (self::$hosts[$hostname] as $record) { if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) { - $records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record); + $records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record); } } } @@ -165,7 +165,7 @@ class DnsMock { $self = \get_called_class(); - $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); + $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php index 8e9bdbe92e..07a9679d13 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php @@ -31,7 +31,7 @@ class CoverageListenerTrait { $this->sutFqcnResolver = $sutFqcnResolver; $this->warningOnSutNotFound = $warningOnSutNotFound; - $this->warnings = array(); + $this->warnings = []; } public function startTest($test) @@ -42,7 +42,7 @@ class CoverageListenerTrait $annotations = $test->getAnnotations(); - $ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing'); + $ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing']; foreach ($ignoredAnnotations as $annotation) { if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) { @@ -74,11 +74,11 @@ class CoverageListenerTrait $r->setAccessible(true); $cache = $r->getValue(); - $cache = array_replace_recursive($cache, array( - \get_class($test) => array( - 'covers' => array($sutFqcn), - ), - )); + $cache = array_replace_recursive($cache, [ + \get_class($test) => [ + 'covers' => [$sutFqcn], + ], + ]); $r->setValue($testClass, $cache); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php index 2da40f2c20..c825a8ddb2 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php @@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener { private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php index 5b864bfe58..0c0b57080e 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php @@ -27,7 +27,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener { private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php index 18bbdbeba0..25ad718a80 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php @@ -30,7 +30,7 @@ class SymfonyTestsListenerForV7 implements TestListener private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index d072e7e91f..078cedd30f 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -31,10 +31,10 @@ class SymfonyTestsListenerTrait private static $globallyEnabled = false; private $state = -1; private $skippedFile = false; - private $wasSkipped = array(); - private $isSkipped = array(); - private $expectedDeprecations = array(); - private $gatheredDeprecations = array(); + private $wasSkipped = []; + private $isSkipped = []; + private $expectedDeprecations = []; + private $gatheredDeprecations = []; private $previousErrorHandler; private $testsWithWarnings; private $reportUselessTests; @@ -44,7 +44,7 @@ class SymfonyTestsListenerTrait /** * @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive) */ - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { if (class_exists('PHPUnit_Util_Blacklist')) { \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; @@ -54,7 +54,7 @@ class SymfonyTestsListenerTrait foreach ($mockedNamespaces as $type => $namespaces) { if (!\is_array($namespaces)) { - $namespaces = array($namespaces); + $namespaces = [$namespaces]; } if ('time-sensitive' === $type) { foreach ($namespaces as $ns) { @@ -95,7 +95,7 @@ class SymfonyTestsListenerTrait $Test = 'PHPUnit\Util\Test'; } $suiteName = $suite->getName(); - $this->testsWithWarnings = array(); + $this->testsWithWarnings = []; foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { @@ -126,11 +126,11 @@ class SymfonyTestsListenerTrait if (!$this->wasSkipped = require $this->skippedFile) { echo "All tests already ran successfully.\n"; - $suite->setTests(array()); + $suite->setTests([]); } } } - $testSuites = array($suite); + $testSuites = [$suite]; for ($i = 0; isset($testSuites[$i]); ++$i) { foreach ($testSuites[$i]->tests() as $test) { if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) { @@ -149,7 +149,7 @@ class SymfonyTestsListenerTrait } } } elseif (2 === $this->state) { - $skipped = array(); + $skipped = []; foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) || isset($this->wasSkipped[$suiteName]['*']) @@ -221,7 +221,7 @@ class SymfonyTestsListenerTrait $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false); $this->expectedDeprecations = $annotations['method']['expectedDeprecation']; - $this->previousErrorHandler = set_error_handler(array($this, 'handleError')); + $this->previousErrorHandler = set_error_handler([$this, 'handleError']); } } } @@ -262,8 +262,8 @@ class SymfonyTestsListenerTrait $deprecations = file_get_contents($this->runsInSeparateProcess); unlink($this->runsInSeparateProcess); putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); - foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { - $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null)); + foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { + $error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]); if ($deprecation[0]) { @trigger_error($error, E_USER_DEPRECATED); } else { @@ -274,13 +274,13 @@ class SymfonyTestsListenerTrait } if ($this->expectedDeprecations) { - if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) { + if (!\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE], true)) { $test->addToAssertionCount(\count($this->expectedDeprecations)); } restore_error_handler(); - if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) { + if (!$errored && !\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR], true)) { try { $prefix = "@expectedDeprecation:\n"; $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); @@ -291,7 +291,7 @@ class SymfonyTestsListenerTrait } } - $this->expectedDeprecations = $this->gatheredDeprecations = array(); + $this->expectedDeprecations = $this->gatheredDeprecations = []; $this->previousErrorHandler = null; } if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { @@ -299,12 +299,12 @@ class SymfonyTestsListenerTrait ClockMock::withClockMock(false); } if (\in_array('dns-sensitive', $groups, true)) { - DnsMock::withMockedHosts(array()); + DnsMock::withMockedHosts([]); } } } - public function handleError($type, $msg, $file, $line, $context = array()) + public function handleError($type, $msg, $file, $line, $context = []) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { $h = $this->previousErrorHandler; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php index 7897861cf5..1a89019fe3 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php @@ -27,7 +27,7 @@ class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner $result = parent::handleConfiguration($arguments); - $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); + $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php index 6da7c65448..8489a58627 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php @@ -30,7 +30,7 @@ class TestRunnerForV6 extends BaseRunner parent::handleConfiguration($arguments); - $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); + $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php index a175fb65d7..bc5fff95ba 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php @@ -30,7 +30,7 @@ class TestRunnerForV7 extends BaseRunner parent::handleConfiguration($arguments); - $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); + $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt index 7a0595a7dd..9bc155a7cd 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt @@ -25,7 +25,7 @@ class Test { public static function getGroups() { - return array(); + return []; } } EOPHP @@ -35,7 +35,7 @@ class PHPUnit_Util_Test { public static function getGroups() { - return array(); + return []; } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php index 16a58246d2..5229a7a7cc 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/deprecation_riddled.php @@ -7,7 +7,7 @@ class Test { public static function getGroups() { - return array(); + return []; } } EOPHP diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt index fddeed6085..703db6fd19 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt @@ -25,7 +25,7 @@ class Test { public static function getGroups() { - return array(); + return []; } } EOPHP @@ -35,7 +35,7 @@ class PHPUnit_Util_Test { public static function getGroups() { - return array(); + return []; } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_non_vendor.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_non_vendor.phpt index e20c7adf6b..b37b623cf2 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_non_vendor.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak_vendors_on_non_vendor.phpt @@ -25,7 +25,7 @@ class Test { public static function getGroups() { - return array(); + return []; } } EOPHP diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php index a178ac7e89..ebbc87a770 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php @@ -18,15 +18,15 @@ class DnsMockTest extends TestCase { protected function tearDown() { - DnsMock::withMockedHosts(array()); + DnsMock::withMockedHosts([]); } public function testCheckdnsrr() { - DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'MX')))); + DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]); $this->assertTrue(DnsMock::checkdnsrr('example.com')); - DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A')))); + DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]); $this->assertFalse(DnsMock::checkdnsrr('example.com')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'a')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'any')); @@ -35,34 +35,34 @@ class DnsMockTest extends TestCase public function testGetmxrr() { - DnsMock::withMockedHosts(array( - 'example.com' => array(array( + DnsMock::withMockedHosts([ + 'example.com' => [[ 'type' => 'MX', 'host' => 'mx.example.com', 'pri' => 10, - )), - )); + ]], + ]); $this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight)); $this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight)); - $this->assertSame(array('mx.example.com'), $mxhosts); - $this->assertSame(array(10), $weight); + $this->assertSame(['mx.example.com'], $mxhosts); + $this->assertSame([10], $weight); } public function testGethostbyaddr() { - DnsMock::withMockedHosts(array( - 'example.com' => array( - array( + DnsMock::withMockedHosts([ + 'example.com' => [ + [ 'type' => 'A', 'ip' => '1.2.3.4', - ), - array( + ], + [ 'type' => 'AAAA', 'ipv6' => '::12', - ), - ), - )); + ], + ], + ]); $this->assertSame('::21', DnsMock::gethostbyaddr('::21')); $this->assertSame('example.com', DnsMock::gethostbyaddr('::12')); @@ -71,18 +71,18 @@ class DnsMockTest extends TestCase public function testGethostbyname() { - DnsMock::withMockedHosts(array( - 'example.com' => array( - array( + DnsMock::withMockedHosts([ + 'example.com' => [ + [ 'type' => 'AAAA', 'ipv6' => '::12', - ), - array( + ], + [ 'type' => 'A', 'ip' => '1.2.3.4', - ), - ), - )); + ], + ], + ]); $this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com')); $this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com')); @@ -90,59 +90,59 @@ class DnsMockTest extends TestCase public function testGethostbynamel() { - DnsMock::withMockedHosts(array( - 'example.com' => array( - array( + DnsMock::withMockedHosts([ + 'example.com' => [ + [ 'type' => 'A', 'ip' => '1.2.3.4', - ), - array( + ], + [ 'type' => 'A', 'ip' => '2.3.4.5', - ), - ), - )); + ], + ], + ]); $this->assertFalse(DnsMock::gethostbynamel('foobar.com')); - $this->assertSame(array('1.2.3.4', '2.3.4.5'), DnsMock::gethostbynamel('example.com')); + $this->assertSame(['1.2.3.4', '2.3.4.5'], DnsMock::gethostbynamel('example.com')); } public function testDnsGetRecord() { - DnsMock::withMockedHosts(array( - 'example.com' => array( - array( + DnsMock::withMockedHosts([ + 'example.com' => [ + [ 'type' => 'A', 'ip' => '1.2.3.4', - ), - array( + ], + [ 'type' => 'PTR', 'ip' => '2.3.4.5', - ), - ), - )); + ], + ], + ]); - $records = array( - array( + $records = [ + [ 'host' => 'example.com', 'class' => 'IN', 'ttl' => 1, 'type' => 'A', 'ip' => '1.2.3.4', - ), - $ptr = array( + ], + $ptr = [ 'host' => 'example.com', 'class' => 'IN', 'ttl' => 1, 'type' => 'PTR', 'ip' => '2.3.4.5', - ), - ); + ], + ]; $this->assertFalse(DnsMock::dns_get_record('foobar.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL)); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR)); - $this->assertSame(array($ptr), DnsMock::dns_get_record('example.com', DNS_PTR)); + $this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR)); } } diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit index c94fa31abd..833eb3cdf0 100755 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit @@ -112,7 +112,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ $prevRoot = getenv('COMPOSER_ROOT_VERSION'); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS - $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true))); + $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", [], $p, getcwd(), null, ['bypass_shell' => true])); putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); if ($exit) { exit($exit); @@ -145,9 +145,9 @@ EOPHP } global $argv, $argc; -$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); +$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : []; $argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0; -$components = array(); +$components = []; $cmd = array_map('escapeshellarg', $argv); $exit = 0; @@ -182,7 +182,7 @@ if ('\\' === DIRECTORY_SEPARATOR) { if ($components) { $skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false; - $runningProcs = array(); + $runningProcs = []; foreach ($components as $component) { // Run phpunit tests in parallel @@ -193,7 +193,7 @@ if ($components) { $c = escapeshellarg($component); - if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) { + if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), [], $pipes)) { $runningProcs[$component] = $proc; } else { $exit = 1; @@ -203,7 +203,7 @@ if ($components) { while ($runningProcs) { usleep(300000); - $terminatedProcs = array(); + $terminatedProcs = []; foreach ($runningProcs as $component => $proc) { $procStatus = proc_get_status($proc); if (!$procStatus['running']) { @@ -214,7 +214,7 @@ if ($components) { } foreach ($terminatedProcs as $component => $procStatus) { - foreach (array('out', 'err') as $file) { + foreach (['out', 'err'] as $file) { $file = "$component/phpunit.std$file"; readfile($file); unlink($file); @@ -224,7 +224,7 @@ if ($components) { // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) { + if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { $exit = $procStatus; echo "\033[41mKO\033[0m $component\n\n"; } else { @@ -236,7 +236,7 @@ if ($components) { if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) { class SymfonyBlacklistSimplePhpunit {} } - array_splice($argv, 1, 0, array('--colors=always')); + array_splice($argv, 1, 0, ['--colors=always']); $_SERVER['argv'] = $argv; $_SERVER['argc'] = ++$argc; include "$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit"; diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php index 7c74641333..647d1667c3 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Dumper/PhpDumperTest.php @@ -69,6 +69,6 @@ class PhpDumperTest extends TestCase $dumper->setProxyDumper(new ProxyDumper()); - return $dumper->dump(array('class' => 'LazyServiceProjectServiceContainer')); + return $dumper->dump(['class' => 'LazyServiceProjectServiceContainer']); } } diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/foo.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/foo.php index 8ffc5be9af..435e9a4d77 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/foo.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/includes/foo.php @@ -11,14 +11,14 @@ class ProxyManagerBridgeFooClass public $initialized = false; public $configured = false; public $called = false; - public $arguments = array(); + public $arguments = []; - public function __construct($arguments = array()) + public function __construct($arguments = []) { $this->arguments = $arguments; } - public static function getInstance($arguments = array()) + public static function getInstance($arguments = []) { $obj = new self($arguments); $obj->called = true; diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index e12b25fcb0..673c2774ed 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -95,18 +95,18 @@ class ProxyDumperTest extends TestCase public function getPrivatePublicDefinitions() { - return array( - array( + return [ + [ (new Definition(__CLASS__)) ->setPublic(false), \method_exists(ContainerBuilder::class, 'addClassResource') ? 'services' : 'privates', - ), - array( + ], + [ (new Definition(__CLASS__)) ->setPublic(true), 'services', - ), - ); + ], + ]; } /** @@ -125,12 +125,12 @@ class ProxyDumperTest extends TestCase */ public function getProxyCandidates() { - $definitions = array( - array(new Definition(__CLASS__), true), - array(new Definition('stdClass'), true), - array(new Definition(uniqid('foo', true)), false), - array(new Definition(), false), - ); + $definitions = [ + [new Definition(__CLASS__), true], + [new Definition('stdClass'), true], + [new Definition(uniqid('foo', true)), false], + [new Definition(), false], + ]; array_map( function ($definition) { diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 702edcbcea..21020270a0 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -150,7 +150,7 @@ class AppVariable * Returns some or all the existing flash messages: * * getFlashes() returns all the flash messages * * getFlashes('notice') returns a simple array with flash messages of that type - * * getFlashes(array('notice', 'error')) returns a nested array of type => messages. + * * getFlashes(['notice', 'error']) returns a nested array of type => messages. * * @return array */ @@ -159,13 +159,13 @@ class AppVariable try { $session = $this->getSession(); if (null === $session) { - return array(); + return []; } } catch (\RuntimeException $e) { - return array(); + return []; } - if (null === $types || '' === $types || array() === $types) { + if (null === $types || '' === $types || [] === $types) { return $session->getFlashBag()->all(); } @@ -173,7 +173,7 @@ class AppVariable return $session->getFlashBag()->get($types); } - $result = array(); + $result = []; foreach ($types as $type) { $result[$type] = $session->getFlashBag()->get($type); } diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md index fcdb5e2756..c4a40bb6cc 100644 --- a/src/Symfony/Bridge/Twig/CHANGELOG.md +++ b/src/Symfony/Bridge/Twig/CHANGELOG.md @@ -38,7 +38,7 @@ CHANGELOG use Symfony\Bridge\Twig\Form\TwigRendererEngine; // ... - $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig')); + $rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig']); $rendererEngine->setEnvironment($twig); $twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager))); ``` @@ -47,13 +47,13 @@ CHANGELOG ```php // ... - $rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig); + $rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig); // require Twig 1.30+ - $twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array( + $twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([ TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) { return new TwigRenderer($rendererEngine, $csrfTokenManager); }, - ))); + ])); $twig->addExtension(new FormExtension()); ``` * Deprecated the `TwigRendererEngineInterface` interface. diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 68eebf123c..d2f7542af7 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -87,7 +87,7 @@ EOF $template .= fread(STDIN, 1024); } - return $this->display($input, $output, $io, array($this->validate($template, uniqid('sf_', true)))); + return $this->display($input, $output, $io, [$this->validate($template, uniqid('sf_', true))]); } $filesInfo = $this->getFilesInfo($filenames); @@ -97,7 +97,7 @@ EOF private function getFilesInfo(array $filenames) { - $filesInfo = array(); + $filesInfo = []; foreach ($filenames as $filename) { foreach ($this->findFiles($filename) as $file) { $filesInfo[] = $this->validate(file_get_contents($file), $file); @@ -110,7 +110,7 @@ EOF protected function findFiles($filename) { if (is_file($filename)) { - return array($filename); + return [$filename]; } elseif (is_dir($filename)) { return Finder::create()->files()->in($filename)->name('*.twig'); } @@ -122,7 +122,7 @@ EOF { $realLoader = $this->twig->getLoader(); try { - $temporaryLoader = new ArrayLoader(array((string) $file => $template)); + $temporaryLoader = new ArrayLoader([(string) $file => $template]); $this->twig->setLoader($temporaryLoader); $nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file))); $this->twig->compile($nodeTree); @@ -130,10 +130,10 @@ EOF } catch (Error $e) { $this->twig->setLoader($realLoader); - return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e); + return ['template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e]; } - return array('template' => $template, 'file' => $file, 'valid' => true); + return ['template' => $template, 'file' => $file, 'valid' => true]; } private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files) @@ -219,7 +219,7 @@ EOF $position = max(0, $line - $context); $max = min(\count($lines), $line - 1 + $context); - $result = array(); + $result = []; while ($position < $max) { $result[$position + 1] = $lines[$position]; ++$position; diff --git a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php index d5d70fb397..cc2cdb268e 100644 --- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php @@ -34,10 +34,10 @@ class AssetExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('asset', array($this, 'getAssetUrl')), - new TwigFunction('asset_version', array($this, 'getAssetVersion')), - ); + return [ + new TwigFunction('asset', [$this, 'getAssetUrl']), + new TwigFunction('asset_version', [$this, 'getAssetVersion']), + ]; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 5c9f7a0c86..103a894349 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -43,17 +43,17 @@ class CodeExtension extends AbstractExtension */ public function getFilters() { - return array( - new TwigFilter('abbr_class', array($this, 'abbrClass'), array('is_safe' => array('html'))), - new TwigFilter('abbr_method', array($this, 'abbrMethod'), array('is_safe' => array('html'))), - new TwigFilter('format_args', array($this, 'formatArgs'), array('is_safe' => array('html'))), - new TwigFilter('format_args_as_text', array($this, 'formatArgsAsText')), - new TwigFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))), - new TwigFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))), - new TwigFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))), - new TwigFilter('format_log_message', array($this, 'formatLogMessage'), array('is_safe' => array('html'))), - new TwigFilter('file_link', array($this, 'getFileLink')), - ); + return [ + new TwigFilter('abbr_class', [$this, 'abbrClass'], ['is_safe' => ['html']]), + new TwigFilter('abbr_method', [$this, 'abbrMethod'], ['is_safe' => ['html']]), + new TwigFilter('format_args', [$this, 'formatArgs'], ['is_safe' => ['html']]), + new TwigFilter('format_args_as_text', [$this, 'formatArgsAsText']), + new TwigFilter('file_excerpt', [$this, 'fileExcerpt'], ['is_safe' => ['html']]), + new TwigFilter('format_file', [$this, 'formatFile'], ['is_safe' => ['html']]), + new TwigFilter('format_file_from_text', [$this, 'formatFileFromText'], ['is_safe' => ['html']]), + new TwigFilter('format_log_message', [$this, 'formatLogMessage'], ['is_safe' => ['html']]), + new TwigFilter('file_link', [$this, 'getFileLink']), + ]; } public function abbrClass($class) @@ -87,7 +87,7 @@ class CodeExtension extends AbstractExtension */ public function formatArgs($args) { - $result = array(); + $result = []; foreach ($args as $key => $item) { if ('object' === $item[0]) { $parts = explode('\\', $item[1]); @@ -146,7 +146,7 @@ class CodeExtension extends AbstractExtension }, $code); $content = explode('
', $code); - $lines = array(); + $lines = []; if (0 > $srcContext) { $srcContext = \count($content); } @@ -205,7 +205,7 @@ class CodeExtension extends AbstractExtension public function getFileLink($file, $line) { if ($fmt = $this->fileLinkFormat) { - return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); + return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); } return false; @@ -224,7 +224,7 @@ class CodeExtension extends AbstractExtension public function formatLogMessage($message, array $context) { if ($context && false !== strpos($message, '{')) { - $replacements = array(); + $replacements = []; foreach ($context as $key => $val) { if (is_scalar($val)) { $replacements['{'.$key.'}'] = $val; diff --git a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php index 3d4c6841f2..88b75368da 100644 --- a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php @@ -37,14 +37,14 @@ class DumpExtension extends AbstractExtension public function getFunctions() { - return array( - new TwigFunction('dump', array($this, 'dump'), array('is_safe' => array('html'), 'needs_context' => true, 'needs_environment' => true)), - ); + return [ + new TwigFunction('dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]), + ]; } public function getTokenParsers() { - return array(new DumpTokenParser()); + return [new DumpTokenParser()]; } public function getName() @@ -59,14 +59,14 @@ class DumpExtension extends AbstractExtension } if (2 === \func_num_args()) { - $vars = array(); + $vars = []; foreach ($context as $key => $value) { if (!$value instanceof Template) { $vars[$key] = $value; } } - $vars = array($vars); + $vars = [$vars]; } else { $vars = \func_get_args(); unset($vars[0], $vars[1]); diff --git a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php index fc64fa3e37..21f6be4d6e 100644 --- a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php @@ -27,9 +27,9 @@ class ExpressionExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('expression', array($this, 'createExpression')), - ); + return [ + new TwigFunction('expression', [$this, 'createExpression']), + ]; } public function createExpression($expression) diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index fe2778393c..82b9a92f75 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -38,10 +38,10 @@ class HttpFoundationExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('absolute_url', array($this, 'generateAbsoluteUrl')), - new TwigFunction('relative_path', array($this, 'generateRelativePath')), - ); + return [ + new TwigFunction('absolute_url', [$this, 'generateAbsoluteUrl']), + new TwigFunction('relative_path', [$this, 'generateRelativePath']), + ]; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php index 45142e7402..f8b93ada15 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php @@ -24,14 +24,14 @@ class HttpKernelExtension extends AbstractExtension { public function getFunctions() { - return array( - new TwigFunction('render', array(HttpKernelRuntime::class, 'renderFragment'), array('is_safe' => array('html'))), - new TwigFunction('render_*', array(HttpKernelRuntime::class, 'renderFragmentStrategy'), array('is_safe' => array('html'))), + return [ + new TwigFunction('render', [HttpKernelRuntime::class, 'renderFragment'], ['is_safe' => ['html']]), + new TwigFunction('render_*', [HttpKernelRuntime::class, 'renderFragmentStrategy'], ['is_safe' => ['html']]), new TwigFunction('controller', static::class.'::controller'), - ); + ]; } - public static function controller($controller, $attributes = array(), $query = array()) + public static function controller($controller, $attributes = [], $query = []) { return new ControllerReference($controller, $attributes, $query); } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php index 6eea673e25..fcd7c24416 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php @@ -38,7 +38,7 @@ class HttpKernelRuntime * * @see FragmentHandler::render() */ - public function renderFragment($uri, $options = array()) + public function renderFragment($uri, $options = []) { $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); @@ -57,7 +57,7 @@ class HttpKernelRuntime * * @see FragmentHandler::render() */ - public function renderFragmentStrategy($strategy, $uri, $options = array()) + public function renderFragmentStrategy($strategy, $uri, $options = []) { return $this->handler->render($uri, $strategy, $options); } diff --git a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php index 17abb77989..e8bc6190cd 100644 --- a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php @@ -34,10 +34,10 @@ class LogoutUrlExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('logout_url', array($this, 'getLogoutUrl')), - new TwigFunction('logout_path', array($this, 'getLogoutPath')), - ); + return [ + new TwigFunction('logout_url', [$this, 'getLogoutUrl']), + new TwigFunction('logout_path', [$this, 'getLogoutPath']), + ]; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index a23a62bb28..67fbe8d391 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -39,10 +39,10 @@ class RoutingExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('url', array($this, 'getUrl'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), - new TwigFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), - ); + return [ + new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), + new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), + ]; } /** @@ -52,7 +52,7 @@ class RoutingExtension extends AbstractExtension * * @return string */ - public function getPath($name, $parameters = array(), $relative = false) + public function getPath($name, $parameters = [], $relative = false) { return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); } @@ -64,7 +64,7 @@ class RoutingExtension extends AbstractExtension * * @return string */ - public function getUrl($name, $parameters = array(), $schemeRelative = false) + public function getUrl($name, $parameters = [], $schemeRelative = false) { return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); } @@ -103,10 +103,10 @@ class RoutingExtension extends AbstractExtension if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 && (!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression) ) { - return array('html'); + return ['html']; } - return array(); + return []; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php index 193726a684..439c31aad3 100644 --- a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php @@ -53,9 +53,9 @@ class SecurityExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('is_granted', array($this, 'isGranted')), - ); + return [ + new TwigFunction('is_granted', [$this, 'isGranted']), + ]; } /** diff --git a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php index 20b0471d53..19dfed23e3 100644 --- a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php @@ -38,14 +38,14 @@ class StopwatchExtension extends AbstractExtension public function getTokenParsers() { - return array( + return [ /* * {% stopwatch foo %} * Some stuff which will be recorded on the timeline * {% endstopwatch %} */ new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled), - ); + ]; } public function getName() diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index fe1adc4a7d..4538f77198 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -48,10 +48,10 @@ class TranslationExtension extends AbstractExtension */ public function getFilters() { - return array( - new TwigFilter('trans', array($this, 'trans')), - new TwigFilter('transchoice', array($this, 'transchoice')), - ); + return [ + new TwigFilter('trans', [$this, 'trans']), + new TwigFilter('transchoice', [$this, 'transchoice']), + ]; } /** @@ -61,7 +61,7 @@ class TranslationExtension extends AbstractExtension */ public function getTokenParsers() { - return array( + return [ // {% trans %}Symfony is great!{% endtrans %} new TransTokenParser(), @@ -72,7 +72,7 @@ class TranslationExtension extends AbstractExtension // {% trans_default_domain "foobar" %} new TransDefaultDomainTokenParser(), - ); + ]; } /** @@ -80,7 +80,7 @@ class TranslationExtension extends AbstractExtension */ public function getNodeVisitors() { - return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()); + return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()]; } public function getTranslationNodeVisitor() @@ -88,7 +88,7 @@ class TranslationExtension extends AbstractExtension return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor(); } - public function trans($message, array $arguments = array(), $domain = null, $locale = null) + public function trans($message, array $arguments = [], $domain = null, $locale = null) { if (null === $this->translator) { return strtr($message, $arguments); @@ -97,13 +97,13 @@ class TranslationExtension extends AbstractExtension return $this->translator->trans($message, $arguments, $domain, $locale); } - public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null) + public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null) { if (null === $this->translator) { return strtr($message, $arguments); } - return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale); + return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale); } /** diff --git a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php index 3d90c3bf21..0ca519ee72 100644 --- a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php @@ -36,14 +36,14 @@ class WebLinkExtension extends AbstractExtension */ public function getFunctions() { - return array( - new TwigFunction('link', array($this, 'link')), - new TwigFunction('preload', array($this, 'preload')), - new TwigFunction('dns_prefetch', array($this, 'dnsPrefetch')), - new TwigFunction('preconnect', array($this, 'preconnect')), - new TwigFunction('prefetch', array($this, 'prefetch')), - new TwigFunction('prerender', array($this, 'prerender')), - ); + return [ + new TwigFunction('link', [$this, 'link']), + new TwigFunction('preload', [$this, 'preload']), + new TwigFunction('dns_prefetch', [$this, 'dnsPrefetch']), + new TwigFunction('preconnect', [$this, 'preconnect']), + new TwigFunction('prefetch', [$this, 'prefetch']), + new TwigFunction('prerender', [$this, 'prerender']), + ]; } /** @@ -51,11 +51,11 @@ class WebLinkExtension extends AbstractExtension * * @param string $uri The relation URI * @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch") - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The relation URI */ - public function link($uri, $rel, array $attributes = array()) + public function link($uri, $rel, array $attributes = []) { if (!$request = $this->requestStack->getMasterRequest()) { return $uri; @@ -76,11 +76,11 @@ class WebLinkExtension extends AbstractExtension * Preloads a resource. * * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('crossorigin' => 'use-credentials')") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']") * * @return string The path of the asset */ - public function preload($uri, array $attributes = array()) + public function preload($uri, array $attributes = []) { return $this->link($uri, 'preload', $attributes); } @@ -89,11 +89,11 @@ class WebLinkExtension extends AbstractExtension * Resolves a resource origin as early as possible. * * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function dnsPrefetch($uri, array $attributes = array()) + public function dnsPrefetch($uri, array $attributes = []) { return $this->link($uri, 'dns-prefetch', $attributes); } @@ -102,11 +102,11 @@ class WebLinkExtension extends AbstractExtension * Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation). * * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function preconnect($uri, array $attributes = array()) + public function preconnect($uri, array $attributes = []) { return $this->link($uri, 'preconnect', $attributes); } @@ -115,11 +115,11 @@ class WebLinkExtension extends AbstractExtension * Indicates to the client that it should prefetch this resource. * * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function prefetch($uri, array $attributes = array()) + public function prefetch($uri, array $attributes = []) { return $this->link($uri, 'prefetch', $attributes); } @@ -128,11 +128,11 @@ class WebLinkExtension extends AbstractExtension * Indicates to the client that it should prerender this resource . * * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function prerender($uri, array $attributes = array()) + public function prerender($uri, array $attributes = []) { return $this->link($uri, 'prerender', $attributes); } diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 88b29d7c23..3284ec5cd3 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -28,10 +28,10 @@ class YamlExtension extends AbstractExtension */ public function getFilters() { - return array( - new TwigFilter('yaml_encode', array($this, 'encode')), - new TwigFilter('yaml_dump', array($this, 'dump')), - ); + return [ + new TwigFilter('yaml_encode', [$this, 'encode']), + new TwigFilter('yaml_dump', [$this, 'dump']), + ]; } public function encode($input, $inline = 0, $dumpObjects = 0) diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php index 19c1397037..c9cf1e1689 100644 --- a/src/Symfony/Bridge/Twig/Node/DumpNode.php +++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php @@ -23,12 +23,12 @@ class DumpNode extends Node public function __construct($varPrefix, Node $values = null, int $lineno, string $tag = null) { - $nodes = array(); + $nodes = []; if (null !== $values) { $nodes['values'] = $values; } - parent::__construct($nodes, array(), $lineno, $tag); + parent::__construct($nodes, [], $lineno, $tag); $this->varPrefix = $varPrefix; } diff --git a/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php b/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php index 09262b8ca8..612bec14e5 100644 --- a/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php +++ b/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php @@ -53,7 +53,7 @@ class SearchAndRenderBlockNode extends FunctionExpression // Only insert the label into the array if it is not empty if (!twig_test_empty($label->getAttribute('value'))) { $originalVariables = $variables; - $variables = new ArrayExpression(array(), $lineno); + $variables = new ArrayExpression([], $lineno); $labelKey = new ConstantExpression('label', $lineno); if (null !== $originalVariables) { diff --git a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php index d95c63028c..3844b2124c 100644 --- a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php +++ b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php @@ -24,7 +24,7 @@ class StopwatchNode extends Node { public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0, string $tag = null) { - parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag); + parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag); } public function compile(Compiler $compiler) diff --git a/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php b/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php index 63ad1f6796..7f8024aa85 100644 --- a/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php @@ -22,7 +22,7 @@ class TransDefaultDomainNode extends Node { public function __construct(AbstractExpression $expr, int $lineno = 0, string $tag = null) { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + parent::__construct(['expr' => $expr], [], $lineno, $tag); } public function compile(Compiler $compiler) diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 7eb8d743e9..acbfa9a054 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -29,7 +29,7 @@ class TransNode extends Node { public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, int $lineno = 0, string $tag = null) { - $nodes = array('body' => $body); + $nodes = ['body' => $body]; if (null !== $domain) { $nodes['domain'] = $domain; } @@ -43,14 +43,14 @@ class TransNode extends Node $nodes['locale'] = $locale; } - parent::__construct($nodes, array(), $lineno, $tag); + parent::__construct($nodes, [], $lineno, $tag); } public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); - $defaults = new ArrayExpression(array(), -1); + $defaults = new ArrayExpression([], -1); if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof ArrayExpression) { $defaults = $this->getNode('vars'); $vars = null; @@ -109,7 +109,7 @@ class TransNode extends Node } elseif ($body instanceof TextNode) { $msg = $body->getAttribute('data'); } else { - return array($body, $vars); + return [$body, $vars]; } preg_match_all('/(?getTemplateLine()), $vars); + return [new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars]; } } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php index 59497dc961..d5bcfa8b8f 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php @@ -17,7 +17,7 @@ namespace Symfony\Bridge\Twig\NodeVisitor; class Scope { private $parent; - private $data = array(); + private $data = []; private $left = false; public function __construct(self $parent = null) diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index 6a34a037e4..5beae16dba 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -56,7 +56,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor $name = new AssignNameExpression($var, $node->getTemplateLine()); $this->scope->set('domain', new NameExpression($var, $node->getTemplateLine())); - return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine()); + return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine()); } } @@ -64,7 +64,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor return $node; } - if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) { + if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), ['trans', 'transchoice'])) { $arguments = $node->getNode('arguments'); $ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2; if ($this->isNamedArguments($arguments)) { @@ -74,7 +74,7 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor } else { if (!$arguments->hasNode($ind)) { if (!$arguments->hasNode($ind - 1)) { - $arguments->setNode($ind - 1, new ArrayExpression(array(), $node->getTemplateLine())); + $arguments->setNode($ind - 1, new ArrayExpression([], $node->getTemplateLine())); } $arguments->setNode($ind, $this->scope->get('domain')); diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index fef722be64..3da4141cdd 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -28,18 +28,18 @@ class TranslationNodeVisitor extends AbstractNodeVisitor const UNDEFINED_DOMAIN = '_undefined'; private $enabled = false; - private $messages = array(); + private $messages = []; public function enable() { $this->enabled = true; - $this->messages = array(); + $this->messages = []; } public function disable() { $this->enabled = false; - $this->messages = array(); + $this->messages = []; } public function getMessages() @@ -62,26 +62,26 @@ class TranslationNodeVisitor extends AbstractNodeVisitor $node->getNode('node') instanceof ConstantExpression ) { // extract constant nodes with a trans filter - $this->messages[] = array( + $this->messages[] = [ $node->getNode('node')->getAttribute('value'), $this->getReadDomainFromArguments($node->getNode('arguments'), 1), - ); + ]; } elseif ( $node instanceof FilterExpression && 'transchoice' === $node->getNode('filter')->getAttribute('value') && $node->getNode('node') instanceof ConstantExpression ) { // extract constant nodes with a trans filter - $this->messages[] = array( + $this->messages[] = [ $node->getNode('node')->getAttribute('value'), $this->getReadDomainFromArguments($node->getNode('arguments'), 2), - ); + ]; } elseif ($node instanceof TransNode) { // extract trans nodes - $this->messages[] = array( + $this->messages[] = [ $node->getNode('body')->getAttribute('data'), $node->hasNode('domain') ? $this->getReadDomainFromNode($node->getNode('domain')) : null, - ); + ]; } return $node; diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index a9389dd82a..53b84b2d1b 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -32,10 +32,10 @@ class AppVariableTest extends TestCase public function debugDataProvider() { - return array( - 'debug on' => array(true), - 'debug off' => array(false), - ); + return [ + 'debug on' => [true], + 'debug off' => [false], + ]; } public function testEnvironment() @@ -165,7 +165,7 @@ class AppVariableTest extends TestCase { $this->setRequestStack(null); - $this->assertEquals(array(), $this->appVariable->getFlashes()); + $this->assertEquals([], $this->appVariable->getFlashes()); } /** @@ -189,15 +189,15 @@ class AppVariableTest extends TestCase $this->assertEquals($flashMessages, $this->appVariable->getFlashes('')); $flashMessages = $this->setFlashMessages(); - $this->assertEquals($flashMessages, $this->appVariable->getFlashes(array())); + $this->assertEquals($flashMessages, $this->appVariable->getFlashes([])); $flashMessages = $this->setFlashMessages(); - $this->assertEquals(array(), $this->appVariable->getFlashes('this-does-not-exist')); + $this->assertEquals([], $this->appVariable->getFlashes('this-does-not-exist')); $flashMessages = $this->setFlashMessages(); $this->assertEquals( - array('this-does-not-exist' => array()), - $this->appVariable->getFlashes(array('this-does-not-exist')) + ['this-does-not-exist' => []], + $this->appVariable->getFlashes(['this-does-not-exist']) ); $flashMessages = $this->setFlashMessages(); @@ -205,31 +205,31 @@ class AppVariableTest extends TestCase $flashMessages = $this->setFlashMessages(); $this->assertEquals( - array('notice' => $flashMessages['notice']), - $this->appVariable->getFlashes(array('notice')) + ['notice' => $flashMessages['notice']], + $this->appVariable->getFlashes(['notice']) ); $flashMessages = $this->setFlashMessages(); $this->assertEquals( - array('notice' => $flashMessages['notice'], 'this-does-not-exist' => array()), - $this->appVariable->getFlashes(array('notice', 'this-does-not-exist')) + ['notice' => $flashMessages['notice'], 'this-does-not-exist' => []], + $this->appVariable->getFlashes(['notice', 'this-does-not-exist']) ); $flashMessages = $this->setFlashMessages(); $this->assertEquals( - array('notice' => $flashMessages['notice'], 'error' => $flashMessages['error']), - $this->appVariable->getFlashes(array('notice', 'error')) + ['notice' => $flashMessages['notice'], 'error' => $flashMessages['error']], + $this->appVariable->getFlashes(['notice', 'error']) ); $this->assertEquals( - array('warning' => $flashMessages['warning']), - $this->appVariable->getFlashes(array('warning')), + ['warning' => $flashMessages['warning']], + $this->appVariable->getFlashes(['warning']), 'After getting some flash types (e.g. "notice" and "error"), the rest of flash messages must remain (e.g. "warning").' ); $this->assertEquals( - array('this-does-not-exist' => array()), - $this->appVariable->getFlashes(array('this-does-not-exist')) + ['this-does-not-exist' => []], + $this->appVariable->getFlashes(['this-does-not-exist']) ); } @@ -254,11 +254,11 @@ class AppVariableTest extends TestCase private function setFlashMessages($sessionHasStarted = true) { - $flashMessages = array( - 'notice' => array('Notice #1 message'), - 'warning' => array('Warning #1 message'), - 'error' => array('Error #1 message', 'Error #2 message'), - ); + $flashMessages = [ + 'notice' => ['Notice #1 message'], + 'warning' => ['Warning #1 message'], + 'error' => ['Error #1 message', 'Error #2 message'], + ]; $flashBag = new FlashBag(); $flashBag->initialize($flashMessages); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 39b0d0df5a..a3569b5602 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -23,7 +23,7 @@ class DebugCommandTest extends TestCase public function testDebugCommand() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array(), array('decorated' => false)); + $ret = $tester->execute([], ['decorated' => false]); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Functions', trim($tester->getDisplay())); @@ -33,12 +33,12 @@ class DebugCommandTest extends TestCase { // these paths aren't realistic, // they're configured to force the line separator - $tester = $this->createCommandTester(array( - 'Acme' => array('extractor', 'extractor'), - '!Acme' => array('extractor', 'extractor'), - FilesystemLoader::MAIN_NAMESPACE => array('extractor', 'extractor'), - )); - $ret = $tester->execute(array(), array('decorated' => false)); + $tester = $this->createCommandTester([ + 'Acme' => ['extractor', 'extractor'], + '!Acme' => ['extractor', 'extractor'], + FilesystemLoader::MAIN_NAMESPACE => ['extractor', 'extractor'], + ]); + $ret = $tester->execute([], ['decorated' => false]); $ds = \DIRECTORY_SEPARATOR; $loaderPaths = <<assertContains($loaderPaths, trim($tester->getDisplay(true))); } - private function createCommandTester(array $paths = array()) + private function createCommandTester(array $paths = []) { - $filesystemLoader = new FilesystemLoader(array(), \dirname(__DIR__).'/Fixtures'); + $filesystemLoader = new FilesystemLoader([], \dirname(__DIR__).'/Fixtures'); foreach ($paths as $namespace => $relDirs) { foreach ($relDirs as $relDir) { $filesystemLoader->addPath($relDir, $namespace); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php index 97311b38a9..9131216182 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php @@ -17,7 +17,7 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); + $this->renderWidget($view, ['label' => 'foo']); $html = $this->renderLabel($view); $this->assertMatchesXpath($html, @@ -31,11 +31,11 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testLabelDoesNotRenderFieldAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -48,11 +48,11 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testLabelWithCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -65,11 +65,11 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), 'Custom label', array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), 'Custom label', [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -82,14 +82,14 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + ]); + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -102,10 +102,10 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testStartTag() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )); + ]); $html = $this->renderStart($form->createView()); @@ -114,25 +114,25 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testStartTagWithOverriddenVars() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'put', 'action' => 'http://example.com/directory', - )); + ]); - $html = $this->renderStart($form->createView(), array( + $html = $this->renderStart($form->createView(), [ 'method' => 'post', 'action' => 'http://foo.com/directory', - )); + ]); $this->assertSame('
', $html); } public function testStartTagForMultipartForm() { - $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )) + ]) ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType') ->getForm(); @@ -143,14 +143,14 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 public function testStartTagWithExtraAttributes() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )); + ]); - $html = $this->renderStart($form->createView(), array( - 'attr' => array('class' => 'foobar'), - )); + $html = $this->renderStart($form->createView(), [ + 'attr' => ['class' => 'foobar'], + ]); $this->assertSame('', $html); } @@ -159,7 +159,7 @@ abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3 { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType'); $view = $form->createView(); - $html = $this->renderRow($view, array('label' => 'foo')); + $html = $this->renderRow($view, ['label' => 'foo']); $this->assertMatchesXpath($html, '/div[@class="form-group"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index 87d0b7677f..93f0dca0a9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -20,7 +20,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); + $this->renderWidget($view, ['label' => 'foo']); $html = $this->renderLabel($view); $this->assertMatchesXpath($html, @@ -34,11 +34,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testLabelDoesNotRenderFieldAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -51,11 +51,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testLabelWithCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -68,11 +68,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), 'Custom label', array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), 'Custom label', [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -85,14 +85,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + ]); + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -175,7 +175,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="checkbox"] [ @@ -193,7 +193,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="checkbox"] [ @@ -209,11 +209,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testCheckboxWithValue() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, [ 'value' => 'foo&bar', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="checkbox"] [ @@ -229,13 +229,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoice() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -251,14 +251,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceAttributesWithMainAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => false, - 'attr' => array('class' => 'bar&baz'), - )); + 'attr' => ['class' => 'bar&baz'], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'bar&baz')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], '/select [@name="name"] [@class="bar&baz form-control"] @@ -274,14 +274,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleExpandedChoiceAttributesWithMainAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => true, - 'attr' => array('class' => 'bar&baz'), - )); + 'attr' => ['class' => 'bar&baz'], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'bar&baz')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'bar&baz']], '/div [@class="bar&baz"] [ @@ -311,14 +311,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSelectWithSizeBiggerThanOneCanBeRequired() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'choices' => array('a', 'b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, [ + 'choices' => ['a', 'b'], 'multiple' => false, 'expanded' => false, - 'attr' => array('size' => 2), - )); + 'attr' => ['size' => 2], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => '')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => '']], '/select [@name="name"] [@required="required"] @@ -330,14 +330,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => false, 'choice_translation_domain' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -353,16 +353,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceWithPlaceholderWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => false, 'required' => false, 'translation_domain' => false, 'placeholder' => 'Placeholder&Not&Translated', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -379,14 +379,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'choice_attr' => ['Choice&B' => ['class' => 'foo&bar']], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -402,14 +402,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceWithPreferred() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'preferred_choices' => array('&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'preferred_choices' => ['&b'], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '-- sep --', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '-- sep --', 'attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -426,14 +426,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceWithPreferredAndNoSeparator() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'preferred_choices' => array('&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'preferred_choices' => ['&b'], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => null, 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['separator' => null, 'attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -449,14 +449,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceWithPreferredAndBlankSeparator() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'preferred_choices' => array('&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'preferred_choices' => ['&b'], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['separator' => '', 'attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -473,14 +473,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testChoiceWithOnlyPreferred() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'preferred_choices' => array('&a', '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'preferred_choices' => ['&a', '&b'], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@class="my&class form-control"] [count(./option)=2] @@ -490,14 +490,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => false, 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -514,14 +514,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceNonRequiredNoneSelected() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => false, 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -538,15 +538,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceNonRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => false, 'required' => false, 'placeholder' => 'Select&Anything&Not&Me', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -563,15 +563,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceRequiredWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => true, 'multiple' => false, 'expanded' => false, 'placeholder' => 'Test&Me', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -588,14 +588,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceRequiredWithPlaceholderViaView() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => true, 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('placeholder' => '', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['placeholder' => '', 'attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -612,16 +612,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceGrouped() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array( - 'Group&1' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'Group&2' => array('Choice&C' => '&c'), - ), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => [ + 'Group&1' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'Group&2' => ['Choice&C' => '&c'], + ], 'multiple' => false, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -643,14 +643,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoice() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => true, 'multiple' => true, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name[]"] [@class="my&class form-control"] @@ -667,15 +667,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'choice_attr' => ['Choice&B' => ['class' => 'foo&bar']], 'required' => true, 'multiple' => true, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name[]"] [@class="my&class form-control"] @@ -692,14 +692,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceSkipsPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => true, 'expanded' => false, 'placeholder' => 'Test&Me', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name[]"] [@class="my&class form-control"] @@ -715,14 +715,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceNonRequired() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'required' => false, 'multiple' => true, 'expanded' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name[]"] [@class="my&class form-control"] @@ -738,13 +738,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -773,14 +773,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithLabelsAsFalse() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'choice_label' => false, 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -807,8 +807,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithLabelsSetByCallable() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'], 'choice_label' => function ($choice, $label, $value) { if ('&b' === $choice) { return false; @@ -818,9 +818,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest }, 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -857,16 +857,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithLabelsSetFalseByCallable() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'choice_label' => function () { return false; }, 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -893,14 +893,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => true, 'choice_translation_domain' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -929,14 +929,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + 'choice_attr' => ['Choice&B' => ['class' => 'foo&bar']], 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -965,15 +965,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => true, 'placeholder' => 'Test&Me', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1011,16 +1011,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'multiple' => false, 'expanded' => true, 'required' => false, 'choice_translation_domain' => false, 'placeholder' => 'Placeholder&Not&Translated', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1058,13 +1058,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testSingleChoiceExpandedWithBooleanValue() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( - 'choices' => array('Choice&A' => '1', 'Choice&B' => '0'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, [ + 'choices' => ['Choice&A' => '1', 'Choice&B' => '0'], 'multiple' => false, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1093,14 +1093,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpanded() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a', '&c'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'], 'multiple' => true, 'expanded' => true, 'required' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1138,14 +1138,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpandedWithLabelsAsFalse() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'choice_label' => false, 'multiple' => true, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1172,8 +1172,8 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpandedWithLabelsSetByCallable() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'], 'choice_label' => function ($choice, $label, $value) { if ('&b' === $choice) { return false; @@ -1183,9 +1183,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest }, 'multiple' => true, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1222,16 +1222,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], 'choice_label' => function () { return false; }, 'multiple' => true, 'expanded' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1258,15 +1258,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpandedWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a', '&c'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'], 'multiple' => true, 'expanded' => true, 'required' => true, 'choice_translation_domain' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1304,15 +1304,15 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMultipleChoiceExpandedAttributes() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), - 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', ['&a', '&c'], [ + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'], + 'choice_attr' => ['Choice&B' => ['class' => 'foo&bar']], 'multiple' => true, 'expanded' => true, 'required' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array(), + $this->assertWidgetMatchesXpath($form->createView(), [], '/div [ ./div @@ -1352,7 +1352,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -1364,12 +1364,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testCountryWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CountryType', 'AT', [ 'placeholder' => 'Select&Country', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -1382,12 +1382,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTime() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', [ 'input' => 'string', 'with_seconds' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [ ./select @@ -1418,13 +1418,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', null, [ 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1456,14 +1456,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeWithHourAndMinute() { - $data = array('year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); + $data = ['year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5']; - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, [ 'input' => 'array', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1495,12 +1495,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', [ 'input' => 'string', 'with_seconds' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1536,13 +1536,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeSingleText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ 'input' => 'string', 'date_widget' => 'single_text', 'time_widget' => 'single_text', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1565,14 +1565,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeWithWidgetSingleText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ 'input' => 'string', 'widget' => 'single_text', 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="datetime-local"] [@name="name"] @@ -1584,16 +1584,16 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ 'input' => 'string', 'date_widget' => 'choice', 'time_widget' => 'choice', 'widget' => 'single_text', 'model_timezone' => 'UTC', 'view_timezone' => 'UTC', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="datetime-local"] [@name="name"] @@ -1605,12 +1605,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateChoice() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', [ 'input' => 'string', 'widget' => 'choice', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1634,14 +1634,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateChoiceWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, [ 'input' => 'string', 'widget' => 'choice', 'placeholder' => 'Change&Me', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1665,14 +1665,14 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateChoiceWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', null, [ 'input' => 'string', 'widget' => 'choice', 'required' => false, - 'placeholder' => array('year' => 'Change&Me'), - )); + 'placeholder' => ['year' => 'Change&Me'], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1696,12 +1696,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', [ 'input' => 'string', 'widget' => 'text', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1728,12 +1728,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDateSingleText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', [ 'input' => 'string', 'widget' => 'single_text', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="date"] [@name="name"] @@ -1745,11 +1745,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testBirthDay() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '2000-02-03', [ 'input' => 'string', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1773,13 +1773,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testBirthDayWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType', '1950-01-01', [ 'input' => 'string', 'placeholder' => '', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -1808,7 +1808,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="email"] [@name="name"] @@ -1821,11 +1821,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testEmailWithMaxLength() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', [ + 'attr' => ['maxlength' => 123], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="email"] [@name="name"] @@ -1840,7 +1840,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\HiddenType', 'foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="hidden"] [@name="name"] @@ -1852,11 +1852,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testDisabled() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ 'disabled' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="text"] [@name="name"] @@ -1870,7 +1870,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', 123); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="number"] [@name="name"] @@ -1884,7 +1884,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LanguageType', 'de'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -1898,7 +1898,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\LocaleType', 'de_AT'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -1910,11 +1910,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMoney() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, [ 'currency' => 'EUR', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="input-group"] [ @@ -1934,11 +1934,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testMoneyWithoutCurrency() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, [ 'currency' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/input [@id="my&id"] [@type="text"] @@ -1955,7 +1955,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="text"] [@name="name"] @@ -1969,7 +1969,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="password"] [@name="name"] @@ -1980,12 +1980,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testPasswordSubmittedWithNotAlwaysEmpty() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, [ 'always_empty' => false, - )); + ]); $form->submit('foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="password"] [@name="name"] @@ -1997,11 +1997,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testPasswordWithMaxLength() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', [ + 'attr' => ['maxlength' => 123], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="password"] [@name="name"] @@ -2015,7 +2015,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="input-group"] [ @@ -2037,7 +2037,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="radio"] [ @@ -2061,7 +2061,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="radio"] [ @@ -2082,11 +2082,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testRadioWithValue() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, [ 'value' => 'foo&bar', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['id' => 'my&id', 'attr' => ['class' => 'my&class']], '/div [@class="radio"] [ @@ -2107,9 +2107,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testRange() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="range"] [@name="name"] @@ -2122,9 +2122,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testRangeWithMinMaxValues() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, array('attr' => array('min' => 5, 'max' => 57))); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5, 'max' => 57]]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="range"] [@name="name"] @@ -2138,11 +2138,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTextarea() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', array( - 'attr' => array('pattern' => 'foo'), - )); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', [ + 'attr' => ['pattern' => 'foo'], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/textarea [@name="name"] [@pattern="foo"] @@ -2156,7 +2156,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="text"] [@name="name"] @@ -2169,11 +2169,11 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTextWithMaxLength() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', [ + 'attr' => ['maxlength' => 123], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="text"] [@name="name"] @@ -2188,7 +2188,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="search"] [@name="name"] @@ -2201,12 +2201,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTime() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', [ 'input' => 'string', 'with_seconds' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -2228,12 +2228,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimeWithSeconds() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', [ 'input' => 'string', 'with_seconds' => true, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -2263,12 +2263,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimeText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', [ 'input' => 'string', 'widget' => 'text', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -2296,12 +2296,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimeSingleText() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', '04:05:06', [ 'input' => 'string', 'widget' => 'single_text', - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="time"] [@name="name"] @@ -2314,13 +2314,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimeWithPlaceholderGlobal() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, [ 'input' => 'string', 'placeholder' => 'Change&Me', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -2341,13 +2341,13 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimeWithPlaceholderOnYear() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimeType', null, [ 'input' => 'string', 'required' => false, - 'placeholder' => array('hour' => 'Change&Me'), - )); + 'placeholder' => ['hour' => 'Change&Me'], + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/div [@class="my&class form-inline"] [ @@ -2370,7 +2370,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', 'Europe/Vienna'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@name="name"] [@class="my&class form-control"] @@ -2387,12 +2387,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testTimezoneWithPlaceholder() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TimezoneType', null, [ 'placeholder' => 'Select&Timezone', 'required' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@class="my&class form-control"] [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] @@ -2407,7 +2407,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="url"] [@name="name"] @@ -2421,18 +2421,18 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"][@class="my&class btn"]' ); } public function testButtonlabelWithoutTranslation() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, [ 'translation_domain' => false, - )); + ]); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/button[@type="button"][@name="name"][.="Name"][@class="my&class btn"]' ); } @@ -2441,7 +2441,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SubmitType'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/button[@type="submit"][@name="name"][@class="my&class btn"]' ); } @@ -2450,18 +2450,18 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ResetType'); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/button[@type="reset"][@name="name"][@class="my&class btn"]' ); } public function testWidgetAttributes() { - $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [ 'required' => true, 'disabled' => true, - 'attr' => array('readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), - )); + 'attr' => ['readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'], + ]); $html = $this->renderWidget($form->createView()); @@ -2471,9 +2471,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testWidgetAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', array( - 'attr' => array('foo' => true), - )); + $form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [ + 'attr' => ['foo' => true], + ]); $html = $this->renderWidget($form->createView()); @@ -2483,10 +2483,10 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testButtonAttributes() { - $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, [ 'disabled' => true, - 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), - )); + 'attr' => ['class' => 'foobar', 'data-foo' => 'bar'], + ]); $html = $this->renderWidget($form->createView()); @@ -2496,9 +2496,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testButtonAttributeNameRepeatedIfTrue() { - $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( - 'attr' => array('foo' => true), - )); + $form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, [ + 'attr' => ['foo' => true], + ]); $html = $this->renderWidget($form->createView()); @@ -2511,7 +2511,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest $tel = '0102030405'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TelType', $tel); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="tel"] [@name="name"] @@ -2526,7 +2526,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest $color = '#0000ff'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ColorType', $color); - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="color"] [@name="name"] diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php index 588c9a422b..d84a4431cd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php @@ -49,7 +49,7 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); + $this->renderWidget($view, ['label' => 'foo']); $html = $this->renderLabel($view); $this->assertMatchesXpath($html, @@ -63,11 +63,11 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testLabelDoesNotRenderFieldAttributes() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -80,11 +80,11 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testLabelWithCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -97,11 +97,11 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); - $html = $this->renderLabel($form->createView(), 'Custom label', array( - 'label_attr' => array( + $html = $this->renderLabel($form->createView(), 'Custom label', [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -114,14 +114,14 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( + ]); + $html = $this->renderLabel($form->createView(), null, [ + 'label_attr' => [ 'class' => 'my&class', - ), - )); + ], + ]); $this->assertMatchesXpath($html, '/label @@ -134,11 +134,11 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testLegendOnExpandedType() { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, [ 'label' => 'Custom label', 'expanded' => true, - 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), - )); + 'choices' => ['Choice&A' => '&a', 'Choice&B' => '&b'], + ]); $view = $form->createView(); $this->renderWidget($view); $html = $this->renderLabel($view); @@ -153,10 +153,10 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testStartTag() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )); + ]); $html = $this->renderStart($form->createView()); @@ -165,25 +165,25 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testStartTagWithOverriddenVars() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'put', 'action' => 'http://example.com/directory', - )); + ]); - $html = $this->renderStart($form->createView(), array( + $html = $this->renderStart($form->createView(), [ 'method' => 'post', 'action' => 'http://foo.com/directory', - )); + ]); $this->assertSame('', $html); } public function testStartTagForMultipartForm() { - $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )) + ]) ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType') ->getForm(); @@ -194,14 +194,14 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 public function testStartTagWithExtraAttributes() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => 'http://example.com/directory', - )); + ]); - $html = $this->renderStart($form->createView(), array( - 'attr' => array('class' => 'foobar'), - )); + $html = $this->renderStart($form->createView(), [ + 'attr' => ['class' => 'foobar'], + ]); $this->assertSame('', $html); } @@ -210,7 +210,7 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4 { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType'); $view = $form->createView(); - $html = $this->renderRow($view, array('label' => 'foo')); + $html = $this->renderRow($view, ['label' => 'foo']); $this->assertMatchesXpath($html, '/div[@class="form-group row"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php index 336991c6ca..a637117f09 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php @@ -41,20 +41,20 @@ class CodeExtensionTest extends TestCase public function getClassNameProvider() { - return array( - array('F\Q\N\Foo', 'Foo'), - array('Bare', 'Bare'), - ); + return [ + ['F\Q\N\Foo', 'Foo'], + ['Bare', 'Bare'], + ]; } public function getMethodNameProvider() { - return array( - array('F\Q\N\Foo::Method', 'Foo::Method()'), - array('Bare::Method', 'Bare::Method()'), - array('Closure', 'Closure'), - array('Method', 'Method()'), - ); + return [ + ['F\Q\N\Foo::Method', 'Foo::Method()'], + ['Bare::Method', 'Bare::Method()'], + ['Closure', 'Closure'], + ['Method', 'Method()'], + ]; } public function testGetName() diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 1522928a6c..273ca922d6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -27,11 +27,11 @@ class DumpExtensionTest extends TestCase public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) { $extension = new DumpExtension(new VarCloner()); - $twig = new Environment(new ArrayLoader(array('template' => $template)), array( + $twig = new Environment(new ArrayLoader(['template' => $template]), [ 'debug' => $debug, 'cache' => false, 'optimizations' => 0, - )); + ]); $twig->addExtension($extension); $dumped = null; @@ -54,11 +54,11 @@ class DumpExtensionTest extends TestCase public function getDumpTags() { - return array( - array('A{% dump %}B', true, 'AB', array()), - array('A{% set foo="bar"%}B{% dump %}C', true, 'ABC', array('foo' => 'bar')), - array('A{% dump %}B', false, 'AB', null), - ); + return [ + ['A{% dump %}B', true, 'AB', []], + ['A{% set foo="bar"%}B{% dump %}C', true, 'ABC', ['foo' => 'bar']], + ['A{% dump %}B', false, 'AB', null], + ]; } /** @@ -67,16 +67,16 @@ class DumpExtensionTest extends TestCase public function testDump($context, $args, $expectedOutput, $debug = true) { $extension = new DumpExtension(new VarCloner()); - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array( + $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [ 'debug' => $debug, 'cache' => false, 'optimizations' => 0, - )); + ]); array_unshift($args, $context); array_unshift($args, $twig); - $dump = \call_user_func_array(array($extension, 'dump'), $args); + $dump = \call_user_func_array([$extension, 'dump'], $args); if ($debug) { $this->assertStringStartsWith('\n"), - array( - array(), - array(123, 456), + return [ + [[], [], '', false], + [[], [], "
[]\n
\n"], + [ + [], + [123, 456], "
123\n
\n" ."
456\n
\n", - ), - array( - array('foo' => 'bar'), - array(), + ], + [ + ['foo' => 'bar'], + [], "
array:1 [\n"
                 ."  \"foo\" => \"bar\"\n"
                 ."]\n"
                 ."
\n", - ), - ); + ], + ]; } public function testCustomDumper() @@ -123,13 +123,13 @@ class DumpExtensionTest extends TestCase '' ); $extension = new DumpExtension(new VarCloner(), $dumper); - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array( + $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [ 'debug' => true, 'cache' => false, 'optimizations' => 0, - )); + ]); - $dump = $extension->dump($twig, array(), 'foo'); + $dump = $extension->dump($twig, [], 'foo'); $dump = preg_replace('/sf-dump-\d+/', 'sf-dump', $dump); $this->assertEquals( diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php index b2ee22c6a9..bfb9c578bb 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/ExpressionExtensionTest.php @@ -21,7 +21,7 @@ class ExpressionExtensionTest extends TestCase public function testExpressionCreation() { $template = "{{ expression('1 == 1') }}"; - $twig = new Environment(new ArrayLoader(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); + $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); $twig->addExtension(new ExpressionExtension()); $output = $twig->render('template'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php index b7d011b599..5ef9e61b60 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php @@ -15,12 +15,12 @@ use Symfony\Component\Translation\TranslatorInterface; class StubTranslator implements TranslatorInterface { - public function trans($id, array $parameters = array(), $domain = null, $locale = null) + public function trans($id, array $parameters = [], $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } - public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) + public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index 5c82a00fcb..384b9391cc 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -24,9 +24,9 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori { use RuntimeLoaderProvider; - protected $testableFeatures = array( + protected $testableFeatures = [ 'choice_attr', - ); + ]; /** * @var FormRenderer @@ -37,32 +37,32 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_3_horizontal_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -78,27 +78,27 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index c6a946494e..2e75e3f7a8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -33,29 +33,29 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -64,10 +64,10 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); @@ -76,18 +76,18 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader(array( + $environment = new Environment(new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )), array('strict_variables' => true)); + ]), ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_3_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); @@ -104,15 +104,15 @@ HTML , trim($this->renderWidget($view))); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -128,27 +128,27 @@ HTML return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index a356921509..243658764c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -29,9 +29,9 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori { use RuntimeLoaderProvider; - protected $testableFeatures = array( + protected $testableFeatures = [ 'choice_attr', - ); + ]; private $renderer; @@ -39,32 +39,32 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_4_horizontal_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -80,27 +80,27 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index fdf9c7a5ab..a0290a2049 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -37,29 +37,29 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_4_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -68,10 +68,10 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); @@ -80,18 +80,18 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader(array( + $environment = new Environment(new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )), array('strict_variables' => true)); + ]), ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'bootstrap_4_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); @@ -108,15 +108,15 @@ HTML , trim($this->renderWidget($view))); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -132,27 +132,27 @@ HTML return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index fa97b4c0a3..18ab06884e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -35,22 +35,22 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); // the value can be any template that exists $environment->addGlobal('dynamic_template_name', 'child_label'); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'form_div_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } @@ -62,7 +62,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest ->createView() ; - $this->setTheme($view, array('theme_use.html.twig')); + $this->setTheme($view, ['theme_use.html.twig']); $this->assertMatchesXpath( $this->renderWidget($view), @@ -77,7 +77,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest ->createView() ; - $this->setTheme($view, array('theme_extends.html.twig')); + $this->setTheme($view, ['theme_extends.html.twig']); $this->assertMatchesXpath( $this->renderWidget($view), @@ -92,7 +92,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest ->createView() ; - $this->renderer->setTheme($view, array('page_dynamic_extends.html.twig')); + $this->renderer->setTheme($view, ['page_dynamic_extends.html.twig']); $this->assertMatchesXpath( $this->renderer->searchAndRenderBlock($view, 'row'), '/div/label[text()="child"]' @@ -101,18 +101,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function isSelectedChoiceProvider() { - return array( - array(true, '0', '0'), - array(true, '1', '1'), - array(true, '', ''), - array(true, '1.23', '1.23'), - array(true, 'foo', 'foo'), - array(true, 'foo10', 'foo10'), - array(true, 'foo', array(1, 'foo', 'foo10')), + return [ + [true, '0', '0'], + [true, '1', '1'], + [true, '', ''], + [true, '1.23', '1.23'], + [true, 'foo', 'foo'], + [true, 'foo10', 'foo10'], + [true, 'foo', [1, 'foo', 'foo10']], - array(false, 10, array(1, 'foo', 'foo10')), - array(false, 0, array(1, 'foo', 'foo10')), - ); + [false, 10, [1, 'foo', 'foo10']], + [false, 0, [1, 'foo', 'foo10']], + ]; } /** @@ -127,10 +127,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -139,10 +139,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); @@ -151,10 +151,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function isRootFormProvider() { - return array( - array(true, new FormView()), - array(false, new FormView(new FormView())), - ); + return [ + [true, new FormView()], + [false, new FormView(new FormView())], + ]; } /** @@ -167,18 +167,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader(array( + $environment = new Environment(new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )), array('strict_variables' => true)); + ]), ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addExtension(new FormExtension()); $environment->setCharset('ISO-8859-1'); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'form_div_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); @@ -190,15 +190,15 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest $this->assertSame('€ ', $this->renderWidget($view)); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -214,27 +214,27 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } @@ -246,15 +246,15 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public static function themeBlockInheritanceProvider() { - return array( - array(array('theme.html.twig')), - ); + return [ + [['theme.html.twig']], + ]; } public static function themeInheritanceProvider() { - return array( - array(array('parent_label.html.twig'), array('child_label.html.twig')), - ); + return [ + [['parent_label.html.twig'], ['child_label.html.twig']], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index f0868d212d..50ac1e573d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -34,30 +34,30 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest { parent::setUp(); - $loader = new StubFilesystemLoader(array( + $loader = new StubFilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', - )); + ]); - $environment = new Environment($loader, array('strict_variables' => true)); + $environment = new Environment($loader, ['strict_variables' => true]); $environment->addExtension(new TranslationExtension(new StubTranslator())); $environment->addGlobal('global', ''); $environment->addExtension(new FormExtension()); - $rendererEngine = new TwigRendererEngine(array( + $rendererEngine = new TwigRendererEngine([ 'form_table_layout.html.twig', 'custom_widgets.html.twig', - ), $environment); + ], $environment); $this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock()); $this->registerTwigRuntimeLoader($environment, $this->renderer); } public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -66,25 +66,25 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); $this->assertSame('', $html); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form', $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { if (null !== $label) { - $vars += array('label' => $label); + $vars += ['label' => $label]; } return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); @@ -100,27 +100,27 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_start', $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->renderer->renderBlock($view, 'form_end', $vars); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index dcabc5739b..38ee375b94 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -33,25 +33,25 @@ class HttpFoundationExtensionTest extends TestCase public function getGenerateAbsoluteUrlData() { - return array( - array('http://localhost/foo.png', '/foo.png', '/foo/bar.html'), - array('http://localhost/foo/foo.png', 'foo.png', '/foo/bar.html'), - array('http://localhost/foo/foo.png', 'foo.png', '/foo/bar'), - array('http://localhost/foo/bar/foo.png', 'foo.png', '/foo/bar/'), + return [ + ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], + ['http://localhost/foo/foo.png', 'foo.png', '/foo/bar.html'], + ['http://localhost/foo/foo.png', 'foo.png', '/foo/bar'], + ['http://localhost/foo/bar/foo.png', 'foo.png', '/foo/bar/'], - array('http://example.com/baz', 'http://example.com/baz', '/'), - array('https://example.com/baz', 'https://example.com/baz', '/'), - array('//example.com/baz', '//example.com/baz', '/'), + ['http://example.com/baz', 'http://example.com/baz', '/'], + ['https://example.com/baz', 'https://example.com/baz', '/'], + ['//example.com/baz', '//example.com/baz', '/'], - array('http://localhost/foo/bar?baz', '?baz', '/foo/bar'), - array('http://localhost/foo/bar?baz=1', '?baz=1', '/foo/bar?foo=1'), - array('http://localhost/foo/baz?baz=1', 'baz?baz=1', '/foo/bar?foo=1'), + ['http://localhost/foo/bar?baz', '?baz', '/foo/bar'], + ['http://localhost/foo/bar?baz=1', '?baz=1', '/foo/bar?foo=1'], + ['http://localhost/foo/baz?baz=1', 'baz?baz=1', '/foo/bar?foo=1'], - array('http://localhost/foo/bar#baz', '#baz', '/foo/bar'), - array('http://localhost/foo/bar?0#baz', '#baz', '/foo/bar?0'), - array('http://localhost/foo/bar?baz=1#baz', '?baz=1#baz', '/foo/bar?foo=1'), - array('http://localhost/foo/baz?baz=1#baz', 'baz?baz=1#baz', '/foo/bar?foo=1'), - ); + ['http://localhost/foo/bar#baz', '#baz', '/foo/bar'], + ['http://localhost/foo/bar?0#baz', '#baz', '/foo/bar?0'], + ['http://localhost/foo/bar?baz=1#baz', '?baz=1#baz', '/foo/bar?foo=1'], + ['http://localhost/foo/baz?baz=1#baz', 'baz?baz=1#baz', '/foo/bar?foo=1'], + ]; } /** @@ -85,16 +85,16 @@ class HttpFoundationExtensionTest extends TestCase public function getGenerateAbsoluteUrlRequestContextData() { - return array( - array('/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'), - array('foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo/foo.png'), - array('foo.png', '/foo/bar/', 'localhost', 'http', 80, 443, 'http://localhost/foo/bar/foo.png'), - array('/foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo.png'), - array('foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo/foo.png'), - array('foo.png', '/foo/bar/', 'localhost', 'https', 80, 443, 'https://localhost/foo/bar/foo.png'), - array('/foo.png', '/foo', 'localhost', 'http', 443, 80, 'http://localhost:443/foo.png'), - array('/foo.png', '/foo', 'localhost', 'https', 443, 80, 'https://localhost:80/foo.png'), - ); + return [ + ['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'], + ['foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo/foo.png'], + ['foo.png', '/foo/bar/', 'localhost', 'http', 80, 443, 'http://localhost/foo/bar/foo.png'], + ['/foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo.png'], + ['foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo/foo.png'], + ['foo.png', '/foo/bar/', 'localhost', 'https', 80, 443, 'https://localhost/foo/bar/foo.png'], + ['/foo.png', '/foo', 'localhost', 'http', 443, 80, 'http://localhost:443/foo.png'], + ['/foo.png', '/foo', 'localhost', 'https', 443, 80, 'https://localhost:80/foo.png'], + ]; } public function testGenerateAbsoluteUrlWithScriptFileName() @@ -130,14 +130,14 @@ class HttpFoundationExtensionTest extends TestCase public function getGenerateRelativePathData() { - return array( - array('../foo.png', '/foo.png', '/foo/bar.html'), - array('../baz/foo.png', '/baz/foo.png', '/foo/bar.html'), - array('baz/foo.png', 'baz/foo.png', '/foo/bar.html'), + return [ + ['../foo.png', '/foo.png', '/foo/bar.html'], + ['../baz/foo.png', '/baz/foo.png', '/foo/bar.html'], + ['baz/foo.png', 'baz/foo.png', '/foo/bar.html'], - array('http://example.com/baz', 'http://example.com/baz', '/'), - array('https://example.com/baz', 'https://example.com/baz', '/'), - array('//example.com/baz', '//example.com/baz', '/'), - ); + ['http://example.com/baz', 'http://example.com/baz', '/'], + ['https://example.com/baz', 'https://example.com/baz', '/'], + ['//example.com/baz', '//example.com/baz', '/'], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index 9f19847eb8..9fe36b40c9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -72,19 +72,19 @@ class HttpKernelExtensionTest extends TestCase $context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); - return new FragmentHandler($context, array($strategy), false); + return new FragmentHandler($context, [$strategy], false); } protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}') { - $loader = new ArrayLoader(array('index' => $template)); - $twig = new Environment($loader, array('debug' => true, 'cache' => false)); + $loader = new ArrayLoader(['index' => $template]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false]); $twig->addExtension(new HttpKernelExtension()); $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); - $loader->expects($this->any())->method('load')->will($this->returnValueMap(array( - array('Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)), - ))); + $loader->expects($this->any())->method('load')->will($this->returnValueMap([ + ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], + ])); $twig->addRuntimeLoader($loader); return $twig->render('index'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index fdff039851..05f7ad741c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -24,7 +24,7 @@ class RoutingExtensionTest extends TestCase */ public function testEscaping($template, $mustBeEscaped) { - $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); + $twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); $twig->addExtension(new RoutingExtension($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock())); $nodes = $twig->parse($twig->tokenize(new Source($template, ''))); @@ -34,21 +34,21 @@ class RoutingExtensionTest extends TestCase public function getEscapingTemplates() { - return array( - array('{{ path("foo") }}', false), - array('{{ path("foo", {}) }}', false), - array('{{ path("foo", { foo: "foo" }) }}', false), - array('{{ path("foo", foo) }}', true), - array('{{ path("foo", { foo: foo }) }}', true), - array('{{ path("foo", { foo: ["foo", "bar"] }) }}', true), - array('{{ path("foo", { foo: "foo", bar: "bar" }) }}', true), + return [ + ['{{ path("foo") }}', false], + ['{{ path("foo", {}) }}', false], + ['{{ path("foo", { foo: "foo" }) }}', false], + ['{{ path("foo", foo) }}', true], + ['{{ path("foo", { foo: foo }) }}', true], + ['{{ path("foo", { foo: ["foo", "bar"] }) }}', true], + ['{{ path("foo", { foo: "foo", bar: "bar" }) }}', true], - array('{{ path(name = "foo", parameters = {}) }}', false), - array('{{ path(name = "foo", parameters = { foo: "foo" }) }}', false), - array('{{ path(name = "foo", parameters = foo) }}', true), - array('{{ path(name = "foo", parameters = { foo: ["foo", "bar"] }) }}', true), - array('{{ path(name = "foo", parameters = { foo: foo }) }}', true), - array('{{ path(name = "foo", parameters = { foo: "foo", bar: "bar" }) }}', true), - ); + ['{{ path(name = "foo", parameters = {}) }}', false], + ['{{ path(name = "foo", parameters = { foo: "foo" }) }}', false], + ['{{ path(name = "foo", parameters = foo) }}', true], + ['{{ path(name = "foo", parameters = { foo: ["foo", "bar"] }) }}', true], + ['{{ path(name = "foo", parameters = { foo: foo }) }}', true], + ['{{ path(name = "foo", parameters = { foo: "foo", bar: "bar" }) }}', true], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php index 4934bef87d..0bec8ec6f1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RuntimeLoaderProvider.php @@ -19,9 +19,9 @@ trait RuntimeLoaderProvider protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer) { $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); - $loader->expects($this->any())->method('load')->will($this->returnValueMap(array( - array('Symfony\Component\Form\FormRenderer', $renderer), - ))); + $loader->expects($this->any())->method('load')->will($this->returnValueMap([ + ['Symfony\Component\Form\FormRenderer', $renderer], + ])); $environment->addRuntimeLoader($loader); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php index 901425b1b9..1af65e4c19 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php @@ -24,7 +24,7 @@ class StopwatchExtensionTest extends TestCase */ public function testFailIfStoppingWrongEvent() { - $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', array()); + $this->testTiming('{% stopwatch "foo" %}{% endstopwatch "bar" %}', []); } /** @@ -32,7 +32,7 @@ class StopwatchExtensionTest extends TestCase */ public function testTiming($template, $events) { - $twig = new Environment(new ArrayLoader(array('template' => $template)), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); + $twig = new Environment(new ArrayLoader(['template' => $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]); $twig->addExtension(new StopwatchExtension($this->getStopwatch($events))); try { @@ -44,19 +44,19 @@ class StopwatchExtensionTest extends TestCase public function getTimingTemplates() { - return array( - array('{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'), - array('{% stopwatch "foo" %}symfony is fun{% endstopwatch %}{% stopwatch "bar" %}something{% endstopwatch %}', array('foo', 'bar')), - array('{% set foo = "foo" %}{% stopwatch foo %}something{% endstopwatch %}', 'foo'), - array('{% set foo = "foo" %}{% stopwatch foo %}something {% set foo = "bar" %}{% endstopwatch %}', 'foo'), - array('{% stopwatch "foo.bar" %}something{% endstopwatch %}', 'foo.bar'), - array('{% stopwatch "foo" %}something{% endstopwatch %}{% stopwatch "foo" %}something else{% endstopwatch %}', array('foo', 'foo')), - ); + return [ + ['{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'], + ['{% stopwatch "foo" %}symfony is fun{% endstopwatch %}{% stopwatch "bar" %}something{% endstopwatch %}', ['foo', 'bar']], + ['{% set foo = "foo" %}{% stopwatch foo %}something{% endstopwatch %}', 'foo'], + ['{% set foo = "foo" %}{% stopwatch foo %}something {% set foo = "bar" %}{% endstopwatch %}', 'foo'], + ['{% stopwatch "foo.bar" %}something{% endstopwatch %}', 'foo.bar'], + ['{% stopwatch "foo" %}something{% endstopwatch %}{% stopwatch "foo" %}something else{% endstopwatch %}', ['foo', 'foo']], + ]; } - protected function getStopwatch($events = array()) + protected function getStopwatch($events = []) { - $events = \is_array($events) ? $events : array($events); + $events = \is_array($events) ? $events : [$events]; $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); $i = -1; diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index feba2b2b6b..ef4bf9e111 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -22,7 +22,7 @@ class TranslationExtensionTest extends TestCase { public function testEscaping() { - $output = $this->getTemplate('{% trans %}Percent: %value%%% (%msg%){% endtrans %}')->render(array('value' => 12, 'msg' => 'approx.')); + $output = $this->getTemplate('{% trans %}Percent: %value%%% (%msg%){% endtrans %}')->render(['value' => 12, 'msg' => 'approx.']); $this->assertEquals('Percent: 12% (approx.)', $output); } @@ -30,12 +30,12 @@ class TranslationExtensionTest extends TestCase /** * @dataProvider getTransTests */ - public function testTrans($template, $expected, array $variables = array()) + public function testTrans($template, $expected, array $variables = []) { if ($expected != $this->getTemplate($template)->render($variables)) { echo $template."\n"; - $loader = new TwigArrayLoader(array('index' => $template)); - $twig = new Environment($loader, array('debug' => true, 'cache' => false)); + $loader = new TwigArrayLoader(['index' => $template]); + $twig = new Environment($loader, ['debug' => true, 'cache' => false]); $twig->addExtension(new TranslationExtension(new Translator('en'))); echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n"; @@ -74,67 +74,67 @@ class TranslationExtensionTest extends TestCase public function getTransTests() { - return array( + return [ // trans tag - array('{% trans %}Hello{% endtrans %}', 'Hello'), - array('{% trans %}%name%{% endtrans %}', 'Symfony', array('name' => 'Symfony')), + ['{% trans %}Hello{% endtrans %}', 'Hello'], + ['{% trans %}%name%{% endtrans %}', 'Symfony', ['name' => 'Symfony']], - array('{% trans from elsewhere %}Hello{% endtrans %}', 'Hello'), + ['{% trans from elsewhere %}Hello{% endtrans %}', 'Hello'], - array('{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony', array('name' => 'Symfony')), - array('{% trans with { \'%name%\': \'Symfony\' } %}Hello %name%{% endtrans %}', 'Hello Symfony'), - array('{% set vars = { \'%name%\': \'Symfony\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony'), + ['{% trans %}Hello %name%{% endtrans %}', 'Hello Symfony', ['name' => 'Symfony']], + ['{% trans with { \'%name%\': \'Symfony\' } %}Hello %name%{% endtrans %}', 'Hello Symfony'], + ['{% set vars = { \'%name%\': \'Symfony\' } %}{% trans with vars %}Hello %name%{% endtrans %}', 'Hello Symfony'], - array('{% trans into "fr"%}Hello{% endtrans %}', 'Hello'), + ['{% trans into "fr"%}Hello{% endtrans %}', 'Hello'], // transchoice - array( + [ '{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is no apples', - array('count' => 0), - ), - array( + ['count' => 0], + ], + [ '{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is 5 apples', - array('count' => 5), - ), - array( + ['count' => 5], + ], + [ '{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', 'There is 5 apples (Symfony)', - array('count' => 5, 'name' => 'Symfony'), - ), - array( + ['count' => 5, 'name' => 'Symfony'], + ], + [ '{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', 'There is 5 apples (Symfony)', - array('count' => 5), - ), - array( + ['count' => 5], + ], + [ '{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is no apples', - array('count' => 0), - ), - array( + ['count' => 0], + ], + [ '{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is 5 apples', - ), + ], // trans filter - array('{{ "Hello"|trans }}', 'Hello'), - array('{{ name|trans }}', 'Symfony', array('name' => 'Symfony')), - array('{{ hello|trans({ \'%name%\': \'Symfony\' }) }}', 'Hello Symfony', array('hello' => 'Hello %name%')), - array('{% set vars = { \'%name%\': \'Symfony\' } %}{{ hello|trans(vars) }}', 'Hello Symfony', array('hello' => 'Hello %name%')), - array('{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'), + ['{{ "Hello"|trans }}', 'Hello'], + ['{{ name|trans }}', 'Symfony', ['name' => 'Symfony']], + ['{{ hello|trans({ \'%name%\': \'Symfony\' }) }}', 'Hello Symfony', ['hello' => 'Hello %name%']], + ['{% set vars = { \'%name%\': \'Symfony\' } %}{{ hello|trans(vars) }}', 'Hello Symfony', ['hello' => 'Hello %name%']], + ['{{ "Hello"|trans({}, "messages", "fr") }}', 'Hello'], // transchoice filter - array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}', 'There is 5 apples', array('count' => 5)), - array('{{ text|transchoice(5, {\'%name%\': \'Symfony\'}) }}', 'There is 5 apples (Symfony)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')), - array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {}, "messages", "fr") }}', 'There is 5 apples', array('count' => 5)), - ); + ['{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}', 'There is 5 apples', ['count' => 5]], + ['{{ text|transchoice(5, {\'%name%\': \'Symfony\'}) }}', 'There is 5 apples (Symfony)', ['text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)']], + ['{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {}, "messages", "fr") }}', 'There is 5 apples', ['count' => 5]], + ]; } public function testDefaultTranslationDomain() { - $templates = array( + $templates = [ 'index' => ' {%- extends "base" %} @@ -153,22 +153,22 @@ class TranslationExtensionTest extends TestCase 'base' => ' {%- block content "" %} ', - ); + ]; $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', array('foo' => 'foo (messages)'), 'en'); - $translator->addResource('array', array('foo' => 'foo (custom)'), 'en', 'custom'); - $translator->addResource('array', array('foo' => 'foo (foo)'), 'en', 'foo'); + $translator->addResource('array', ['foo' => 'foo (messages)'], 'en'); + $translator->addResource('array', ['foo' => 'foo (custom)'], 'en', 'custom'); + $translator->addResource('array', ['foo' => 'foo (foo)'], 'en', 'foo'); $template = $this->getTemplate($templates, $translator); - $this->assertEquals('foo (foo)foo (custom)foo (foo)foo (custom)foo (foo)foo (custom)', trim($template->render(array()))); + $this->assertEquals('foo (foo)foo (custom)foo (foo)foo (custom)foo (foo)foo (custom)', trim($template->render([]))); } public function testDefaultTranslationDomainWithNamedArguments() { - $templates = array( + $templates = [ 'index' => ' {%- trans_default_domain "foo" %} @@ -186,18 +186,18 @@ class TranslationExtensionTest extends TestCase 'base' => ' {%- block content "" %} ', - ); + ]; $translator = new Translator('en'); $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', array('foo' => 'foo (messages)'), 'en'); - $translator->addResource('array', array('foo' => 'foo (custom)'), 'en', 'custom'); - $translator->addResource('array', array('foo' => 'foo (foo)'), 'en', 'foo'); - $translator->addResource('array', array('foo' => 'foo (fr)'), 'fr', 'custom'); + $translator->addResource('array', ['foo' => 'foo (messages)'], 'en'); + $translator->addResource('array', ['foo' => 'foo (custom)'], 'en', 'custom'); + $translator->addResource('array', ['foo' => 'foo (foo)'], 'en', 'foo'); + $translator->addResource('array', ['foo' => 'foo (fr)'], 'fr', 'custom'); $template = $this->getTemplate($templates, $translator); - $this->assertEquals('foo (custom)foo (foo)foo (custom)foo (custom)foo (fr)foo (custom)foo (fr)', trim($template->render(array()))); + $this->assertEquals('foo (custom)foo (foo)foo (custom)foo (custom)foo (fr)foo (custom)foo (fr)', trim($template->render([]))); } protected function getTemplate($template, $translator = null) @@ -209,9 +209,9 @@ class TranslationExtensionTest extends TestCase if (\is_array($template)) { $loader = new TwigArrayLoader($template); } else { - $loader = new TwigArrayLoader(array('index' => $template)); + $loader = new TwigArrayLoader(['index' => $template]); } - $twig = new Environment($loader, array('debug' => true, 'cache' => false)); + $twig = new Environment($loader, ['debug' => true, 'cache' => false]); $twig->addExtension(new TranslationExtension($translator)); return $twig->loadTemplate('index'); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/WebLinkExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/WebLinkExtensionTest.php index 3424b58875..f49eea396d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/WebLinkExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/WebLinkExtensionTest.php @@ -44,49 +44,49 @@ class WebLinkExtensionTest extends TestCase public function testLink() { - $this->assertEquals('/foo.css', $this->extension->link('/foo.css', 'preload', array('as' => 'style', 'nopush' => true))); + $this->assertEquals('/foo.css', $this->extension->link('/foo.css', 'preload', ['as' => 'style', 'nopush' => true])); $link = (new Link('preload', '/foo.css'))->withAttribute('as', 'style')->withAttribute('nopush', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } public function testPreload() { - $this->assertEquals('/foo.css', $this->extension->preload('/foo.css', array('as' => 'style', 'crossorigin' => true))); + $this->assertEquals('/foo.css', $this->extension->preload('/foo.css', ['as' => 'style', 'crossorigin' => true])); $link = (new Link('preload', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } public function testDnsPrefetch() { - $this->assertEquals('/foo.css', $this->extension->dnsPrefetch('/foo.css', array('as' => 'style', 'crossorigin' => true))); + $this->assertEquals('/foo.css', $this->extension->dnsPrefetch('/foo.css', ['as' => 'style', 'crossorigin' => true])); $link = (new Link('dns-prefetch', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } public function testPreconnect() { - $this->assertEquals('/foo.css', $this->extension->preconnect('/foo.css', array('as' => 'style', 'crossorigin' => true))); + $this->assertEquals('/foo.css', $this->extension->preconnect('/foo.css', ['as' => 'style', 'crossorigin' => true])); $link = (new Link('preconnect', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } public function testPrefetch() { - $this->assertEquals('/foo.css', $this->extension->prefetch('/foo.css', array('as' => 'style', 'crossorigin' => true))); + $this->assertEquals('/foo.css', $this->extension->prefetch('/foo.css', ['as' => 'style', 'crossorigin' => true])); $link = (new Link('prefetch', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } public function testPrerender() { - $this->assertEquals('/foo.css', $this->extension->prerender('/foo.css', array('as' => 'style', 'crossorigin' => true))); + $this->assertEquals('/foo.css', $this->extension->prerender('/foo.css', ['as' => 'style', 'crossorigin' => true])); $link = (new Link('prerender', '/foo.css'))->withAttribute('as', 'style')->withAttribute('crossorigin', true); - $this->assertEquals(array($link), array_values($this->request->attributes->get('_links')->getLinks())); + $this->assertEquals([$link], array_values($this->request->attributes->get('_links')->getLinks())); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 3075f34629..06c75fd0ec 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -70,9 +70,9 @@ EOTXT; public function testOneVar() { - $vars = new Node(array( + $vars = new Node([ new NameExpression('foo', 7), - )); + ]); $node = new DumpNode('bar', $vars, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); @@ -93,10 +93,10 @@ EOTXT; public function testMultiVars() { - $vars = new Node(array( + $vars = new Node([ new NameExpression('foo', 7), new NameExpression('bar', 7), - )); + ]); $node = new DumpNode('bar', $vars, 7); $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock()); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index e9a568d744..848685ee5f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -30,10 +30,10 @@ class FormThemeTest extends TestCase public function testConstructor() { $form = new NameExpression('form', 0); - $resources = new Node(array( + $resources = new Node([ new ConstantExpression('tpl1', 0), new ConstantExpression('tpl2', 0), - )); + ]); $node = new FormThemeNode($form, $resources, 0); @@ -45,12 +45,12 @@ class FormThemeTest extends TestCase public function testCompile() { $form = new NameExpression('form', 0); - $resources = new ArrayExpression(array( + $resources = new ArrayExpression([ new ConstantExpression(0, 0), new ConstantExpression('tpl1', 0), new ConstantExpression(1, 0), new ConstantExpression('tpl2', 0), - ), 0); + ], 0); $node = new FormThemeNode($form, $resources, 0); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 9a86ffb9e8..fab7d0974c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -25,9 +25,9 @@ class SearchAndRenderBlockNodeTest extends TestCase { public function testCompileWidget() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), - )); + ]); $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); @@ -44,13 +44,13 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileWidgetWithVariables() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), - ), 0), - )); + ], 0), + ]); $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); @@ -67,10 +67,10 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithLabel() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConstantExpression('my label', 0), - )); + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -87,10 +87,10 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithNullLabel() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConstantExpression(null, 0), - )); + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -109,10 +109,10 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithEmptyStringLabel() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConstantExpression('', 0), - )); + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -131,9 +131,9 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithDefaultLabel() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), - )); + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -150,14 +150,14 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithAttributes() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConstantExpression(null, 0), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), - ), 0), - )); + ], 0), + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -177,16 +177,16 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithLabelAndAttributes() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConstantExpression('value in argument', 0), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), new ConstantExpression('label', 0), new ConstantExpression('value in attributes', 0), - ), 0), - )); + ], 0), + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -203,7 +203,7 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithLabelThatEvaluatesToNull() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConditionalExpression( // if @@ -214,7 +214,7 @@ class SearchAndRenderBlockNodeTest extends TestCase new ConstantExpression(null, 0), 0 ), - )); + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); @@ -234,7 +234,7 @@ class SearchAndRenderBlockNodeTest extends TestCase public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() { - $arguments = new Node(array( + $arguments = new Node([ new NameExpression('form', 0), new ConditionalExpression( // if @@ -245,13 +245,13 @@ class SearchAndRenderBlockNodeTest extends TestCase new ConstantExpression(null, 0), 0 ), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression('foo', 0), new ConstantExpression('bar', 0), new ConstantExpression('label', 0), new ConstantExpression('value in attributes', 0), - ), 0), - )); + ], 0), + ]); $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index ebc3dac5bb..d70f782411 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -29,7 +29,7 @@ class TransNodeTest extends TestCase $vars = new NameExpression('foo', 0); $node = new TransNode($body, null, null, $vars); - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('strict_variables' => true)); + $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['strict_variables' => true]); $compiler = new Compiler($env); $this->assertEquals( diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index eb4c9a83e8..5abfe1e92a 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -26,7 +26,7 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase /** @dataProvider getDefaultDomainAssignmentTestData */ public function testDefaultDomainAssignment(Node $node) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag @@ -46,13 +46,13 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); - $this->assertEquals(array(array(self::$message, self::$domain)), $visitor->getMessages()); + $this->assertEquals([[self::$message, self::$domain]], $visitor->getMessages()); } /** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(Node $node) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag @@ -72,22 +72,22 @@ class TranslationDefaultDomainNodeVisitorTest extends TestCase $visitor->enterNode($node, $env); $visitor->leaveNode($node, $env); - $this->assertEquals(array(array(self::$message, null)), $visitor->getMessages()); + $this->assertEquals([[self::$message, null]], $visitor->getMessages()); } public function getDefaultDomainAssignmentTestData() { - return array( - array(TwigNodeProvider::getTransFilter(self::$message)), - array(TwigNodeProvider::getTransChoiceFilter(self::$message)), - array(TwigNodeProvider::getTransTag(self::$message)), + return [ + [TwigNodeProvider::getTransFilter(self::$message)], + [TwigNodeProvider::getTransChoiceFilter(self::$message)], + [TwigNodeProvider::getTransTag(self::$message)], // with named arguments - array(TwigNodeProvider::getTransFilter(self::$message, null, array( - 'arguments' => new ArrayExpression(array(), 0), - ))), - array(TwigNodeProvider::getTransChoiceFilter(self::$message), null, array( - 'arguments' => new ArrayExpression(array(), 0), - )), - ); + [TwigNodeProvider::getTransFilter(self::$message, null, [ + 'arguments' => new ArrayExpression([], 0), + ])], + [TwigNodeProvider::getTransChoiceFilter(self::$message), null, [ + 'arguments' => new ArrayExpression([], 0), + ]], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 9c2d0ab9e4..11d16e4cd6 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -25,7 +25,7 @@ class TranslationNodeVisitorTest extends TestCase /** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(Node $node, array $expectedMessages) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); @@ -40,14 +40,14 @@ class TranslationNodeVisitorTest extends TestCase $node = new FilterExpression( new ConstantExpression($message, 0), new ConstantExpression('trans', 0), - new Node(array( - new ArrayExpression(array(), 0), + new Node([ + new ArrayExpression([], 0), new NameExpression('variable', 0), - )), + ]), 0 ); - $this->testMessagesExtraction($node, array(array($message, TranslationNodeVisitor::UNDEFINED_DOMAIN))); + $this->testMessagesExtraction($node, [[$message, TranslationNodeVisitor::UNDEFINED_DOMAIN]]); } public function getMessagesExtractionTestData() @@ -55,13 +55,13 @@ class TranslationNodeVisitorTest extends TestCase $message = 'new key'; $domain = 'domain'; - return array( - array(TwigNodeProvider::getTransFilter($message), array(array($message, null))), - array(TwigNodeProvider::getTransChoiceFilter($message), array(array($message, null))), - array(TwigNodeProvider::getTransTag($message), array(array($message, null))), - array(TwigNodeProvider::getTransFilter($message, $domain), array(array($message, $domain))), - array(TwigNodeProvider::getTransChoiceFilter($message, $domain), array(array($message, $domain))), - array(TwigNodeProvider::getTransTag($message, $domain), array(array($message, $domain))), - ); + return [ + [TwigNodeProvider::getTransFilter($message), [[$message, null]]], + [TwigNodeProvider::getTransChoiceFilter($message), [[$message, null]]], + [TwigNodeProvider::getTransTag($message), [[$message, null]]], + [TwigNodeProvider::getTransFilter($message, $domain), [[$message, $domain]]], + [TwigNodeProvider::getTransChoiceFilter($message, $domain), [[$message, $domain]]], + [TwigNodeProvider::getTransTag($message, $domain), [[$message, $domain]]], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php index 49eac23e8a..5147724675 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php @@ -28,9 +28,9 @@ class TwigNodeProvider return new ModuleNode( new ConstantExpression($content, 0), null, - new ArrayExpression(array(), 0), - new ArrayExpression(array(), 0), - new ArrayExpression(array(), 0), + new ArrayExpression([], 0), + new ArrayExpression([], 0), + new ArrayExpression([], 0), null, new Source('', '') ); @@ -39,10 +39,10 @@ class TwigNodeProvider public static function getTransFilter($message, $domain = null, $arguments = null) { if (!$arguments) { - $arguments = $domain ? array( - new ArrayExpression(array(), 0), + $arguments = $domain ? [ + new ArrayExpression([], 0), new ConstantExpression($domain, 0), - ) : array(); + ] : []; } return new FilterExpression( @@ -56,11 +56,11 @@ class TwigNodeProvider public static function getTransChoiceFilter($message, $domain = null, $arguments = null) { if (!$arguments) { - $arguments = $domain ? array( + $arguments = $domain ? [ new ConstantExpression(0, 0), - new ArrayExpression(array(), 0), + new ArrayExpression([], 0), new ConstantExpression($domain, 0), - ) : array(); + ] : []; } return new FilterExpression( @@ -74,7 +74,7 @@ class TwigNodeProvider public static function getTransTag($message, $domain = null) { return new TransNode( - new BodyNode(array(), array('data' => $message)), + new BodyNode([], ['data' => $message]), $domain ? new ConstantExpression($domain, 0) : null ); } diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index fc7af4f94d..572685a6c4 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -28,7 +28,7 @@ class FormThemeTokenParserTest extends TestCase */ public function testCompile($source, $expected) { - $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]); $env->addTokenParser(new FormThemeTokenParser()); $stream = $env->tokenize(new Source($source, '')); $parser = new Parser($env); @@ -38,34 +38,34 @@ class FormThemeTokenParserTest extends TestCase public function getTestsForFormTheme() { - return array( - array( + return [ + [ '{% form_theme form "tpl1" %}', new FormThemeNode( new NameExpression('form', 1), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), - ), 1), + ], 1), 1, 'form_theme' ), - ), - array( + ], + [ '{% form_theme form "tpl1" "tpl2" %}', new FormThemeNode( new NameExpression('form', 1), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), - ), 1), + ], 1), 1, 'form_theme' ), - ), - array( + ], + [ '{% form_theme form with "tpl1" %}', new FormThemeNode( new NameExpression('form', 1), @@ -73,48 +73,48 @@ class FormThemeTokenParserTest extends TestCase 1, 'form_theme' ), - ), - array( + ], + [ '{% form_theme form with ["tpl1"] %}', new FormThemeNode( new NameExpression('form', 1), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), - ), 1), + ], 1), 1, 'form_theme' ), - ), - array( + ], + [ '{% form_theme form with ["tpl1", "tpl2"] %}', new FormThemeNode( new NameExpression('form', 1), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), - ), 1), + ], 1), 1, 'form_theme' ), - ), - array( + ], + [ '{% form_theme form with ["tpl1", "tpl2"] only %}', new FormThemeNode( new NameExpression('form', 1), - new ArrayExpression(array( + new ArrayExpression([ new ConstantExpression(0, 1), new ConstantExpression('tpl1', 1), new ConstantExpression(1, 1), new ConstantExpression('tpl2', 1), - ), 1), + ], 1), 1, 'form_theme', true ), - ), - ); + ], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 8e5c84bbc9..5dd5bb79d7 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -27,12 +27,12 @@ class TwigExtractorTest extends TestCase public function testExtract($template, $messages) { $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); - $twig = new Environment($loader, array( + $twig = new Environment($loader, [ 'strict_variables' => true, 'debug' => true, 'cache' => false, 'autoescape' => false, - )); + ]); $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())); $extractor = new TwigExtractor($twig); @@ -51,28 +51,28 @@ class TwigExtractorTest extends TestCase public function getExtractData() { - return array( - array('{{ "new key" | trans() }}', array('new key' => 'messages')), - array('{{ "new key" | trans() | upper }}', array('new key' => 'messages')), - array('{{ "new key" | trans({}, "domain") }}', array('new key' => 'domain')), - array('{{ "new key" | transchoice(1) }}', array('new key' => 'messages')), - array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')), - array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')), - array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')), - array('{% trans %} new key {% endtrans %}', array('new key' => 'messages')), - array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')), - array('{% set foo = "new key" | trans %}', array('new key' => 'messages')), - array('{{ 1 ? "new key" | trans : "another key" | trans }}', array('new key' => 'messages', 'another key' => 'messages')), + return [ + ['{{ "new key" | trans() }}', ['new key' => 'messages']], + ['{{ "new key" | trans() | upper }}', ['new key' => 'messages']], + ['{{ "new key" | trans({}, "domain") }}', ['new key' => 'domain']], + ['{{ "new key" | transchoice(1) }}', ['new key' => 'messages']], + ['{{ "new key" | transchoice(1) | upper }}', ['new key' => 'messages']], + ['{{ "new key" | transchoice(1, {}, "domain") }}', ['new key' => 'domain']], + ['{% trans %}new key{% endtrans %}', ['new key' => 'messages']], + ['{% trans %} new key {% endtrans %}', ['new key' => 'messages']], + ['{% trans from "domain" %}new key{% endtrans %}', ['new key' => 'domain']], + ['{% set foo = "new key" | trans %}', ['new key' => 'messages']], + ['{{ 1 ? "new key" | trans : "another key" | trans }}', ['new key' => 'messages', 'another key' => 'messages']], // make sure 'trans_default_domain' tag is supported - array('{% trans_default_domain "domain" %}{{ "new key"|trans }}', array('new key' => 'domain')), - array('{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', array('new key' => 'domain')), - array('{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', array('new key' => 'domain')), + ['{% trans_default_domain "domain" %}{{ "new key"|trans }}', ['new key' => 'domain']], + ['{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', ['new key' => 'domain']], + ['{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', ['new key' => 'domain']], // make sure this works with twig's named arguments - array('{{ "new key" | trans(domain="domain") }}', array('new key' => 'domain')), - array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')), - ); + ['{{ "new key" | trans(domain="domain") }}', ['new key' => 'domain']], + ['{{ "new key" | transchoice(domain="domain", count=1) }}', ['new key' => 'domain']], + ]; } /** @@ -105,11 +105,11 @@ class TwigExtractorTest extends TestCase */ public function resourcesWithSyntaxErrorsProvider() { - return array( - array(__DIR__.'/../Fixtures'), - array(__DIR__.'/../Fixtures/extractor/syntax_error.twig'), - array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')), - ); + return [ + [__DIR__.'/../Fixtures'], + [__DIR__.'/../Fixtures/extractor/syntax_error.twig'], + [new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')], + ]; } /** @@ -117,13 +117,13 @@ class TwigExtractorTest extends TestCase */ public function testExtractWithFiles($resource) { - $loader = new ArrayLoader(array()); - $twig = new Environment($loader, array( + $loader = new ArrayLoader([]); + $twig = new Environment($loader, [ 'strict_variables' => true, 'debug' => true, 'cache' => false, 'autoescape' => false, - )); + ]); $twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())); $extractor = new TwigExtractor($twig); @@ -141,12 +141,12 @@ class TwigExtractorTest extends TestCase { $directory = __DIR__.'/../Fixtures/extractor/'; - return array( - array($directory.'with_translations.html.twig'), - array(array($directory.'with_translations.html.twig')), - array(array(new \SplFileInfo($directory.'with_translations.html.twig'))), - array(new \ArrayObject(array($directory.'with_translations.html.twig'))), - array(new \ArrayObject(array(new \SplFileInfo($directory.'with_translations.html.twig')))), - ); + return [ + [$directory.'with_translations.html.twig'], + [[$directory.'with_translations.html.twig']], + [[new \SplFileInfo($directory.'with_translations.html.twig')]], + [new \ArrayObject([$directory.'with_translations.html.twig'])], + [new \ArrayObject([new \SplFileInfo($directory.'with_translations.html.twig')])], + ]; } } diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php index a74c59e8d2..ab932eebc3 100644 --- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php @@ -23,7 +23,7 @@ class TwigEngineTest extends TestCase { $engine = $this->getTwig(); - $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', array(), '', false))); + $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', [], '', false))); } public function testExistsWithNonExistentTemplates() @@ -70,10 +70,10 @@ class TwigEngineTest extends TestCase protected function getTwig() { - $twig = new Environment(new ArrayLoader(array( + $twig = new Environment(new ArrayLoader([ 'index' => 'foo', 'error' => '{{ foo }', - ))); + ])); $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); return new TwigEngine($twig, $parser); diff --git a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php index 2388cc5662..ffef9e9859 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php @@ -45,7 +45,7 @@ class FormThemeTokenParser extends AbstractTokenParser $only = true; } } else { - $resources = new ArrayExpression(array(), $stream->getCurrent()->getLine()); + $resources = new ArrayExpression([], $stream->getCurrent()->getLine()); do { $resources->addElement($this->parser->getExpressionParser()->parseExpression()); } while (!$stream->test(Token::BLOCK_END_TYPE)); diff --git a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php index dd78175d21..54dcf6d391 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php @@ -41,7 +41,7 @@ class StopwatchTokenParser extends AbstractTokenParser $stream->expect(Token::BLOCK_END_TYPE); // {% endstopwatch %} - $body = $this->parser->subparse(array($this, 'decideStopwatchEnd'), true); + $body = $this->parser->subparse([$this, 'decideStopwatchEnd'], true); $stream->expect(Token::BLOCK_END_TYPE); if ($this->stopwatchIsAvailable) { diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index 1cda1dcb3c..7b673856f0 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -38,7 +38,7 @@ class TransChoiceTokenParser extends TransTokenParser $lineno = $token->getLine(); $stream = $this->parser->getStream(); - $vars = new ArrayExpression(array(), $lineno); + $vars = new ArrayExpression([], $lineno); $count = $this->parser->getExpressionParser()->parseExpression(); @@ -65,7 +65,7 @@ class TransChoiceTokenParser extends TransTokenParser $stream->expect(Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true); + $body = $this->parser->subparse([$this, 'decideTransChoiceFork'], true); if (!$body instanceof TextNode && !$body instanceof AbstractExpression) { throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()); @@ -78,7 +78,7 @@ class TransChoiceTokenParser extends TransTokenParser public function decideTransChoiceFork($token) { - return $token->test(array('endtranschoice')); + return $token->test(['endtranschoice']); } /** diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 5fe2255fcd..ca2dae1618 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -39,7 +39,7 @@ class TransTokenParser extends AbstractTokenParser $lineno = $token->getLine(); $stream = $this->parser->getStream(); - $vars = new ArrayExpression(array(), $lineno); + $vars = new ArrayExpression([], $lineno); $domain = null; $locale = null; if (!$stream->test(Token::BLOCK_END_TYPE)) { @@ -66,7 +66,7 @@ class TransTokenParser extends AbstractTokenParser // {% trans %}message{% endtrans %} $stream->expect(Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideTransFork'), true); + $body = $this->parser->subparse([$this, 'decideTransFork'], true); if (!$body instanceof TextNode && !$body instanceof AbstractExpression) { throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()); @@ -79,7 +79,7 @@ class TransTokenParser extends AbstractTokenParser public function decideTransFork($token) { - return $token->test(array('endtrans')); + return $token->test(['endtrans']); } /** diff --git a/src/Symfony/Bridge/Twig/TwigEngine.php b/src/Symfony/Bridge/Twig/TwigEngine.php index bc0a4fecc9..4789f3f4d6 100644 --- a/src/Symfony/Bridge/Twig/TwigEngine.php +++ b/src/Symfony/Bridge/Twig/TwigEngine.php @@ -44,7 +44,7 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface * * @throws Error if something went wrong like a thrown exception while rendering the template */ - public function render($name, array $parameters = array()) + public function render($name, array $parameters = []) { return $this->load($name)->render($parameters); } @@ -56,7 +56,7 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface * * @throws Error if something went wrong like a thrown exception while rendering the template */ - public function stream($name, array $parameters = array()) + public function stream($name, array $parameters = []) { $this->load($name)->display($parameters); } diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php index 78b0ab16ea..ff88c69852 100644 --- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php +++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php @@ -19,15 +19,15 @@ use Twig\Error\SyntaxError; */ class UndefinedCallableHandler { - private static $filterComponents = array( + private static $filterComponents = [ 'humanize' => 'form', 'trans' => 'translation', 'transchoice' => 'translation', 'yaml_encode' => 'yaml', 'yaml_dump' => 'yaml', - ); + ]; - private static $functionComponents = array( + private static $functionComponents = [ 'asset' => 'asset', 'asset_version' => 'asset', 'dump' => 'debug-bundle', @@ -55,15 +55,15 @@ class UndefinedCallableHandler 'workflow_transitions' => 'workflow', 'workflow_has_marked_place' => 'workflow', 'workflow_marked_places' => 'workflow', - ); + ]; - private static $fullStackEnable = array( + private static $fullStackEnable = [ 'form' => 'enable "framework.form"', 'security-core' => 'add the "SecurityBundle"', 'security-http' => 'add the "SecurityBundle"', 'web-link' => 'enable "framework.web_link"', 'workflow' => 'enable "framework.workflows"', - ); + ]; public static function onUndefinedFilter($name) { diff --git a/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php b/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php index aa124a8c03..a59872f0ed 100644 --- a/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php +++ b/src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php @@ -37,9 +37,9 @@ class DebugExtension extends Extension $loader->load('services.xml'); $container->getDefinition('var_dumper.cloner') - ->addMethodCall('setMaxItems', array($config['max_items'])) - ->addMethodCall('setMinDepth', array($config['min_depth'])) - ->addMethodCall('setMaxString', array($config['max_string_length'])); + ->addMethodCall('setMaxItems', [$config['max_items']]) + ->addMethodCall('setMinDepth', [$config['min_depth']]) + ->addMethodCall('setMaxString', [$config['max_string_length']]); if (null === $config['dump_destination']) { $container->getDefinition('var_dumper.command.server_dump') diff --git a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php index 6f49c02126..0b518ee00f 100644 --- a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php +++ b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/Compiler/DumpDataCollectorPassTest.php @@ -25,7 +25,7 @@ class DumpDataCollectorPassTest extends TestCase $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); - $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, null)); + $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, null]); $container->setDefinition('data_collector.dump', $definition); $container->compile(); @@ -39,7 +39,7 @@ class DumpDataCollectorPassTest extends TestCase $container->addCompilerPass(new DumpDataCollectorPass()); $requestStack = new RequestStack(); - $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, $requestStack)); + $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, $requestStack]); $container->setDefinition('data_collector.dump', $definition); $container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::ENABLED); @@ -53,7 +53,7 @@ class DumpDataCollectorPassTest extends TestCase $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); - $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, new RequestStack())); + $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, new RequestStack()]); $container->setDefinition('data_collector.dump', $definition); $container->setParameter('web_profiler.debug_toolbar.mode', WebDebugToolbarListener::DISABLED); @@ -67,7 +67,7 @@ class DumpDataCollectorPassTest extends TestCase $container = new ContainerBuilder(); $container->addCompilerPass(new DumpDataCollectorPass()); - $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null, null, new RequestStack())); + $definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', [null, null, null, new RequestStack()]); $container->setDefinition('data_collector.dump', $definition); $container->compile(); diff --git a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php index 0c285a02ac..cd6084c5e3 100644 --- a/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php +++ b/src/Symfony/Bundle/DebugBundle/Tests/DependencyInjection/DebugExtensionTest.php @@ -22,36 +22,36 @@ class DebugExtensionTest extends TestCase { $container = $this->createContainer(); $container->registerExtension(new DebugExtension()); - $container->loadFromExtension('debug', array()); + $container->loadFromExtension('debug', []); $this->compileContainer($container); - $expectedTags = array( - array( + $expectedTags = [ + [ 'id' => 'dump', 'template' => '@Debug/Profiler/dump.html.twig', 'priority' => 240, - ), - ); + ], + ]; $this->assertSame($expectedTags, $container->getDefinition('data_collector.dump')->getTag('data_collector')); } private function createContainer() { - $container = new ContainerBuilder(new ParameterBag(array( + $container = new ContainerBuilder(new ParameterBag([ 'kernel.cache_dir' => __DIR__, 'kernel.charset' => 'UTF-8', 'kernel.debug' => true, - 'kernel.bundles' => array('DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'), - ))); + 'kernel.bundles' => ['DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'], + ])); return $container; } private function compileContainer(ContainerBuilder $container) { - $container->getCompilerPassConfig()->setOptimizationPasses(array()); - $container->getCompilerPassConfig()->setRemovingPasses(array()); + $container->getCompilerPassConfig()->setOptimizationPasses([]); + $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php index cbd864d2ed..0273f7638a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php @@ -54,13 +54,13 @@ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface { $arrayAdapter = new ArrayAdapter(); - spl_autoload_register(array(PhpArrayAdapter::class, 'throwOnRequiredClass')); + spl_autoload_register([PhpArrayAdapter::class, 'throwOnRequiredClass']); try { if (!$this->doWarmUp($cacheDir, $arrayAdapter)) { return; } } finally { - spl_autoload_unregister(array(PhpArrayAdapter::class, 'throwOnRequiredClass')); + spl_autoload_unregister([PhpArrayAdapter::class, 'throwOnRequiredClass']); } // the ArrayAdapter stores the values serialized diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php index e5ba4fd99b..7e6f4e5c2f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php @@ -67,8 +67,8 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf */ public static function getSubscribedServices() { - return array( + return [ 'router' => RouterInterface::class, - ); + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index 0b2ede4864..825b4f3bc6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -74,7 +74,7 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer */ private function extractSupportedLoaders(array $loaders) { - $supportedLoaders = array(); + $supportedLoaders = []; foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php index eaad0f1894..27c103e26c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php @@ -52,7 +52,7 @@ class TemplateFinder implements TemplateFinderInterface return $this->templates; } - $templates = array(); + $templates = []; foreach ($this->kernel->getBundles() as $bundle) { $templates = array_merge($templates, $this->findTemplatesInBundle($bundle)); @@ -72,7 +72,7 @@ class TemplateFinder implements TemplateFinderInterface */ private function findTemplatesInFolder($dir) { - $templates = array(); + $templates = []; if (is_dir($dir)) { $finder = new Finder(); diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php index 523d7ecce0..6662a1808d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php @@ -39,7 +39,7 @@ class TemplatePathsCacheWarmer extends CacheWarmer public function warmUp($cacheDir) { $filesystem = new Filesystem(); - $templates = array(); + $templates = []; foreach ($this->finder->findAllTemplates() as $template) { $templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/'); diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php index eab97ce9db..836913b927 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php @@ -60,8 +60,8 @@ class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriber */ public static function getSubscribedServices() { - return array( + return [ 'translator' => TranslatorInterface::class, - ); + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php index 51a965f71b..e633d2a732 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php @@ -85,7 +85,7 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer */ private function extractSupportedLoaders(array $loaders) { - $supportedLoaders = array(); + $supportedLoaders = []; foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index c86a2772eb..6473f97584 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -34,7 +34,7 @@ class Client extends BaseClient /** * {@inheritdoc} */ - public function __construct(KernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) + public function __construct(KernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) { parent::__construct($kernel, $server, $history, $cookieJar); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 5ec2e5f3ec..ece0e1d8eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -61,46 +61,46 @@ EOT /** @var $kernel KernelInterface */ $kernel = $this->getApplication()->getKernel(); - $rows = array( - array('Symfony'), + $rows = [ + ['Symfony'], new TableSeparator(), - array('Version', Kernel::VERSION), - array('End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' Expired' : '')), - array('End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' Expired' : '')), + ['Version', Kernel::VERSION], + ['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' Expired' : '')], + ['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' Expired' : '')], new TableSeparator(), - array('Kernel'), + ['Kernel'], new TableSeparator(), - array('Type', \get_class($kernel)), - array('Name', $kernel->getName()), - array('Environment', $kernel->getEnvironment()), - array('Debug', $kernel->isDebug() ? 'true' : 'false'), - array('Charset', $kernel->getCharset()), - array('Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())), - array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' ('.self::formatFileSize($kernel->getCacheDir()).')'), - array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' ('.self::formatFileSize($kernel->getLogDir()).')'), + ['Type', \get_class($kernel)], + ['Name', $kernel->getName()], + ['Environment', $kernel->getEnvironment()], + ['Debug', $kernel->isDebug() ? 'true' : 'false'], + ['Charset', $kernel->getCharset()], + ['Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())], + ['Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' ('.self::formatFileSize($kernel->getCacheDir()).')'], + ['Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' ('.self::formatFileSize($kernel->getLogDir()).')'], new TableSeparator(), - array('PHP'), + ['PHP'], new TableSeparator(), - array('Version', PHP_VERSION), - array('Architecture', (PHP_INT_SIZE * 8).' bits'), - array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'), - array('Timezone', date_default_timezone_get().' ('.(new \DateTime())->format(\DateTime::W3C).')'), - array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'), - array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'), - array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'), - ); + ['Version', PHP_VERSION], + ['Architecture', (PHP_INT_SIZE * 8).' bits'], + ['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'], + ['Timezone', date_default_timezone_get().' ('.(new \DateTime())->format(\DateTime::W3C).')'], + ['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'], + ['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'], + ]; if ($dotenv = self::getDotenvVars()) { - $rows = array_merge($rows, array( + $rows = array_merge($rows, [ new TableSeparator(), - array('Environment (.env)'), + ['Environment (.env)'], new TableSeparator(), - ), array_map(function ($value, $name) { - return array($name, $value); + ], array_map(function ($value, $name) { + return [$name, $value]; }, $dotenv, array_keys($dotenv))); } - $io->table(array(), $rows); + $io->table([], $rows); } private static function formatPath(string $path, string $baseDir = null): string @@ -131,7 +131,7 @@ EOT private static function getDotenvVars(): array { - $vars = array(); + $vars = []; foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) { if ('' !== $name && false !== $value = getenv($name)) { $vars[$name] = $value; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 6d8960cd03..cc1b858abb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -29,8 +29,8 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand protected function listBundles($output) { $title = 'Available registered bundles with their extension alias if available'; - $headers = array('Bundle name', 'Extension alias'); - $rows = array(); + $headers = ['Bundle name', 'Extension alias']; + $rows = []; $bundles = $this->getApplication()->getKernel()->getBundles(); usort($bundles, function ($bundleA, $bundleB) { @@ -39,7 +39,7 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand foreach ($bundles as $bundle) { $extension = $bundle->getContainerExtension(); - $rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : ''); + $rows[] = [$bundle->getName(), $extension ? $extension->getAlias() : '']; } if ($output instanceof StyleInterface) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index b90c810006..4116ae1bc6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -55,9 +55,9 @@ class AssetsInstallCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', null), - )) + ]) ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks') ->addOption('no-cleanup', null, InputOption::VALUE_NONE, 'Do not remove the assets of the bundles that no longer exist') @@ -123,10 +123,10 @@ EOT $io->newLine(); - $rows = array(); + $rows = []; $copyUsed = false; $exitCode = 0; - $validAssetDirs = array(); + $validAssetDirs = []; /** @var BundleInterface $bundle */ foreach ($kernel->getBundles() as $bundle) { if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) { @@ -159,13 +159,13 @@ EOT } if ($method === $expectedMethod) { - $rows[] = array(sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method); + $rows[] = [sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method]; } else { - $rows[] = array(sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method); + $rows[] = [sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method]; } } catch (\Exception $e) { $exitCode = 1; - $rows[] = array(sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()); + $rows[] = [sprintf('%s', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()]; } } // remove the assets of the bundles that no longer exist @@ -175,7 +175,7 @@ EOT } if ($rows) { - $io->table(array('', 'Bundle', 'Method / Error'), $rows); + $io->table(['', 'Bundle', 'Method / Error'], $rows); } if (0 !== $exitCode) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php index e90bb65b33..dc42910d34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php @@ -44,9 +44,9 @@ final class CachePoolClearCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'), - )) + ]) ->setDescription('Clears cache pools') ->setHelp(<<<'EOF' The %command.name% command clears the given cache pools or cache pool clearers. @@ -64,8 +64,8 @@ EOF { $io = new SymfonyStyle($input, $output); $kernel = $this->getApplication()->getKernel(); - $pools = array(); - $clearers = array(); + $pools = []; + $clearers = []; foreach ($input->getArgument('pools') as $id) { if ($this->poolClearer->hasPool($id)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php index ccd315cad5..04b5d2f7c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php @@ -44,9 +44,9 @@ class CacheWarmupCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), - )) + ]) ->setDescription('Warms up an empty cache') ->setHelp(<<<'EOF' The %command.name% command warms up the cache. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 7b41131b2c..a4a10805f6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -37,10 +37,10 @@ class ConfigDebugCommand extends AbstractConfigCommand protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'), new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), - )) + ]) ->setDescription('Dumps the current configuration for an extension') ->setHelp(<<<'EOF' The %command.name% command dumps the current configuration for an @@ -95,7 +95,7 @@ EOF sprintf('Current configuration for %s', ($name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))) ); - $io->writeln(Yaml::dump(array($extensionAlias => $config), 10)); + $io->writeln(Yaml::dump([$extensionAlias => $config], 10)); return; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 96bcb51ba0..8640c0bacc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -39,11 +39,11 @@ class ConfigDumpReferenceCommand extends AbstractConfigCommand protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'), new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'), - )) + ]) ->setDescription('Dumps the default configuration for an extension') ->setHelp(<<<'EOF' The %command.name% command dumps the default configuration for an @@ -81,17 +81,17 @@ EOF if (null === $name = $input->getArgument('name')) { $this->listBundles($errorIo); - $errorIo->comment(array( + $errorIo->comment([ 'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. config:dump-reference FrameworkBundle)', 'For dumping a specific option, add its path as the second argument of this command. (e.g. config:dump-reference FrameworkBundle profiler.matcher to dump the framework.profiler.matcher configuration)', - )); + ]); return; } $extension = $this->findExtension($name); - $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder()); + $configuration = $extension->getConfiguration([], $this->getContainerBuilder()); $this->validateConfiguration($extension, $configuration); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php index 8749f7a30f..e61f543e7f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php @@ -45,11 +45,11 @@ class EventDispatcherDebugCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('event', InputArgument::OPTIONAL, 'An event name'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'), - )) + ]) ->setDescription('Displays configured listeners for an application') ->setHelp(<<<'EOF' The %command.name% command displays all configured listeners: @@ -73,7 +73,7 @@ EOF { $io = new SymfonyStyle($input, $output); - $options = array(); + $options = []; if ($event = $input->getArgument('event')) { if (!$this->dispatcher->hasListeners($event)) { $io->getErrorStyle()->warning(sprintf('The event "%s" does not have any registered listeners.', $event)); @@ -81,7 +81,7 @@ EOF return; } - $options = array('event' => $event); + $options = ['event' => $event]; } $helper = new DescriptorHelper(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index 55d3dea128..dd40352df7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -47,12 +47,12 @@ class RouterMatchCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'), new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method'), new InputOption('scheme', null, InputOption::VALUE_REQUIRED, 'Sets the URI scheme (usually http or https)'), new InputOption('host', null, InputOption::VALUE_REQUIRED, 'Sets the URI host'), - )) + ]) ->setDescription('Helps debug routes by simulating a path info match') ->setHelp(<<<'EOF' The %command.name% shows which routes match a given request and which don't and for what reason: @@ -100,7 +100,7 @@ EOF $io->success(sprintf('Route "%s" matches', $trace['name'])); $routerDebugCommand = $this->getApplication()->find('debug:router'); - $routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output); + $routerDebugCommand->run(new ArrayInput(['name' => $trace['name']]), $output); $matches = true; } elseif ($input->getOption('verbose')) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index dba01c8bea..c3cb53e270 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -67,14 +67,14 @@ class TranslationDebugCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'), new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Displays only missing messages'), new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Displays only unused messages'), new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'), - )) + ]) ->setDescription('Displays translation messages information') ->setHelp(<<<'EOF' The %command.name% command helps finding unused or missing translation @@ -123,11 +123,11 @@ EOF $kernel = $this->getApplication()->getKernel(); // Define Root Paths - $transPaths = array($kernel->getRootDir().'/Resources/translations'); + $transPaths = [$kernel->getRootDir().'/Resources/translations']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - $viewsPaths = array($kernel->getRootDir().'/Resources/views'); + $viewsPaths = [$kernel->getRootDir().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -136,20 +136,20 @@ EOF if (null !== $input->getArgument('bundle')) { try { $bundle = $kernel->getBundle($input->getArgument('bundle')); - $transPaths = array($bundle->getPath().'/Resources/translations'); + $transPaths = [$bundle->getPath().'/Resources/translations']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath.'/'.$bundle->getName(); } $transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName()); - $viewsPaths = array($bundle->getPath().'/Resources/views'); + $viewsPaths = [$bundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName(); } $viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName()); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path - $transPaths = array($input->getArgument('bundle').'/Resources/translations'); - $viewsPaths = array($input->getArgument('bundle').'/Resources/views'); + $transPaths = [$input->getArgument('bundle').'/Resources/translations']; + $viewsPaths = [$input->getArgument('bundle').'/Resources/views']; if (!is_dir($transPaths[0])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); @@ -180,7 +180,7 @@ EOF $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue); $allMessages = $mergeOperation->getResult()->all($domain); if (null !== $domain) { - $allMessages = array($domain => $allMessages); + $allMessages = [$domain => $allMessages]; } // No defined or extracted messages @@ -200,16 +200,16 @@ EOF $fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths); // Display header line - $headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)); + $headers = ['State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)]; foreach ($fallbackCatalogues as $fallbackCatalogue) { $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale()); } - $rows = array(); + $rows = []; // Iterate all message ids and determine their state foreach ($allMessages as $domain => $messages) { foreach (array_keys($messages) as $messageId) { $value = $currentCatalogue->get($messageId, $domain); - $states = array(); + $states = []; if ($extractedCatalogue->defines($messageId, $domain)) { if (!$currentCatalogue->defines($messageId, $domain)) { @@ -232,7 +232,7 @@ EOF } } - $row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)); + $row = [$this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)]; foreach ($fallbackCatalogues as $fallbackCatalogue) { $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain)); } @@ -263,7 +263,7 @@ EOF private function formatStates(array $states): string { - $result = array(); + $result = []; foreach ($states as $state) { $result[] = $this->formatState($state); } @@ -320,7 +320,7 @@ EOF */ private function loadFallbackCatalogues(string $locale, array $transPaths): array { - $fallbackCatalogues = array(); + $fallbackCatalogues = []; if ($this->translator instanceof Translator || $this->translator instanceof DataCollectorTranslator || $this->translator instanceof LoggingTranslator) { foreach ($this->translator->getFallbackLocales() as $fallbackLocale) { if ($fallbackLocale === $locale) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index e1e260a045..95ba8b3507 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -63,7 +63,7 @@ class TranslationUpdateCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'), @@ -73,7 +73,7 @@ class TranslationUpdateCommand extends Command new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Should backup be disabled'), new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'), - )) + ]) ->setDescription('Updates the translation file') ->setHelp(<<<'EOF' The %command.name% command extracts translation strings from templates @@ -112,7 +112,7 @@ EOF // check format $supportedFormats = $this->writer->getFormats(); if (!\in_array($input->getOption('output-format'), $supportedFormats)) { - $errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.')); + $errorIo->error(['Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.']); return 1; } @@ -120,11 +120,11 @@ EOF $kernel = $this->getApplication()->getKernel(); // Define Root Paths - $transPaths = array($kernel->getRootDir().'/Resources/translations'); + $transPaths = [$kernel->getRootDir().'/Resources/translations']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - $viewsPaths = array($kernel->getRootDir().'/Resources/views'); + $viewsPaths = [$kernel->getRootDir().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -134,12 +134,12 @@ EOF if (null !== $input->getArgument('bundle')) { try { $foundBundle = $kernel->getBundle($input->getArgument('bundle')); - $transPaths = array($foundBundle->getPath().'/Resources/translations'); + $transPaths = [$foundBundle->getPath().'/Resources/translations']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName(); } $transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $foundBundle->getName()); - $viewsPaths = array($foundBundle->getPath().'/Resources/views'); + $viewsPaths = [$foundBundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName(); } @@ -147,8 +147,8 @@ EOF $currentName = $foundBundle->getName(); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path - $transPaths = array($input->getArgument('bundle').'/Resources/translations'); - $viewsPaths = array($input->getArgument('bundle').'/Resources/views'); + $transPaths = [$input->getArgument('bundle').'/Resources/translations']; + $viewsPaths = [$input->getArgument('bundle').'/Resources/views']; $currentName = $transPaths[0]; if (!is_dir($transPaths[0])) { @@ -250,7 +250,7 @@ EOF $bundleTransPath = end($transPaths); } - $this->writer->write($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale)); + $this->writer->write($operation->getResult(), $input->getOption('output-format'), ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale]); if (true === $input->getOption('dump-messages')) { $resultMessage .= ' and translation files were updated'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index 07f27563a2..d3f24d2b95 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -37,7 +37,7 @@ abstract class Descriptor implements DescriptorInterface /** * {@inheritdoc} */ - public function describe(OutputInterface $output, $object, array $options = array()) + public function describe(OutputInterface $output, $object, array $options = []) { $this->output = $output; @@ -104,22 +104,22 @@ abstract class Descriptor implements DescriptorInterface /** * Describes an InputArgument instance. */ - abstract protected function describeRouteCollection(RouteCollection $routes, array $options = array()); + abstract protected function describeRouteCollection(RouteCollection $routes, array $options = []); /** * Describes an InputOption instance. */ - abstract protected function describeRoute(Route $route, array $options = array()); + abstract protected function describeRoute(Route $route, array $options = []); /** * Describes container parameters. */ - abstract protected function describeContainerParameters(ParameterBag $parameters, array $options = array()); + abstract protected function describeContainerParameters(ParameterBag $parameters, array $options = []); /** * Describes container tags. */ - abstract protected function describeContainerTags(ContainerBuilder $builder, array $options = array()); + abstract protected function describeContainerTags(ContainerBuilder $builder, array $options = []); /** * Describes a container service by its name. @@ -131,7 +131,7 @@ abstract class Descriptor implements DescriptorInterface * @param array $options * @param ContainerBuilder|null $builder */ - abstract protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null); + abstract protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null); /** * Describes container services. @@ -139,22 +139,22 @@ abstract class Descriptor implements DescriptorInterface * Common options are: * * tag: filters described services by given tag */ - abstract protected function describeContainerServices(ContainerBuilder $builder, array $options = array()); + abstract protected function describeContainerServices(ContainerBuilder $builder, array $options = []); /** * Describes a service definition. */ - abstract protected function describeContainerDefinition(Definition $definition, array $options = array()); + abstract protected function describeContainerDefinition(Definition $definition, array $options = []); /** * Describes a service alias. */ - abstract protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null); + abstract protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null); /** * Describes a container parameter. */ - abstract protected function describeContainerParameter($parameter, array $options = array()); + abstract protected function describeContainerParameter($parameter, array $options = []); /** * Describes event dispatcher listeners. @@ -162,7 +162,7 @@ abstract class Descriptor implements DescriptorInterface * Common options are: * * name: name of listened event */ - abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()); + abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []); /** * Describes a callable. @@ -170,7 +170,7 @@ abstract class Descriptor implements DescriptorInterface * @param callable $callable * @param array $options */ - abstract protected function describeCallable($callable, array $options = array()); + abstract protected function describeCallable($callable, array $options = []); /** * Formats a value as string. @@ -247,7 +247,7 @@ abstract class Descriptor implements DescriptorInterface */ protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden) { - $definitions = array(); + $definitions = []; $tags = $builder->findTags(); asort($tags); @@ -260,7 +260,7 @@ abstract class Descriptor implements DescriptorInterface } if (!isset($definitions[$tag])) { - $definitions[$tag] = array(); + $definitions[$tag] = []; } $definitions[$tag][$serviceId] = $definition; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index d5958f7317..57af09f930 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -30,7 +30,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeRouteCollection(RouteCollection $routes, array $options = array()) + protected function describeRouteCollection(RouteCollection $routes, array $options = []) { $first = true; foreach ($routes->all() as $name => $route) { @@ -39,7 +39,7 @@ class MarkdownDescriptor extends Descriptor } else { $this->write("\n\n"); } - $this->describeRoute($route, array('name' => $name)); + $this->describeRoute($route, ['name' => $name]); } $this->write("\n"); } @@ -47,7 +47,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeRoute(Route $route, array $options = array()) + protected function describeRoute(Route $route, array $options = []) { $output = '- Path: '.$route->getPath() ."\n".'- Path Regex: '.$route->compile()->getRegex() @@ -69,7 +69,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) + protected function describeContainerParameters(ParameterBag $parameters, array $options = []) { $this->write("Container parameters\n====================\n"); foreach ($this->sortParameters($parameters) as $key => $value) { @@ -80,7 +80,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) + protected function describeContainerTags(ContainerBuilder $builder, array $options = []) { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; $this->write("Container tags\n=============="); @@ -89,7 +89,7 @@ class MarkdownDescriptor extends Descriptor $this->write("\n\n".$tag."\n".str_repeat('-', \strlen($tag))); foreach ($definitions as $serviceId => $definition) { $this->write("\n\n"); - $this->describeContainerDefinition($definition, array('omit_tags' => true, 'id' => $serviceId)); + $this->describeContainerDefinition($definition, ['omit_tags' => true, 'id' => $serviceId]); } } } @@ -97,13 +97,13 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null) + protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null) { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } - $childOptions = array_merge($options, array('id' => $options['id'], 'as_array' => true)); + $childOptions = array_merge($options, ['id' => $options['id'], 'as_array' => true]); if ($service instanceof Alias) { $this->describeContainerAlias($service, $childOptions, $builder); @@ -117,7 +117,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) + protected function describeContainerServices(ContainerBuilder $builder, array $options = []) { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; @@ -129,7 +129,7 @@ class MarkdownDescriptor extends Descriptor $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); $showArguments = isset($options['show_arguments']) && $options['show_arguments']; - $services = array('definitions' => array(), 'aliases' => array(), 'services' => array()); + $services = ['definitions' => [], 'aliases' => [], 'services' => []]; if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); @@ -155,7 +155,7 @@ class MarkdownDescriptor extends Descriptor $this->write("\n\nDefinitions\n-----------\n"); foreach ($services['definitions'] as $id => $service) { $this->write("\n"); - $this->describeContainerDefinition($service, array('id' => $id, 'show_arguments' => $showArguments)); + $this->describeContainerDefinition($service, ['id' => $id, 'show_arguments' => $showArguments]); } } @@ -163,7 +163,7 @@ class MarkdownDescriptor extends Descriptor $this->write("\n\nAliases\n-------\n"); foreach ($services['aliases'] as $id => $service) { $this->write("\n"); - $this->describeContainerAlias($service, array('id' => $id)); + $this->describeContainerAlias($service, ['id' => $id]); } } @@ -179,7 +179,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerDefinition(Definition $definition, array $options = array()) + protected function describeContainerDefinition(Definition $definition, array $options = []) { $output = '- Class: `'.$definition->getClass().'`' ."\n".'- Public: '.($definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no') @@ -236,7 +236,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) { $output = '- Service: `'.$alias.'`' ."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no'); @@ -252,13 +252,13 @@ class MarkdownDescriptor extends Descriptor } $this->write("\n"); - $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, array('id' => (string) $alias))); + $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias])); } /** * {@inheritdoc} */ - protected function describeContainerParameter($parameter, array $options = array()) + protected function describeContainerParameter($parameter, array $options = []) { $this->write(isset($options['parameter']) ? sprintf("%s\n%s\n\n%s", $options['parameter'], str_repeat('=', \strlen($options['parameter'])), $this->formatParameter($parameter)) : $parameter); } @@ -266,7 +266,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) + protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { $event = array_key_exists('event', $options) ? $options['event'] : null; @@ -302,7 +302,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeCallable($callable, array $options = array()) + protected function describeCallable($callable, array $options = []) { $string = ''; diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 8ad78f9f85..d669771a59 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -60,7 +60,7 @@ class RedirectController throw new HttpException($permanent ? 410 : 404); } - $attributes = array(); + $attributes = []; if (false === $ignoreAttributes || \is_array($ignoreAttributes)) { $attributes = $request->attributes->get('_route_params'); $attributes = $keepQueryParams ? array_merge($request->query->all(), $attributes) : $attributes; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php index 69038cf92f..b4da145010 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddDebugLogProcessorPass.php @@ -30,6 +30,6 @@ class AddDebugLogProcessorPass implements CompilerPassInterface } $definition = $container->getDefinition('monolog.logger_prototype'); - $definition->addMethodCall('pushProcessor', array(new Reference('debug.log_processor'))); + $definition->addMethodCall('pushProcessor', [new Reference('debug.log_processor')]); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php index a5bdfd626f..77c0700599 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php @@ -31,7 +31,7 @@ class AddExpressionLanguageProvidersPass implements CompilerPassInterface if ($container->has('router')) { $definition = $container->findDefinition('router'); foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) { - $definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id))); + $definition->addMethodCall('addExpressionLanguageProvider', [new Reference($id)]); } } @@ -39,7 +39,7 @@ class AddExpressionLanguageProvidersPass implements CompilerPassInterface if ($container->has('security.expression_language')) { $definition = $container->findDefinition('security.expression_language'); foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) { - $definition->addMethodCall('registerProvider', array(new Reference($id))); + $definition->addMethodCall('registerProvider', [new Reference($id)]); } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php index bd6908b9c4..9f9b907b24 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php @@ -29,7 +29,7 @@ final class CachePoolClearerPass implements CompilerPassInterface foreach ($container->findTaggedServiceIds('cache.pool.clearer') as $id => $attr) { $clearer = $container->getDefinition($id); - $pools = array(); + $pools = []; foreach ($clearer->getArgument(0) as $id => $ref) { if ($container->hasDefinition($id)) { $pools[$id] = new Reference($id); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php index b515bcb69c..ecf43b6f83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php @@ -37,14 +37,14 @@ class CachePoolPass implements CompilerPassInterface } $seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment'); - $pools = array(); - $clearers = array(); - $attributes = array( + $pools = []; + $clearers = []; + $attributes = [ 'provider', 'namespace', 'default_lifetime', 'reset', - ); + ]; foreach ($container->findTaggedServiceIds('cache.pool') as $id => $tags) { $adapter = $pool = $container->getDefinition($id); if ($pool->isAbstract()) { @@ -78,7 +78,7 @@ class CachePoolPass implements CompilerPassInterface // no-op } elseif ('reset' === $attr) { if ($tags[0][$attr]) { - $pool->addTag('kernel.reset', array('method' => $tags[0][$attr])); + $pool->addTag('kernel.reset', ['method' => $tags[0][$attr]]); } } elseif ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass()) { $pool->replaceArgument($i++, $tags[0][$attr]); @@ -137,8 +137,8 @@ class CachePoolPass implements CompilerPassInterface if (!$container->hasDefinition($name = '.cache_connection.'.ContainerBuilder::hash($dsn))) { $definition = new Definition(AbstractAdapter::class); $definition->setPublic(false); - $definition->setFactory(array(AbstractAdapter::class, 'createConnection')); - $definition->setArguments(array($dsn, array('lazy' => true))); + $definition->setFactory([AbstractAdapter::class, 'createConnection']); + $definition->setArguments([$dsn, ['lazy' => true]]); $container->setDefinition($name, $definition); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php index 66d42f54e9..de8f2ed06d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php @@ -41,7 +41,7 @@ class CachePoolPrunerPass implements CompilerPassInterface return; } - $services = array(); + $services = []; foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $tags) { $class = $container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass()); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php index 4945e1c12e..8866035637 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php @@ -47,7 +47,7 @@ class LoggingTranslatorPass implements CompilerPassInterface $warmer->addTag('container.service_subscriber', $v); } } - $warmer->addTag('container.service_subscriber', array('key' => 'translator', 'id' => 'translator.logging.inner')); + $warmer->addTag('container.service_subscriber', ['key' => 'translator', 'id' => 'translator.logging.inner']); } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php index 8e15979a90..357c079c4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php @@ -41,15 +41,15 @@ class ProfilerPass implements CompilerPassInterface if (!isset($attributes[0]['id'])) { throw new InvalidArgumentException(sprintf('Data collector service "%s" must have an id attribute in order to specify a template', $id)); } - $template = array($attributes[0]['id'], $attributes[0]['template']); + $template = [$attributes[0]['id'], $attributes[0]['template']]; } - $collectors->insert(array($id, $template), array($priority, --$order)); + $collectors->insert([$id, $template], [$priority, --$order]); } - $templates = array(); + $templates = []; foreach ($collectors as $collector) { - $definition->addMethodCall('add', array(new Reference($collector[0]))); + $definition->addMethodCall('add', [new Reference($collector[0])]); $templates[$collector[0]] = $collector[1]; } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php index 8de51211d3..4eff0b6c8e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php @@ -32,8 +32,8 @@ class TemplatingPass implements CompilerPassInterface } if ($container->hasDefinition('templating.engine.php')) { - $refs = array(); - $helpers = array(); + $refs = []; + $helpers = []; foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) { if (isset($attributes[0]['alias'])) { $helpers[$attributes[0]['alias']] = $id; @@ -43,7 +43,7 @@ class TemplatingPass implements CompilerPassInterface if (\count($helpers) > 0) { $definition = $container->getDefinition('templating.engine.php'); - $definition->addMethodCall('setHelpers', array($helpers)); + $definition->addMethodCall('setHelpers', [$helpers]); if ($container->hasDefinition('templating.engine.php.helpers_locator')) { $container->getDefinition('templating.engine.php.helpers_locator')->replaceArgument(0, $refs); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php index 14c97cfaef..431d945985 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php @@ -21,7 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; */ class UnusedTagsPass implements CompilerPassInterface { - private $whitelist = array( + private $whitelist = [ 'annotations.cached_reader', 'cache.pool.clearer', 'console.command', @@ -59,7 +59,7 @@ class UnusedTagsPass implements CompilerPassInterface 'twig.loader', 'validator.constraint_validator', 'validator.initializer', - ); + ]; public function process(ContainerBuilder $container) { @@ -72,7 +72,7 @@ class UnusedTagsPass implements CompilerPassInterface } // check for typos - $candidates = array(); + $candidates = []; foreach ($tags as $definedTag) { if ($definedTag === $tag) { continue; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/WorkflowGuardListenerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/WorkflowGuardListenerPass.php index c5498adc47..ad62e19384 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/WorkflowGuardListenerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/WorkflowGuardListenerPass.php @@ -32,12 +32,12 @@ class WorkflowGuardListenerPass implements CompilerPassInterface $container->getParameterBag()->remove('workflow.has_guard_listeners'); - $servicesNeeded = array( + $servicesNeeded = [ 'security.token_storage', 'security.authorization_checker', 'security.authentication.trust_resolver', 'security.role_hierarchy', - ); + ]; foreach ($servicesNeeded as $service) { if (!$container->has($service)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/ResolveControllerNameSubscriber.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/ResolveControllerNameSubscriber.php index d4186daef6..e68ef896dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/ResolveControllerNameSubscriber.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/ResolveControllerNameSubscriber.php @@ -43,8 +43,8 @@ class ResolveControllerNameSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 24), - ); + return [ + KernelEvents::REQUEST => ['onKernelRequest', 24], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 506644d5fa..3ca97b8bc7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -78,13 +78,13 @@ class FrameworkBundle extends Bundle { parent::build($container); - $hotPathEvents = array( + $hotPathEvents = [ KernelEvents::REQUEST, KernelEvents::CONTROLLER, KernelEvents::CONTROLLER_ARGUMENTS, KernelEvents::RESPONSE, KernelEvents::FINISH_REQUEST, - ); + ]; $container->addCompilerPass(new LoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); $container->addCompilerPass(new RegisterControllerArgumentLocatorsPass()); diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index 67853ac5ab..e4a630fb48 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -37,7 +37,7 @@ class HttpCache extends BaseHttpCache $this->kernel = $kernel; $this->cacheDir = $cacheDir; - parent::__construct($kernel, $this->createStore(), $this->createSurrogate(), array_merge(array('debug' => $kernel->isDebug()), $this->getOptions())); + parent::__construct($kernel, $this->createStore(), $this->createSurrogate(), array_merge(['debug' => $kernel->isDebug()], $this->getOptions())); } /** @@ -64,7 +64,7 @@ class HttpCache extends BaseHttpCache */ protected function getOptions() { - return array(); + return []; } protected function createSurrogate() diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/attributes.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/attributes.html.php index a9bd62f2a1..dbed8eff72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/attributes.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/attributes.html.php @@ -1,6 +1,6 @@ $v): ?> -escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?> +escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, [], $translation_domain) : $v)) ?> escape($k), $view->escape($k)) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php index 4b63876984..2a10aa0f41 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php @@ -1,4 +1,4 @@ $name, '%id%' => $id)) + ? strtr($label_format, ['%name%' => $name, '%id%' => $id]) : $view['form']->humanize($name); } ?> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php index 92298cf5fc..c63d354e17 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php @@ -2,17 +2,17 @@ - block($form, 'widget_attributes', array( + block($form, 'widget_attributes', [ 'required' => $required, - )) ?> + ]) ?> multiple="multiple" > - + 0): ?> - block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?> + block($form, 'choice_widget_options', ['choices' => $preferred_choices]) ?> 0 && null !== $separator): ?> - block($form, 'choice_widget_options', array('choices' => $choices)) ?> + block($form, 'choice_widget_options', ['choices' => $choices]) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php index 2c42687207..9691759a90 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php @@ -1,6 +1,6 @@
block($form, 'widget_container_attributes') ?>> widget($child) ?> - label($child, null, array('translation_domain' => $choice_translation_domain)) ?> + label($child, null, ['translation_domain' => $choice_translation_domain]) ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_options.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_options.html.php index f1c6ad3b56..a19b5a5e6e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_options.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_options.html.php @@ -4,10 +4,10 @@ $translatorHelper = $view['translator']; // outside of the loop for performance $choice): ?> - - block($form, 'choice_widget_options', array('choices' => $choice)) ?> + + block($form, 'choice_widget_options', ['choices' => $choice]) ?> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/collection_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/collection_widget.html.php index 9f6a94bcef..40dfdaf1f0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/collection_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/collection_widget.html.php @@ -1,4 +1,4 @@ escape($view['form']->row($prototype)) ?> -widget($form, array('attr' => $attr)) ?> +widget($form, ['attr' => $attr]) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/color_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/color_widget.html.php index 10a8cdf149..48f5c2c30d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/color_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/color_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'color')); +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'color']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php index 22e51d2735..fbd844f286 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php @@ -2,10 +2,10 @@ block($form, 'form_widget_simple'); ?>
block($form, 'widget_container_attributes') ?>> - widget($form['year']), $view['form']->widget($form['month']), $view['form']->widget($form['day']), - ), $date_pattern) ?> + ], $date_pattern) ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php index 0b30c5bb7a..fa6b0ee8a1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'email')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'email']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php index 78c953ec5a..8e8e5b9498 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php @@ -2,7 +2,7 @@ $name, '%id%' => $id)) + ? strtr($label_format, ['%name%' => $name, '%id%' => $id]) : $view['form']->humanize($name); } ?> -block($form, 'attributes', array('attr' => $label_attr)); } ?>>escape(false !== $translation_domain ? $view['translator']->trans($label, array(), $translation_domain) : $label) ?> +block($form, 'attributes', ['attr' => $label_attr]); } ?>>escape(false !== $translation_domain ? $view['translator']->trans($label, [], $translation_domain) : $label) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php index a43f7de475..6bcbb5e046 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'hidden')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'hidden']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/integer_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/integer_widget.html.php index 5fceb49a38..faaff51e67 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/integer_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/integer_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'number')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'number']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php index bf4a4c4785..3d6f79c63b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php index ec96cfb46b..5514468f6a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'password')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'password']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php index 8519da429b..f5839ebf70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/percent_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'text')) ?> % +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'text']) ?> % diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php index 4c628f8e00..d6650d8154 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'range')); +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'range']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php index e8fa18e488..af45b15669 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php @@ -1 +1 @@ -block($form, 'button_widget', array('type' => isset($type) ? $type : 'reset')) ?> +block($form, 'button_widget', ['type' => isset($type) ? $type : 'reset']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/search_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/search_widget.html.php index 48a33f4aa2..191279b517 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/search_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/search_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'search')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'search']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php index 6bf71f5a1e..baea833326 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php @@ -1 +1 @@ -block($form, 'button_widget', array('type' => isset($type) ? $type : 'submit')) ?> +block($form, 'button_widget', ['type' => isset($type) ? $type : 'submit']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/tel_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/tel_widget.html.php index 7779538127..dd471b9518 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/tel_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/tel_widget.html.php @@ -1 +1 @@ -block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'tel')); +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'tel']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php index e24411cd74..cd2f559601 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php @@ -1,7 +1,7 @@ block($form, 'form_widget_simple'); ?> - array('size' => 1)) : array() ?> + ['size' => 1]] : [] ?>
block($form, 'widget_container_attributes') ?>> block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'url')) ?> +block($form, 'form_widget_simple', ['type' => isset($type) ? $type : 'url']) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php index 474c725566..51419c8914 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php @@ -43,14 +43,14 @@ class AnnotatedRouteControllerLoader extends AnnotationClassLoader */ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { - return preg_replace(array( + return preg_replace([ '/(bundle|controller)_/', '/action(_\d+)?$/', '/__/', - ), array( + ], [ '_', '\\1', '_', - ), parent::getDefaultRouteName($class, $method)); + ], parent::getDefaultRouteName($class, $method)); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php index 5571c74e81..fd1594c883 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php @@ -29,7 +29,7 @@ class RedirectableUrlMatcher extends BaseMatcher */ public function redirect($path, $route, $scheme = null) { - return array( + return [ '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', 'path' => $path, 'permanent' => true, @@ -37,6 +37,6 @@ class RedirectableUrlMatcher extends BaseMatcher 'httpPort' => $this->context->getHttpPort(), 'httpsPort' => $this->context->getHttpsPort(), '_route' => $route, - ); + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php index 07bf39f5b4..f40760fc91 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php @@ -43,7 +43,7 @@ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface /** * {@inheritdoc} */ - public function renderResponse($view, array $parameters = array(), Response $response = null) + public function renderResponse($view, array $parameters = [], Response $response = null) { $engine = $this->getEngine($view); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php b/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php index cc0d573ee2..0b3a8b3200 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php @@ -32,5 +32,5 @@ interface EngineInterface extends BaseEngineInterface * * @throws \RuntimeException if the template cannot be rendered */ - public function renderResponse($view, array $parameters = array(), Response $response = null); + public function renderResponse($view, array $parameters = [], Response $response = null); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php index 76a6046d9b..70e5a314bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php @@ -39,7 +39,7 @@ class ActionsHelper extends Helper * * @see FragmentHandler::render() */ - public function render($uri, array $options = array()) + public function render($uri, array $options = []) { $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); @@ -47,7 +47,7 @@ class ActionsHelper extends Helper return $this->handler->render($uri, $strategy, $options); } - public function controller($controller, $attributes = array(), $query = array()) + public function controller($controller, $attributes = [], $query = []) { return new ControllerReference($controller, $attributes, $query); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index a1cddf2808..49add1f31f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -78,7 +78,7 @@ class CodeHelper extends Helper */ public function formatArgs(array $args) { - $result = array(); + $result = []; foreach ($args as $key => $item) { if ('object' === $item[0]) { $parts = explode('\\', $item[1]); @@ -131,7 +131,7 @@ class CodeHelper extends Helper $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); $content = explode('
', $code); - $lines = array(); + $lines = []; for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) { $lines[] = ''.self::fixCodeMarkup($content[$i - 1]).''; } @@ -157,7 +157,7 @@ class CodeHelper extends Helper $file = trim($file); $fileStr = $file; if (0 === strpos($fileStr, $this->rootDir)) { - $fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr); + $fileStr = str_replace(['\\', $this->rootDir], ['/', ''], $fileStr); $fileStr = htmlspecialchars($fileStr, $flags, $this->charset); $fileStr = sprintf('kernel.root_dir/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr); } @@ -183,7 +183,7 @@ class CodeHelper extends Helper public function getFileLink($file, $line) { if ($fmt = $this->fileLinkFormat) { - return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); + return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); } return false; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php index 23b5c4e91e..dd1d14149a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php @@ -61,9 +61,9 @@ class FormHelper extends Helper * * You can pass options during the call: * - * form($form, array('attr' => array('class' => 'foo'))) ?> + * form($form, ['attr' => ['class' => 'foo']]) ?> * - * form($form, array('separator' => '+++++')) ?> + * form($form, ['separator' => '+++++']) ?> * * This method is mainly intended for prototyping purposes. If you want to * control the layout of a form in a more fine-grained manner, you are @@ -76,7 +76,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function form(FormView $view, array $variables = array()) + public function form(FormView $view, array $variables = []) { return $this->renderer->renderBlock($view, 'form', $variables); } @@ -93,7 +93,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function start(FormView $view, array $variables = array()) + public function start(FormView $view, array $variables = []) { return $this->renderer->renderBlock($view, 'form_start', $variables); } @@ -110,7 +110,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function end(FormView $view, array $variables = array()) + public function end(FormView $view, array $variables = []) { return $this->renderer->renderBlock($view, 'form_end', $variables); } @@ -124,16 +124,16 @@ class FormHelper extends Helper * * You can pass options during the call: * - * widget($form, array('attr' => array('class' => 'foo'))) ?> + * widget($form, ['attr' => ['class' => 'foo']]) ?> * - * widget($form, array('separator' => '+++++')) ?> + * widget($form, ['separator' => '+++++']) ?> * * @param FormView $view The view for which to render the widget * @param array $variables Additional variables passed to the template * * @return string The HTML markup */ - public function widget(FormView $view, array $variables = array()) + public function widget(FormView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables); } @@ -146,7 +146,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function row(FormView $view, array $variables = array()) + public function row(FormView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'row', $variables); } @@ -160,10 +160,10 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function label(FormView $view, $label = null, array $variables = array()) + public function label(FormView $view, $label = null, array $variables = []) { if (null !== $label) { - $variables += array('label' => $label); + $variables += ['label' => $label]; } return $this->renderer->searchAndRenderBlock($view, 'label', $variables); @@ -199,7 +199,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function rest(FormView $view, array $variables = array()) + public function rest(FormView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'rest', $variables); } @@ -213,7 +213,7 @@ class FormHelper extends Helper * * @return string The HTML markup */ - public function block(FormView $view, $blockName, array $variables = array()) + public function block(FormView $view, $blockName, array $variables = []) { return $this->renderer->renderBlock($view, $blockName, $variables); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php index 683efd5974..f242479086 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php @@ -39,7 +39,7 @@ class RouterHelper extends Helper * * @see UrlGeneratorInterface */ - public function path($name, $parameters = array(), $relative = false) + public function path($name, $parameters = [], $relative = false) { return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); } @@ -55,7 +55,7 @@ class RouterHelper extends Helper * * @see UrlGeneratorInterface */ - public function url($name, $parameters = array(), $schemeRelative = false) + public function url($name, $parameters = [], $schemeRelative = false) { return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php index 4de6e7eec0..072c1d3d21 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php @@ -42,7 +42,7 @@ class SessionHelper extends Helper return $this->getSession()->get($name, $default); } - public function getFlash($name, array $default = array()) + public function getFlash($name, array $default = []) { return $this->getSession()->getFlashBag()->get($name, $default); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php index 72269ec69d..55232c4620 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php @@ -33,11 +33,11 @@ class StopwatchHelper extends Helper return 'stopwatch'; } - public function __call($method, $arguments = array()) + public function __call($method, $arguments = []) { if (null !== $this->stopwatch) { if (method_exists($this->stopwatch, $method)) { - return \call_user_func_array(array($this->stopwatch, $method), $arguments); + return \call_user_func_array([$this->stopwatch, $method], $arguments); } throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php index 5c4a9ae0fa..4846cb1101 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php @@ -29,7 +29,7 @@ class TranslatorHelper extends Helper /** * @see TranslatorInterface::trans() */ - public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) + public function trans($id, array $parameters = [], $domain = 'messages', $locale = null) { return $this->translator->trans($id, $parameters, $domain, $locale); } @@ -37,7 +37,7 @@ class TranslatorHelper extends Helper /** * @see TranslatorInterface::transChoice() */ - public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) + public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null) { return $this->translator->transChoice($id, $number, $parameters, $domain, $locale); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php index 8f9b256d6a..4e4743dcc5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php @@ -24,7 +24,7 @@ class TemplateLocator implements FileLocatorInterface protected $locator; protected $cache; - private $cacheHits = array(); + private $cacheHits = []; /** * @param FileLocatorInterface $locator A FileLocatorInterface instance diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php index bad7c17931..ef9c43b8fd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php @@ -65,7 +65,7 @@ class PhpEngine extends BasePhpEngine implements EngineInterface /** * {@inheritdoc} */ - public function renderResponse($view, array $parameters = array(), Response $response = null) + public function renderResponse($view, array $parameters = [], Response $response = null) { if (null === $response) { $response = new Response(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 726c2a2a30..d1be3e9074 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -25,7 +25,7 @@ use Symfony\Component\Templating\TemplateReferenceInterface; class TemplateNameParser extends BaseTemplateNameParser { protected $kernel; - protected $cache = array(); + protected $cache = []; public function __construct(KernelInterface $kernel) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php index d03e4f59b8..830942972a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php @@ -22,13 +22,13 @@ class TemplateReference extends BaseTemplateReference { public function __construct(string $bundle = null, string $controller = null, string $name = null, string $format = null, string $engine = null) { - $this->parameters = array( + $this->parameters = [ 'bundle' => $bundle, 'controller' => $controller, 'name' => $name, 'format' => $format, 'engine' => $engine, - ); + ]; } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php index 3263ea24d0..783e675f97 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php @@ -35,7 +35,7 @@ class TimedPhpEngine extends PhpEngine /** * {@inheritdoc} */ - public function render($name, array $parameters = array()) + public function render($name, array $parameters = []) { $e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index 351d27900e..ed321be11b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -59,7 +59,7 @@ abstract class KernelTestCase extends TestCase * * @return KernelInterface A KernelInterface instance */ - protected static function bootKernel(array $options = array()) + protected static function bootKernel(array $options = []) { static::ensureKernelShutdown(); @@ -82,7 +82,7 @@ abstract class KernelTestCase extends TestCase * * @return KernelInterface A KernelInterface instance */ - protected static function createKernel(array $options = array()) + protected static function createKernel(array $options = []) { if (null === static::$class) { static::$class = static::getKernelClass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 7302dc78aa..e56e938dd9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -29,7 +29,7 @@ abstract class WebTestCase extends KernelTestCase * * @return Client A Client instance */ - protected static function createClient(array $options = array(), array $server = array()) + protected static function createClient(array $options = [], array $server = []) { $kernel = static::bootKernel($options); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index b32274e7e7..9cc3bfa2d2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -34,7 +34,7 @@ class AnnotationsCacheWarmerTest extends TestCase public function testAnnotationsCacheWarmerWithDebugDisabled() { - file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); $reader = new AnnotationReader(); $fallbackPool = new ArrayAdapter(); @@ -60,7 +60,7 @@ class AnnotationsCacheWarmerTest extends TestCase public function testAnnotationsCacheWarmerWithDebugEnabled() { - file_put_contents($this->cacheDir.'/annotations.map', sprintf('cacheDir.'/annotations.map', sprintf('cacheDir, __FUNCTION__); $reader = new AnnotationReader(); $fallbackPool = new ArrayAdapter(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php index fdd40d48d6..50a5abf0ae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -28,10 +28,10 @@ class SerializerCacheWarmerTest extends TestCase $this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.'); } - $loaders = array( + $loaders = [ new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'), new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'), - ); + ]; $file = sys_get_temp_dir().'/cache-serializer.php'; @unlink($file); @@ -67,7 +67,7 @@ class SerializerCacheWarmerTest extends TestCase $fallbackPool = new ArrayAdapter(); - $warmer = new SerializerCacheWarmer(array(), $file, $fallbackPool); + $warmer = new SerializerCacheWarmer([], $file, $fallbackPool); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 5da592c356..94b5432c3a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -34,7 +34,7 @@ class TemplateFinderTest extends TestCase $kernel ->expects($this->once()) ->method('getBundles') - ->will($this->returnValue(array('BaseBundle' => new BaseBundle()))) + ->will($this->returnValue(['BaseBundle' => new BaseBundle()])) ; $parser = new TemplateFilenameParser(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 75d5934c79..30d0242663 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -39,13 +39,13 @@ class TemplatePathsCacheWarmerTest extends TestCase { $this->templateFinder = $this ->getMockBuilder(TemplateFinderInterface::class) - ->setMethods(array('findAllTemplates')) + ->setMethods(['findAllTemplates']) ->getMock(); $this->fileLocator = $this ->getMockBuilder(FileLocator::class) - ->setMethods(array('locate')) - ->setConstructorArgs(array('/path/to/fallback')) + ->setMethods(['locate']) + ->setConstructorArgs(['/path/to/fallback']) ->getMock(); $this->templateLocator = new TemplateLocator($this->fileLocator); @@ -68,7 +68,7 @@ class TemplatePathsCacheWarmerTest extends TestCase $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue(array($template))); + ->will($this->returnValue([$template])); $this->fileLocator ->expects($this->once()) @@ -87,7 +87,7 @@ class TemplatePathsCacheWarmerTest extends TestCase $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $this->fileLocator ->expects($this->never()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php index d021b0a29a..ba253d1d1f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php @@ -54,7 +54,7 @@ class ClientTest extends WebTestCase private function getKernelMock() { $mock = $this->getMockBuilder($this->getKernelClass()) - ->setMethods(array('shutdown', 'boot', 'handle')) + ->setMethods(['shutdown', 'boot', 'handle']) ->disableOriginalConstructor() ->getMock(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index 1b376e51b4..8a6f3b1fb6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -45,7 +45,7 @@ class CacheClearCommandTest extends TestCase public function testCacheIsFreshAfterCacheClearedWithWarmup() { - $input = new ArrayInput(array('cache:clear')); + $input = new ArrayInput(['cache:clear']); $application = new Application($this->kernel); $application->setCatchExceptions(false); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index 213d75ecc6..1022b31a4f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php @@ -21,9 +21,9 @@ class TestAppKernel extends Kernel { public function registerBundles() { - return array( + return [ new FrameworkBundle(), - ); + ]; } public function setRootDir($rootDir) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php index d13e120442..693fdfa101 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php @@ -24,13 +24,13 @@ class CachePruneCommandTest extends TestCase public function testCommandWithPools() { $tester = $this->getCommandTester($this->getKernel(), $this->getRewindableGenerator()); - $tester->execute(array()); + $tester->execute([]); } public function testCommandWithNoPools() { $tester = $this->getCommandTester($this->getKernel(), $this->getEmptyRewindableGenerator()); - $tester->execute(array()); + $tester->execute([]); } private function getRewindableGenerator(): RewindableGenerator @@ -44,7 +44,7 @@ class CachePruneCommandTest extends TestCase private function getEmptyRewindableGenerator(): RewindableGenerator { return new RewindableGenerator(function () { - return new \ArrayIterator(array()); + return new \ArrayIterator([]); }, 0); } @@ -69,7 +69,7 @@ class CachePruneCommandTest extends TestCase $kernel ->expects($this->once()) ->method('getBundles') - ->willReturn(array()); + ->willReturn([]); return $kernel; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php index 2daa2e3228..a71fb824d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php @@ -36,8 +36,8 @@ class YamlLintCommandTest extends TestCase $filename = $this->createFile('foo: bar'); $tester->execute( - array('filename' => $filename), - array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) + ['filename' => $filename], + ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false] ); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); @@ -52,7 +52,7 @@ bar'; $tester = $this->createCommandTester(); $filename = $this->createFile($incorrectContent); - $tester->execute(array('filename' => $filename), array('decorated' => false)); + $tester->execute(['filename' => $filename], ['decorated' => false]); $this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error'); $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); @@ -67,7 +67,7 @@ bar'; $filename = $this->createFile(''); unlink($filename); - $tester->execute(array('filename' => $filename), array('decorated' => false)); + $tester->execute(['filename' => $filename], ['decorated' => false]); } public function testGetHelp() @@ -103,8 +103,8 @@ EOF; { $tester = $this->createCommandTester($this->getKernelAwareApplicationMock()); $tester->execute( - array('filename' => '@AppBundle/Resources'), - array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false) + ['filename' => '@AppBundle/Resources'], + ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false] ); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); @@ -186,7 +186,7 @@ EOF; protected function setUp() { @mkdir(sys_get_temp_dir().'/yml-lint-test'); - $this->files = array(); + $this->files = []; } protected function tearDown() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 7dced9e648..09f8d2224e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -29,30 +29,30 @@ class ApplicationTest extends TestCase { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $kernel = $this->getKernel(array($bundle), true); + $kernel = $this->getKernel([$bundle], true); $application = new Application($kernel); - $application->doRun(new ArrayInput(array('list')), new NullOutput()); + $application->doRun(new ArrayInput(['list']), new NullOutput()); } public function testBundleCommandsAreRegistered() { - $bundle = $this->createBundleMock(array()); + $bundle = $this->createBundleMock([]); - $kernel = $this->getKernel(array($bundle), true); + $kernel = $this->getKernel([$bundle], true); $application = new Application($kernel); - $application->doRun(new ArrayInput(array('list')), new NullOutput()); + $application->doRun(new ArrayInput(['list']), new NullOutput()); // Calling twice: registration should only be done once. - $application->doRun(new ArrayInput(array('list')), new NullOutput()); + $application->doRun(new ArrayInput(['list']), new NullOutput()); } public function testBundleCommandsAreRetrievable() { - $bundle = $this->createBundleMock(array()); + $bundle = $this->createBundleMock([]); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel([$bundle]); $application = new Application($kernel); $application->all(); @@ -65,9 +65,9 @@ class ApplicationTest extends TestCase { $command = new Command('example'); - $bundle = $this->createBundleMock(array($command)); + $bundle = $this->createBundleMock([$command]); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel([$bundle]); $application = new Application($kernel); @@ -78,9 +78,9 @@ class ApplicationTest extends TestCase { $command = new Command('example'); - $bundle = $this->createBundleMock(array($command)); + $bundle = $this->createBundleMock([$command]); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel([$bundle]); $application = new Application($kernel); @@ -90,11 +90,11 @@ class ApplicationTest extends TestCase public function testBundleCommandCanBeFoundByAlias() { $command = new Command('example'); - $command->setAliases(array('alias')); + $command->setAliases(['alias']); - $bundle = $this->createBundleMock(array($command)); + $bundle = $this->createBundleMock([$command]); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel([$bundle]); $application = new Application($kernel); @@ -103,30 +103,30 @@ class ApplicationTest extends TestCase public function testBundleCommandsHaveRightContainer() { - $command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer')); + $command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', ['foo'], '', true, true, true, ['setContainer']); $command->setCode(function () {}); $command->expects($this->exactly(2))->method('setContainer'); - $application = new Application($this->getKernel(array(), true)); + $application = new Application($this->getKernel([], true)); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add($command); $tester = new ApplicationTester($application); // set container is called here - $tester->run(array('command' => 'foo')); + $tester->run(['command' => 'foo']); // as the container might have change between two runs, setContainer must called again - $tester->run(array('command' => 'foo')); + $tester->run(['command' => 'foo']); } public function testBundleCommandCanOverriddeAPreExistingCommandWithTheSameName() { $command = new Command('example'); - $bundle = $this->createBundleMock(array($command)); + $bundle = $this->createBundleMock([$command]); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel([$bundle]); $application = new Application($kernel); $newCommand = new Command('example'); @@ -140,14 +140,14 @@ class ApplicationTest extends TestCase $container = new ContainerBuilder(); $container->register('event_dispatcher', EventDispatcher::class); $container->register(ThrowingCommand::class, ThrowingCommand::class); - $container->setParameter('console.command.ids', array(ThrowingCommand::class => ThrowingCommand::class)); + $container->setParameter('console.command.ids', [ThrowingCommand::class => ThrowingCommand::class]); $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->method('getBundles') - ->willReturn(array($this->createBundleMock( - array((new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })) - ))); + ->willReturn([$this->createBundleMock( + [(new Command('fine'))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })] + )]); $kernel ->method('getContainer') ->willReturn($container); @@ -156,7 +156,7 @@ class ApplicationTest extends TestCase $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'fine')); + $tester->run(['command' => 'fine']); $output = $tester->getDisplay(); $this->assertSame(0, $tester->getStatusCode()); @@ -173,9 +173,9 @@ class ApplicationTest extends TestCase $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel ->method('getBundles') - ->willReturn(array($this->createBundleMock( - array((new Command(null))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })) - ))); + ->willReturn([$this->createBundleMock( + [(new Command(null))->setCode(function (InputInterface $input, OutputInterface $output) { $output->write('fine'); })] + )]); $kernel ->method('getContainer') ->willReturn($container); @@ -184,7 +184,7 @@ class ApplicationTest extends TestCase $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'fine')); + $tester->run(['command' => 'fine']); $output = $tester->getDisplay(); $this->assertSame(1, $tester->getStatusCode()); @@ -241,14 +241,14 @@ class ApplicationTest extends TestCase $container ->expects($this->exactly(2)) ->method('hasParameter') - ->withConsecutive(array('console.command.ids'), array('console.lazy_command.ids')) + ->withConsecutive(['console.command.ids'], ['console.lazy_command.ids']) ->willReturnOnConsecutiveCalls(true, true) ; $container ->expects($this->exactly(2)) ->method('getParameter') - ->withConsecutive(array('console.lazy_command.ids'), array('console.command.ids')) - ->willReturnOnConsecutiveCalls(array(), array()) + ->withConsecutive(['console.lazy_command.ids'], ['console.command.ids']) + ->willReturnOnConsecutiveCalls([], []) ; $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index a4529a657c..983c152f56 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -88,7 +88,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.'::testAction'); - $this->assertSame(array($controller, 'testAction'), $resolver->getController($request)); + $this->assertSame([$controller, 'testAction'], $resolver->getController($request)); $this->assertSame($container, $controller->getContainer()); } @@ -106,7 +106,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.'::fooAction'); - $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); + $this->assertSame([$controller, 'fooAction'], $resolver->getController($request)); $this->assertSame($container, $controller->setContainer($container)); } @@ -124,7 +124,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest $request = Request::create('/'); $request->attributes->set('_controller', DummyController::class.'::fooAction'); - $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); + $this->assertSame([$controller, 'fooAction'], $resolver->getController($request)); $this->assertSame($container, $controller->getContainer()); } @@ -144,7 +144,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest $request = Request::create('/'); $request->attributes->set('_controller', TestAbstractController::class.'::fooAction'); - $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); + $this->assertSame([$controller, 'fooAction'], $resolver->getController($request)); $this->assertSame($controllerContainer, $controller->setContainer($container)); } @@ -164,7 +164,7 @@ class ControllerResolverTest extends ContainerControllerResolverTest $request = Request::create('/'); $request->attributes->set('_controller', DummyController::class.'::fooAction'); - $this->assertSame(array($controller, 'fooAction'), $resolver->getController($request)); + $this->assertSame([$controller, 'fooAction'], $resolver->getController($request)); $this->assertSame($controllerContainer, $controller->getContainer()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index f30e024b0c..fb9eff96cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -59,7 +59,7 @@ abstract class ControllerTraitTest extends TestCase public function testGetUser() { $user = new User('user', 'pass'); - $token = new UsernamePasswordToken($user, 'pass', 'default', array('ROLE_USER')); + $token = new UsernamePasswordToken($user, 'pass', 'default', ['ROLE_USER']); $controller = $this->createController(); $controller->setContainer($this->getContainerWithTokenStorage($token)); @@ -121,7 +121,7 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $controller->setContainer(new Container()); - $response = $controller->json(array()); + $response = $controller->json([]); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); } @@ -134,7 +134,7 @@ abstract class ControllerTraitTest extends TestCase $serializer ->expects($this->once()) ->method('serialize') - ->with(array(), 'json', array('json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS)) + ->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS]) ->will($this->returnValue('[]')); $container->set('serializer', $serializer); @@ -142,7 +142,7 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $controller->setContainer($container); - $response = $controller->json(array()); + $response = $controller->json([]); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); } @@ -155,7 +155,7 @@ abstract class ControllerTraitTest extends TestCase $serializer ->expects($this->once()) ->method('serialize') - ->with(array(), 'json', array('json_encode_options' => 0, 'other' => 'context')) + ->with([], 'json', ['json_encode_options' => 0, 'other' => 'context']) ->will($this->returnValue('[]')); $container->set('serializer', $serializer); @@ -163,7 +163,7 @@ abstract class ControllerTraitTest extends TestCase $controller = $this->createController(); $controller->setContainer($container); - $response = $controller->json(array(), 200, array(), array('json_encode_options' => 0, 'other' => 'context')); + $response = $controller->json([], 200, [], ['json_encode_options' => 0, 'other' => 'context']); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals('[]', $response->getContent()); $response->setEncodingOptions(JSON_FORCE_OBJECT); @@ -388,7 +388,7 @@ abstract class ControllerTraitTest extends TestCase $controller->setContainer($container); $controller->addFlash('foo', 'bar'); - $this->assertSame(array('bar'), $flashBag->get('foo')); + $this->assertSame(['bar'], $flashBag->get('foo')); } public function testCreateAccessDeniedException() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php index 6a9438ecbd..992691de6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php @@ -37,10 +37,10 @@ class CacheCollectorPassTest extends TestCase $collector = $container->register('data_collector.cache', CacheDataCollector::class); (new CacheCollectorPass())->process($container); - $this->assertEquals(array( - array('addInstance', array('fs', new Reference('fs'))), - array('addInstance', array('tagged_fs', new Reference('tagged_fs'))), - ), $collector->getMethodCalls()); + $this->assertEquals([ + ['addInstance', ['fs', new Reference('fs')]], + ['addInstance', ['tagged_fs', new Reference('tagged_fs')]], + ], $collector->getMethodCalls()); $this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass()); $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php index 9230405d75..728595ae9f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php @@ -36,13 +36,13 @@ class CachePoolClearerPassTest extends TestCase $publicPool = new Definition(); $publicPool->addArgument('namespace'); - $publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias')); + $publicPool->addTag('cache.pool', ['clearer' => 'clearer_alias']); $container->setDefinition('public.pool', $publicPool); $privatePool = new Definition(); $privatePool->setPublic(false); $privatePool->addArgument('namespace'); - $privatePool->addTag('cache.pool', array('clearer' => 'clearer_alias')); + $privatePool->addTag('cache.pool', ['clearer' => 'clearer_alias']); $container->setDefinition('private.pool', $privatePool); $clearer = new Definition(); @@ -50,12 +50,12 @@ class CachePoolClearerPassTest extends TestCase $container->setAlias('clearer_alias', 'clearer'); $pass = new RemoveUnusedDefinitionsPass(); - $pass->setRepeatedPass(new RepeatedPass(array($pass))); - foreach (array(new CachePoolPass(), $pass, new CachePoolClearerPass()) as $pass) { + $pass->setRepeatedPass(new RepeatedPass([$pass])); + foreach ([new CachePoolPass(), $pass, new CachePoolClearerPass()] as $pass) { $pass->process($container); } - $this->assertEquals(array(array('public.pool' => new Reference('public.pool'))), $clearer->getArguments()); - $this->assertEquals(array(array('public.pool' => new Reference('public.pool'))), $globalClearer->getArguments()); + $this->assertEquals([['public.pool' => new Reference('public.pool')]], $clearer->getArguments()); + $this->assertEquals([['public.pool' => new Reference('public.pool')]], $globalClearer->getArguments()); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php index 4619301b6e..1e7dc416cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php @@ -76,10 +76,10 @@ class CachePoolPassTest extends TestCase $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); - $cachePool->addTag('cache.pool', array( + $cachePool->addTag('cache.pool', [ 'provider' => 'foobar', 'default_lifetime' => 3, - )); + ]); $cachePool->addArgument(null); $cachePool->addArgument(null); $cachePool->addArgument(null); @@ -109,7 +109,7 @@ class CachePoolPassTest extends TestCase $adapter->addTag('cache.pool'); $container->setDefinition('app.cache_adapter', $adapter); $cachePool = new ChildDefinition('app.cache_adapter'); - $cachePool->addTag('cache.pool', array('foobar' => 123)); + $cachePool->addTag('cache.pool', ['foobar' => 123]); $container->setDefinition('app.cache_pool', $cachePool); $this->cachePoolPass->process($container); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php index df9a49b428..2ef2e1535e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php @@ -24,17 +24,17 @@ class CachePoolPrunerPassTest extends TestCase public function testCompilerPassReplacesCommandArgument() { $container = new ContainerBuilder(); - $container->register('console.command.cache_pool_prune')->addArgument(array()); + $container->register('console.command.cache_pool_prune')->addArgument([]); $container->register('pool.foo', FilesystemAdapter::class)->addTag('cache.pool'); $container->register('pool.bar', PhpFilesAdapter::class)->addTag('cache.pool'); $pass = new CachePoolPrunerPass(); $pass->process($container); - $expected = array( + $expected = [ 'pool.foo' => new Reference('pool.foo'), 'pool.bar' => new Reference('pool.bar'), - ); + ]; $argument = $container->getDefinition('console.command.cache_pool_prune')->getArgument(0); $this->assertInstanceOf(IteratorArgument::class, $argument); @@ -63,7 +63,7 @@ class CachePoolPrunerPassTest extends TestCase public function testCompilerPassThrowsOnInvalidDefinitionClass() { $container = new ContainerBuilder(); - $container->register('console.command.cache_pool_prune')->addArgument(array()); + $container->register('console.command.cache_pool_prune')->addArgument([]); $container->register('pool.not-found', NotFound::class)->addTag('cache.pool'); $pass = new CachePoolPrunerPass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index 2d6e8ca3be..8748d1e9c7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -33,11 +33,11 @@ class DataCollectorTranslatorPassTest extends TestCase $this->container->register('translator.data_collector', 'Symfony\Component\Translation\DataCollectorTranslator') ->setPublic(false) ->setDecoratedService('translator') - ->setArguments(array(new Reference('translator.data_collector.inner'))) + ->setArguments([new Reference('translator.data_collector.inner')]) ; $this->container->register('data_collector.translation', 'Symfony\Component\Translation\DataCollector\TranslationDataCollector') - ->setArguments(array(new Reference('translator.data_collector'))) + ->setArguments([new Reference('translator.data_collector')]) ; } @@ -67,10 +67,10 @@ class DataCollectorTranslatorPassTest extends TestCase public function getImplementingTranslatorBagInterfaceTranslatorClassNames() { - return array( - array('Symfony\Component\Translation\Translator'), - array('%translator_implementing_bag%'), - ); + return [ + ['Symfony\Component\Translation\Translator'], + ['%translator_implementing_bag%'], + ]; } /** @@ -99,20 +99,20 @@ class DataCollectorTranslatorPassTest extends TestCase public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames() { - return array( - array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'), - array('%translator_not_implementing_bag%'), - ); + return [ + ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'], + ['%translator_not_implementing_bag%'], + ]; } } class TranslatorWithTranslatorBag implements TranslatorInterface { - public function trans($id, array $parameters = array(), $domain = null, $locale = null) + public function trans($id, array $parameters = [], $domain = null, $locale = null) { } - public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) + public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php index 7788df0c7b..6838d47883 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php @@ -30,17 +30,17 @@ class LoggingTranslatorPassTest extends TestCase $container->setAlias('translator', 'translator.default'); $translationWarmerDefinition = $container->register('translation.warmer') ->addArgument(new Reference('translator')) - ->addTag('container.service_subscriber', array('id' => 'translator')) - ->addTag('container.service_subscriber', array('id' => 'foo')); + ->addTag('container.service_subscriber', ['id' => 'translator']) + ->addTag('container.service_subscriber', ['id' => 'foo']); $pass = new LoggingTranslatorPass(); $pass->process($container); $this->assertEquals( - array('container.service_subscriber' => array( - array('id' => 'foo'), - array('key' => 'translator', 'id' => 'translator.logging.inner'), - )), + ['container.service_subscriber' => [ + ['id' => 'foo'], + ['key' => 'translator', 'id' => 'translator.logging.inner'], + ]], $translationWarmerDefinition->getTags() ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index f46779ada1..b693165f8b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -32,7 +32,7 @@ class ProfilerPassTest extends TestCase $builder = new ContainerBuilder(); $builder->register('profiler', 'ProfilerClass'); $builder->register('my_collector_service') - ->addTag('data_collector', array('template' => 'foo')); + ->addTag('data_collector', ['template' => 'foo']); $profilerPass = new ProfilerPass(); $profilerPass->process($builder); @@ -43,12 +43,12 @@ class ProfilerPassTest extends TestCase $container = new ContainerBuilder(); $profilerDefinition = $container->register('profiler', 'ProfilerClass'); $container->register('my_collector_service') - ->addTag('data_collector', array('template' => 'foo', 'id' => 'my_collector')); + ->addTag('data_collector', ['template' => 'foo', 'id' => 'my_collector']); $profilerPass = new ProfilerPass(); $profilerPass->process($container); - $this->assertSame(array('my_collector_service' => array('my_collector', 'foo')), $container->getParameter('data_collector.templates')); + $this->assertSame(['my_collector_service' => ['my_collector', 'foo']], $container->getParameter('data_collector.templates')); // grab the method calls off of the "profiler" definition $methodCalls = $profilerDefinition->getMethodCalls(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php index d91c806bc8..1377a62882 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php @@ -29,6 +29,6 @@ class UnusedTagsPassTest extends TestCase $pass->process($container); - $this->assertSame(array(sprintf('%s: Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?', UnusedTagsPass::class)), $container->getCompiler()->getLog()); + $this->assertSame([sprintf('%s: Tag "kenrel.event_subscriber" was defined on service(s) "foo", "bar", but was never used. Did you mean "kernel.event_subscriber"?', UnusedTagsPass::class)], $container->getCompiler()->getLog()); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php index dc6bf7bb8d..c05c6fe3a1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php @@ -1,32 +1,32 @@ loadFromExtension('framework', array( - 'assets' => array( +$container->loadFromExtension('framework', [ + 'assets' => [ 'version' => 'SomeVersionScheme', 'base_urls' => 'http://cdn.example.com', 'version_format' => '%%s?version=%%s', - 'packages' => array( - 'images_path' => array( + 'packages' => [ + 'images_path' => [ 'base_path' => '/foo', - ), - 'images' => array( + ], + 'images' => [ 'version' => '1.0.0', - 'base_urls' => array('http://images1.example.com', 'http://images2.example.com'), - ), - 'foo' => array( + 'base_urls' => ['http://images1.example.com', 'http://images2.example.com'], + ], + 'foo' => [ 'version' => '1.0.0', 'version_format' => '%%s-%%s', - ), - 'bar' => array( - 'base_urls' => array('https://bar2.example.com'), - ), - 'bar_version_strategy' => array( - 'base_urls' => array('https://bar2.example.com'), + ], + 'bar' => [ + 'base_urls' => ['https://bar2.example.com'], + ], + 'bar_version_strategy' => [ + 'base_urls' => ['https://bar2.example.com'], 'version_strategy' => 'assets.custom_version_strategy', - ), - 'json_manifest_strategy' => array( + ], + 'json_manifest_strategy' => [ 'json_manifest_path' => '/path/to/manifest.json', - ), - ), - ), -)); + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php index 3ade7047a1..d10595fba9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_disabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'assets' => array( +$container->loadFromExtension('framework', [ + 'assets' => [ 'enabled' => false, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php index 4f9123aefb..b57f78ba47 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( - 'assets' => array( +$container->loadFromExtension('framework', [ + 'assets' => [ 'version_strategy' => 'assets.custom_version_strategy', 'base_urls' => 'http://cdn.example.com', - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php index ef7a1be190..2a85f849fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php @@ -1,29 +1,29 @@ loadFromExtension('framework', array( - 'cache' => array( - 'pools' => array( - 'cache.foo' => array( +$container->loadFromExtension('framework', [ + 'cache' => [ + 'pools' => [ + 'cache.foo' => [ 'adapter' => 'cache.adapter.apcu', 'default_lifetime' => 30, - ), - 'cache.bar' => array( + ], + 'cache.bar' => [ 'adapter' => 'cache.adapter.doctrine', 'default_lifetime' => 5, 'provider' => 'app.doctrine_cache_provider', - ), - 'cache.baz' => array( + ], + 'cache.baz' => [ 'adapter' => 'cache.adapter.filesystem', 'default_lifetime' => 7, - ), - 'cache.foobar' => array( + ], + 'cache.foobar' => [ 'adapter' => 'cache.adapter.psr6', 'default_lifetime' => 10, 'provider' => 'app.cache_pool', - ), - 'cache.def' => array( + ], + 'cache.def' => [ 'default_lifetime' => 11, - ), - ), - ), -)); + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php index b93ade8f4c..4f819e7204 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_env_var.php @@ -2,8 +2,8 @@ $container->setParameter('env(REDIS_URL)', 'redis://paas.com'); -$container->loadFromExtension('framework', array( - 'cache' => array( +$container->loadFromExtension('framework', [ + 'cache' => [ 'default_redis_provider' => '%env(REDIS_URL)%', - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php index 497ceb2b6e..886cb657b2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf.php @@ -1,9 +1,9 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'csrf_protection' => true, 'form' => true, - 'session' => array( + 'session' => [ 'handler_id' => null, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php index d1df1c5962..34fdb4c1f9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'csrf_protection' => array( +$container->loadFromExtension('framework', [ + 'csrf_protection' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php index cd2e56bddf..4b2021df7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/default_config.php @@ -1,3 +1,3 @@ loadFromExtension('framework', array()); +$container->loadFromExtension('framework', []); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php index b8f3aa0441..beada36b84 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php @@ -1,13 +1,13 @@ loadFromExtension('framework', array( - 'fragments' => array( +$container->loadFromExtension('framework', [ + 'fragments' => [ 'enabled' => false, - ), - 'esi' => array( + ], + 'esi' => [ 'enabled' => true, - ), - 'ssi' => array( + ], + 'ssi' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php index 1fb5936fde..a24cd8158c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/esi_disabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'esi' => array( +$container->loadFromExtension('framework', [ + 'esi' => [ 'enabled' => false, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php index 7360c49c72..e0befdb320 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php @@ -1,9 +1,9 @@ loadFromExtension('framework', array( - 'form' => array( - 'csrf_protection' => array( +$container->loadFromExtension('framework', [ + 'form' => [ + 'csrf_protection' => [ 'enabled' => false, - ), - ), -)); + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php index 1338ec5510..cff0582bf3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( - 'php_errors' => array( +$container->loadFromExtension('framework', [ + 'php_errors' => [ 'log' => false, 'throw' => false, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php index a33875ec6a..9afa5d1c02 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( - 'php_errors' => array( +$container->loadFromExtension('framework', [ + 'php_errors' => [ 'log' => true, 'throw' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php index 6615aa74ce..552c95e137 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/profiler.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'profiler' => array( +$container->loadFromExtension('framework', [ + 'profiler' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php index 4340e61fc0..b5b060c1ba 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( - 'property_access' => array( +$container->loadFromExtension('framework', [ + 'property_access' => [ 'magic_call' => true, 'throw_exception_on_invalid_index' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php index 847e15fa19..bff8d41158 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_info.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'property_info' => array( +$container->loadFromExtension('framework', [ + 'property_info' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php index 1e7cb2921c..d69d7512ad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'request' => array( - 'formats' => array(), - ), -)); +$container->loadFromExtension('framework', [ + 'request' => [ + 'formats' => [], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php index eadad57ec7..de3381c21e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'serializer' => array( +$container->loadFromExtension('framework', [ + 'serializer' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php index 65ddd32154..9636b1d661 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( - 'serializer' => array( +$container->loadFromExtension('framework', [ + 'serializer' => [ 'enabled' => true, 'cache' => 'foo', - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php index f2b928ff2d..2f6f48e958 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php @@ -1,15 +1,15 @@ loadFromExtension('framework', array( - 'annotations' => array('enabled' => true), - 'serializer' => array( +$container->loadFromExtension('framework', [ + 'annotations' => ['enabled' => true], + 'serializer' => [ 'enable_annotations' => true, - 'mapping' => array( - 'paths' => array( + 'mapping' => [ + 'paths' => [ '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml', - ), - ), - ), -)); + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php index 104183764a..375008c7db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/session.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'session' => array( +$container->loadFromExtension('framework', [ + 'session' => [ 'handler_id' => null, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php index 4d61d82166..32e1bf0c55 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'ssi' => array( +$container->loadFromExtension('framework', [ + 'ssi' => [ 'enabled' => false, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php index f76d8ad351..2d5e6d779f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php @@ -1,5 +1,5 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'templating' => false, -)); +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php index bf12a8bc47..f4d5a28aaf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'templating' => array( - 'engines' => array('php', 'twig'), - ), -)); +$container->loadFromExtension('framework', [ + 'templating' => [ + 'engines' => ['php', 'twig'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php index 535a9a2e99..851a7e140c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'assets' => false, - 'templating' => array( - 'engines' => array('php'), - ), -)); + 'templating' => [ + 'engines' => ['php'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php index 4fb2aec557..1d65c0caa4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'translator' => false, - 'templating' => array( - 'engines' => array('php'), - ), -)); + 'templating' => [ + 'engines' => ['php'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php index b8053c853b..2d4710ba30 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php @@ -1,8 +1,8 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'translator' => true, - 'templating' => array( - 'engines' => array('php'), - ), -)); + 'templating' => [ + 'engines' => ['php'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php index 0abe3a46ab..592a61de65 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'translator' => array( - 'fallbacks' => array('en', 'fr'), - ), -)); +$container->loadFromExtension('framework', [ + 'translator' => [ + 'fallbacks' => ['en', 'fr'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php index 35a0b3d39e..dff03e398e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_annotations.php @@ -1,9 +1,9 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'secret' => 's3cr3t', - 'validation' => array( + 'validation' => [ 'enabled' => true, 'enable_annotations' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php index 5d44c6c215..f8b19e3480 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_mapping.php @@ -1,13 +1,13 @@ loadFromExtension('framework', array( - 'validation' => array( - 'mapping' => array( - 'paths' => array( +$container->loadFromExtension('framework', [ + 'validation' => [ + 'mapping' => [ + 'paths' => [ '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml', '%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml', - ), - ), - ), -)); + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php index 476da7948e..ad2bd817a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php @@ -1,9 +1,9 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'secret' => 's3cr3t', - 'validation' => array( + 'validation' => [ 'enabled' => true, - 'static_method' => array('loadFoo', 'loadBar'), - ), -)); + 'static_method' => ['loadFoo', 'loadBar'], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php index b428e06f5c..a9d98e17c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php @@ -1,9 +1,9 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'secret' => 's3cr3t', - 'validation' => array( + 'validation' => [ 'enabled' => true, 'static_method' => false, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email_enabled.php index 64a47a2322..caa47d7470 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_strict_email_enabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'validation' => array( +$container->loadFromExtension('framework', [ + 'validation' => [ 'strict_email' => true, - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php index 40a81d4936..42ea071303 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'validation' => array( +$container->loadFromExtension('framework', [ + 'validation' => [ 'translation_domain' => 'messages', - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php index 990064cca9..44d52e402d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/web_link.php @@ -1,5 +1,5 @@ loadFromExtension('framework', array( - 'web_link' => array('enabled' => true), -)); +$container->loadFromExtension('framework', [ + 'web_link' => ['enabled' => true], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php index d97f9700a0..003b99f210 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php @@ -2,30 +2,30 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'my_workflow' => array( - 'marking_store' => array( - 'arguments' => array('a', 'b'), +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'my_workflow' => [ + 'marking_store' => [ + 'arguments' => ['a', 'b'], 'service' => 'workflow_service', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), - 'places' => array( + ], + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( - 'from' => array( + ], + 'transitions' => [ + 'go' => [ + 'from' => [ 'first', - ), - 'to' => array( + ], + 'to' => [ 'last', - ), - ), - ), - ), - ), -)); + ], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php index 89c86339af..19de6363e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php @@ -2,50 +2,50 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'article' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'article' => [ 'type' => 'workflow', - 'marking_store' => array( + 'marking_store' => [ 'type' => 'multiple_state', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), + ], 'initial_place' => 'draft', - 'places' => array( + 'places' => [ 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', - ), - 'transitions' => array( - 'request_review' => array( + ], + 'transitions' => [ + 'request_review' => [ 'from' => 'draft', - 'to' => array('wait_for_journalist', 'wait_for_spellchecker'), - ), - 'journalist_approval' => array( + 'to' => ['wait_for_journalist', 'wait_for_spellchecker'], + ], + 'journalist_approval' => [ 'from' => 'wait_for_journalist', 'to' => 'approved_by_journalist', - ), - 'spellchecker_approval' => array( + ], + 'spellchecker_approval' => [ 'from' => 'wait_for_spellchecker', 'to' => 'approved_by_spellchecker', - ), - 'publish' => array( - 'from' => array('approved_by_journalist', 'approved_by_spellchecker'), + ], + 'publish' => [ + 'from' => ['approved_by_journalist', 'approved_by_spellchecker'], 'to' => 'published', 'guard' => '!!true', - ), - 'publish_editor_in_chief' => array( + ], + 'publish_editor_in_chief' => [ 'name' => 'publish', 'from' => 'draft', 'to' => 'published', 'guard' => '!!false', - ), - ), - ), - ), -)); + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php index 2619a2dd43..c1a525db03 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php @@ -2,48 +2,48 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'article' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'article' => [ 'type' => 'workflow', - 'marking_store' => array( + 'marking_store' => [ 'type' => 'multiple_state', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), + ], 'initial_place' => 'draft', - 'places' => array( + 'places' => [ 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', - ), - 'transitions' => array( - 'request_review' => array( + ], + 'transitions' => [ + 'request_review' => [ 'from' => 'draft', - 'to' => array('wait_for_journalist', 'wait_for_spellchecker'), - ), - 'journalist_approval' => array( + 'to' => ['wait_for_journalist', 'wait_for_spellchecker'], + ], + 'journalist_approval' => [ 'from' => 'wait_for_journalist', 'to' => 'approved_by_journalist', - ), - 'spellchecker_approval' => array( + ], + 'spellchecker_approval' => [ 'from' => 'wait_for_spellchecker', 'to' => 'approved_by_spellchecker', - ), - 'publish' => array( - 'from' => array('approved_by_journalist', 'approved_by_spellchecker'), + ], + 'publish' => [ + 'from' => ['approved_by_journalist', 'approved_by_spellchecker'], 'to' => 'published', - ), - 'publish_editor_in_chief' => array( + ], + 'publish_editor_in_chief' => [ 'name' => 'publish', 'from' => 'draft', 'to' => 'published', - ), - ), - ), - ), -)); + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php index 062fdb9f0d..4b38093a3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php @@ -2,30 +2,30 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'my_workflow' => array( - 'marking_store' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'my_workflow' => [ + 'marking_store' => [ 'type' => 'multiple_state', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), + ], 'support_strategy' => 'foobar', - 'places' => array( + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( - 'from' => array( + ], + 'transitions' => [ + 'go' => [ + 'from' => [ 'first', - ), - 'to' => array( + ], + 'to' => [ 'last', - ), - ), - ), - ), - ), -)); + ], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php index 7d9e596408..eca1e29c45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php @@ -2,30 +2,30 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'my_workflow' => array( - 'marking_store' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'my_workflow' => [ + 'marking_store' => [ 'type' => 'multiple_state', 'service' => 'workflow_service', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), - 'places' => array( + ], + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( - 'from' => array( + ], + 'transitions' => [ + 'go' => [ + 'from' => [ 'first', - ), - 'to' => array( + ], + 'to' => [ 'last', - ), - ), - ), - ), - ), -)); + ], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php index 06948785e9..dd2a92dc26 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php @@ -2,26 +2,26 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'my_workflow' => array( - 'marking_store' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'my_workflow' => [ + 'marking_store' => [ 'type' => 'multiple_state', - ), - 'places' => array( + ], + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( - 'from' => array( + ], + 'transitions' => [ + 'go' => [ + 'from' => [ 'first', - ), - 'to' => array( + ], + 'to' => [ 'last', - ), - ), - ), - ), - ), -)); + ], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php index 9a2fe9136a..eb17731940 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php @@ -1,5 +1,5 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'workflows' => null, -)); +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php index 16009b588f..165d0daa11 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php @@ -1,19 +1,19 @@ loadFromExtension('framework', array( - 'workflows' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ 'enabled' => true, - 'foo' => array( + 'foo' => [ 'type' => 'workflow', - 'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'), + 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], 'initial_place' => 'bar', - 'places' => array('bar', 'baz'), - 'transitions' => array( - 'bar_baz' => array( - 'from' => array('foo'), - 'to' => array('bar'), - ), - ), - ), - ), -)); + 'places' => ['bar', 'baz'], + 'transitions' => [ + 'bar_baz' => [ + 'from' => ['foo'], + 'to' => ['bar'], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php index bd36d87fa2..17055ec16f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php @@ -1,19 +1,19 @@ loadFromExtension('framework', array( - 'workflows' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ 'enabled' => true, - 'workflows' => array( + 'workflows' => [ 'type' => 'workflow', - 'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'), + 'supports' => ['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'], 'initial_place' => 'bar', - 'places' => array('bar', 'baz'), - 'transitions' => array( - 'bar_baz' => array( - 'from' => array('foo'), - 'to' => array('bar'), - ), - ), - ), - ), -)); + 'places' => ['bar', 'baz'], + 'transitions' => [ + 'bar_baz' => [ + 'from' => ['foo'], + 'to' => ['bar'], + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index c554532c7a..ec39372b1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -29,12 +29,12 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest public function testAssetsCannotHavePathAndUrl() { $this->createContainerFromClosure(function ($container) { - $container->loadFromExtension('framework', array( - 'assets' => array( + $container->loadFromExtension('framework', [ + 'assets' => [ 'base_urls' => 'http://cdn.example.com', 'base_path' => '/foo', - ), - )); + ], + ]); }); } @@ -44,16 +44,16 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest public function testAssetPackageCannotHavePathAndUrl() { $this->createContainerFromClosure(function ($container) { - $container->loadFromExtension('framework', array( - 'assets' => array( - 'packages' => array( - 'impossible' => array( + $container->loadFromExtension('framework', [ + 'assets' => [ + 'packages' => [ + 'impossible' => [ 'base_urls' => 'http://cdn.example.com', 'base_path' => '/foo', - ), - ), - ), - )); + ], + ], + ], + ]); }); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/ResolveControllerNameSubscriberTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/ResolveControllerNameSubscriberTest.php index 338c1ec81a..92211dc341 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/ResolveControllerNameSubscriberTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/ResolveControllerNameSubscriberTest.php @@ -57,7 +57,7 @@ class ResolveControllerNameSubscriberTest extends TestCase public function provideSkippedControllers() { - yield array('Other:format'); - yield array(function () {}); + yield ['Other:format']; + yield [function () {}]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php index 1dcc5536c1..b8a20d246a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php @@ -29,21 +29,21 @@ EOF transChoice( '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', 10, - array('%count%' => 10) + ['%count%' => 10] ) ?> -trans('other-domain-test-no-params-short-array', array(), 'not_messages'); ?> +trans('other-domain-test-no-params-short-array', [], 'not_messages'); ?> -trans('other-domain-test-no-params-long-array', array(), 'not_messages'); ?> +trans('other-domain-test-no-params-long-array', [], 'not_messages'); ?> -trans('other-domain-test-params-short-array', array('foo' => 'bar'), 'not_messages'); ?> +trans('other-domain-test-params-short-array', ['foo' => 'bar'], 'not_messages'); ?> -trans('other-domain-test-params-long-array', array('foo' => 'bar'), 'not_messages'); ?> +trans('other-domain-test-params-long-array', ['foo' => 'bar'], 'not_messages'); ?> -transChoice('other-domain-test-trans-choice-short-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?> +transChoice('other-domain-test-trans-choice-short-array-%count%', 10, ['%count%' => 10], 'not_messages'); ?> -transChoice('other-domain-test-trans-choice-long-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?> +transChoice('other-domain-test-trans-choice-long-array-%count%', 10, ['%count%' => 10], 'not_messages'); ?> -trans('typecast', array('a' => (int) '123'), 'not_messages'); ?> -transChoice('msg1', 10 + 1, array(), 'not_messages'); ?> -transChoice('msg2', ceil(4.5), array(), 'not_messages'); ?> +trans('typecast', ['a' => (int) '123'], 'not_messages'); ?> +transChoice('msg1', 10 + 1, [], 'not_messages'); ?> +transChoice('msg2', ceil(4.5), [], 'not_messages'); ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php index b97a6ba6a7..c9a7ad7a1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/templates.php @@ -1,5 +1,5 @@ __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine', -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php index 2fdbef8839..51a3e7ee54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php @@ -18,7 +18,7 @@ class AnnotatedControllerTest extends WebTestCase */ public function testAnnotatedController($path, $expectedValue) { - $client = $this->createClient(array('test_case' => 'AnnotatedController', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'AnnotatedController', 'root_config' => 'config.yml']); $client->request('GET', '/annotated'.$path); $this->assertSame(200, $client->getResponse()->getStatusCode()); @@ -27,13 +27,13 @@ class AnnotatedControllerTest extends WebTestCase public function getRoutes() { - return array( - array('/null_request', 'Symfony\Component\HttpFoundation\Request'), - array('/null_argument', ''), - array('/null_argument_with_route_param', ''), - array('/null_argument_with_route_param/value', 'value'), - array('/argument_with_route_param_and_default', 'value'), - array('/argument_with_route_param_and_default/custom', 'custom'), - ); + return [ + ['/null_request', 'Symfony\Component\HttpFoundation\Request'], + ['/null_argument', ''], + ['/null_argument_with_route_param', ''], + ['/null_argument_with_route_param/value', 'value'], + ['/argument_with_route_param_and_default', 'value'], + ['/argument_with_route_param_and_default/custom', 'custom'], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index 88bd102a5f..aa78c87190 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php @@ -22,7 +22,7 @@ class FragmentController implements ContainerAwareInterface public function indexAction(Request $request) { - return $this->container->get('templating')->renderResponse('fragment.html.php', array('bar' => new Bar())); + return $this->container->get('templating')->renderResponse('fragment.html.php', ['bar' => new Bar()]); } public function inlinedAction($options, $_format) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php index b1e4f79dc1..30f364def4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php @@ -23,12 +23,12 @@ class SubRequestController implements ContainerAwareInterface public function indexAction($handler) { - $errorUrl = $this->generateUrl('subrequest_fragment_error', array('_locale' => 'fr', '_format' => 'json')); - $altUrl = $this->generateUrl('subrequest_fragment', array('_locale' => 'fr', '_format' => 'json')); + $errorUrl = $this->generateUrl('subrequest_fragment_error', ['_locale' => 'fr', '_format' => 'json']); + $altUrl = $this->generateUrl('subrequest_fragment', ['_locale' => 'fr', '_format' => 'json']); // simulates a failure during the rendering of a fragment... // should render fr/json - $content = $handler->render($errorUrl, 'inline', array('alt' => $altUrl)); + $content = $handler->render($errorUrl, 'inline', ['alt' => $altUrl]); // ...to check that the FragmentListener still references the right Request // when rendering another fragment after the error occurred @@ -59,7 +59,7 @@ class SubRequestController implements ContainerAwareInterface throw new \RuntimeException('error'); } - protected function generateUrl($name, $arguments = array()) + protected function generateUrl($name, $arguments = []) { return $this->container->get('router')->generate($name, $arguments); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php index 66489374f6..59670fdd19 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php @@ -36,7 +36,7 @@ class TestExtension extends Extension implements PrependExtensionInterface */ public function prepend(ContainerBuilder $container) { - $container->prependExtensionConfig('test', array('custom' => 'foo')); + $container->prependExtensionConfig('test', ['custom' => 'foo']); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 9cdb93a493..ebee71ca83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -19,7 +19,7 @@ class CachePoolsTest extends WebTestCase { public function testCachePools() { - $this->doTestCachePools(array(), AdapterInterface::class); + $this->doTestCachePools([], AdapterInterface::class); } /** @@ -28,7 +28,7 @@ class CachePoolsTest extends WebTestCase public function testRedisCachePools() { try { - $this->doTestCachePools(array('root_config' => 'redis_config.yml', 'environment' => 'redis_cache'), RedisAdapter::class); + $this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; @@ -53,7 +53,7 @@ class CachePoolsTest extends WebTestCase public function testRedisCustomCachePools() { try { - $this->doTestCachePools(array('root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'), RedisAdapter::class); + $this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { if (0 !== strpos($e->getMessage(), 'unable to connect to')) { throw $e; @@ -96,8 +96,8 @@ class CachePoolsTest extends WebTestCase $this->assertTrue($item->isHit()); } - protected static function createKernel(array $options = array()) + protected static function createKernel(array $options = []) { - return parent::createKernel(array('test_case' => 'CachePools') + $options); + return parent::createKernel(['test_case' => 'CachePools'] + $options); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php index a98879938d..2c0a75481b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php @@ -25,15 +25,15 @@ class ConfigDebugCommandTest extends WebTestCase protected function setUp() { - $kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml')); + $kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']); $this->application = new Application($kernel); - $this->application->doRun(new ArrayInput(array()), new NullOutput()); + $this->application->doRun(new ArrayInput([]), new NullOutput()); } public function testDumpBundleName() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'TestBundle')); + $ret = $tester->execute(['name' => 'TestBundle']); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('custom: foo', $tester->getDisplay()); @@ -42,7 +42,7 @@ class ConfigDebugCommandTest extends WebTestCase public function testDumpBundleOption() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'TestBundle', 'path' => 'custom')); + $ret = $tester->execute(['name' => 'TestBundle', 'path' => 'custom']); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('foo', $tester->getDisplay()); @@ -51,7 +51,7 @@ class ConfigDebugCommandTest extends WebTestCase public function testParametersValuesAreResolved() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'framework')); + $ret = $tester->execute(['name' => 'framework']); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains("locale: '%env(LOCALE)%'", $tester->getDisplay()); @@ -61,7 +61,7 @@ class ConfigDebugCommandTest extends WebTestCase public function testDumpUndefinedBundleOption() { $tester = $this->createCommandTester(); - $tester->execute(array('name' => 'TestBundle', 'path' => 'foo')); + $tester->execute(['name' => 'TestBundle', 'path' => 'foo']); $this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php index 3817afed17..a4cfd6cfa9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php @@ -25,15 +25,15 @@ class ConfigDumpReferenceCommandTest extends WebTestCase protected function setUp() { - $kernel = static::createKernel(array('test_case' => 'ConfigDump', 'root_config' => 'config.yml')); + $kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']); $this->application = new Application($kernel); - $this->application->doRun(new ArrayInput(array()), new NullOutput()); + $this->application->doRun(new ArrayInput([]), new NullOutput()); } public function testDumpBundleName() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'TestBundle')); + $ret = $tester->execute(['name' => 'TestBundle']); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertContains('test:', $tester->getDisplay()); @@ -43,10 +43,10 @@ class ConfigDumpReferenceCommandTest extends WebTestCase public function testDumpAtPath() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array( + $ret = $tester->execute([ 'name' => 'test', 'path' => 'array', - )); + ]); $this->assertSame(0, $ret, 'Returns 0 in case of success'); $this->assertSame(<<<'EOL' @@ -63,11 +63,11 @@ EOL public function testDumpAtPathXml() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array( + $ret = $tester->execute([ 'name' => 'test', 'path' => 'array', '--format' => 'xml', - )); + ]); $this->assertSame(1, $ret); $this->assertContains('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php index 1eff55d480..fe0cea4d16 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php @@ -18,14 +18,14 @@ class ContainerDumpTest extends WebTestCase { public function testContainerCompilationInDebug() { - $client = $this->createClient(array('test_case' => 'ContainerDump', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']); $this->assertTrue(static::$container->has('serializer')); } public function testContainerCompilation() { - $client = $this->createClient(array('test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false)); + $client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]); $this->assertTrue(static::$container->has('serializer')); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php index 0b7f9290a5..7e41d3298d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php @@ -21,13 +21,13 @@ class DebugAutowiringCommandTest extends WebTestCase { public function testBasicFunctionality() { - static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'debug:autowiring')); + $tester->run(['command' => 'debug:autowiring']); $this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay()); $this->assertContains('alias to http_kernel', $tester->getDisplay()); @@ -35,13 +35,13 @@ class DebugAutowiringCommandTest extends WebTestCase public function testSearchArgument() { - static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'debug:autowiring', 'search' => 'kern')); + $tester->run(['command' => 'debug:autowiring', 'search' => 'kern']); $this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay()); $this->assertNotContains('Symfony\Component\Routing\RouterInterface', $tester->getDisplay()); @@ -49,13 +49,13 @@ class DebugAutowiringCommandTest extends WebTestCase public function testSearchNoResults() { - static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml')); + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'debug:autowiring', 'search' => 'foo_fake'), array('capture_stderr_separately' => true)); + $tester->run(['command' => 'debug:autowiring', 'search' => 'foo_fake'], ['capture_stderr_separately' => true]); $this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput()); $this->assertEquals(1, $tester->getStatusCode()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index dff65d636c..db550a2312 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -18,7 +18,7 @@ class FragmentTest extends WebTestCase */ public function testFragment($insulate) { - $client = $this->createClient(array('test_case' => 'Fragment', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml']); if ($insulate) { $client->insulate(); } @@ -30,9 +30,9 @@ class FragmentTest extends WebTestCase public function getConfigs() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php index 2d422b0292..c5252c0d58 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php @@ -18,7 +18,7 @@ class ProfilerTest extends WebTestCase */ public function testProfilerIsDisabled($insulate) { - $client = $this->createClient(array('test_case' => 'Profiler', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'Profiler', 'root_config' => 'config.yml']); if ($insulate) { $client->insulate(); } @@ -38,9 +38,9 @@ class ProfilerTest extends WebTestCase public function getConfigs() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php index 2e1634220c..aad3d77949 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php @@ -20,7 +20,7 @@ class SessionTest extends WebTestCase */ public function testWelcome($config, $insulate) { - $client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); if ($insulate) { $client->insulate(); } @@ -53,7 +53,7 @@ class SessionTest extends WebTestCase */ public function testFlash($config, $insulate) { - $client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); if ($insulate) { $client->insulate(); } @@ -78,13 +78,13 @@ class SessionTest extends WebTestCase public function testTwoClients($config, $insulate) { // start first client - $client1 = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); + $client1 = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); if ($insulate) { $client1->insulate(); } // start second client - $client2 = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); + $client2 = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); if ($insulate) { $client2->insulate(); } @@ -131,7 +131,7 @@ class SessionTest extends WebTestCase */ public function testCorrectCacheControlHeadersForCacheableAction($config, $insulate) { - $client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]); if ($insulate) { $client->insulate(); } @@ -144,10 +144,10 @@ class SessionTest extends WebTestCase public function getConfigs() { - return array( + return [ // configfile, insulate - array('config.yml', true), - array('config.yml', false), - ); + ['config.yml', true], + ['config.yml', false], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php index 1a87ff928a..9d040581db 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php @@ -15,7 +15,7 @@ class SubRequestsTest extends WebTestCase { public function testStateAfterSubRequest() { - $client = $this->createClient(array('test_case' => 'Session', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'Session', 'root_config' => 'config.yml']); $client->request('GET', 'https://localhost/subrequest/en'); $this->assertEquals('--fr/json--en/html--fr/json--http://localhost/subrequest/fragment/en', $client->getResponse()->getContent()); @@ -23,7 +23,7 @@ class SubRequestsTest extends WebTestCase public function testSubRequestControllerServicesAreResolved() { - $client = $this->createClient(array('test_case' => 'ControllerServiceResolution', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'ControllerServiceResolution', 'root_config' => 'config.yml']); $client->request('GET', 'https://localhost/subrequest'); $this->assertEquals('---', $client->getResponse()->getContent()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php index b25ab8e5a6..3f7bb4c7ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php @@ -49,7 +49,7 @@ class WebTestCase extends BaseWebTestCase return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel'; } - protected static function createKernel(array $options = array()) + protected static function createKernel(array $options = []) { $class = self::getKernelClass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AnnotatedController/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index e239bb5331..11457f6a79 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -81,7 +81,7 @@ class AppKernel extends Kernel public function serialize() { - return serialize(array($this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug())); + return serialize([$this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug()]); } public function unserialize($str) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePoolClear/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ConfigDump/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDebug/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ControllerServiceResolution/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Profiler/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/bundles.php index 144db90236..13ab9fddee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Serializer/bundles.php @@ -11,6 +11,6 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -return array( +return [ new FrameworkBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/bundles.php index 422ffc917f..15ff182c6f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Session/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; -return array( +return [ new FrameworkBundle(), new TestBundle(), -); +]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php index 3c5a55e338..80fa74bb13 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php @@ -49,9 +49,9 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface public function registerBundles() { - return array( + return [ new FrameworkBundle(), - ); + ]; } public function getCacheDir() @@ -79,9 +79,9 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) { $c->register('logger', NullLogger::class); - $c->loadFromExtension('framework', array( + $c->loadFromExtension('framework', [ 'secret' => '$ecret', - )); + ]); $c->setParameter('halloween', 'Have a great day!'); $c->register('halloween', 'stdClass')->setPublic(true); @@ -92,9 +92,9 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( + return [ KernelEvents::EXCEPTION => 'onKernelException', - ); + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php index b5f7a3bd48..d87eee58cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.php @@ -26,7 +26,7 @@ class RedirectableUrlMatcherTest extends TestCase $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); - $this->assertEquals(array( + $this->assertEquals([ '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'path' => '/foo/', 'permanent' => true, @@ -34,7 +34,7 @@ class RedirectableUrlMatcherTest extends TestCase 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', - ), + ], $matcher->match('/foo') ); } @@ -42,11 +42,11 @@ class RedirectableUrlMatcherTest extends TestCase public function testSchemeRedirect() { $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); + $coll->add('foo', new Route('/foo', [], [], [], '', ['https'])); $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); - $this->assertEquals(array( + $this->assertEquals([ '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'path' => '/foo', 'permanent' => true, @@ -54,7 +54,7 @@ class RedirectableUrlMatcherTest extends TestCase 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', - ), + ], $matcher->match('/foo') ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 20a001a1d6..63bb55e506 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -36,12 +36,12 @@ class RouterTest extends TestCase $routes->add('foo', new Route( ' /{_locale}', - array( + [ '_locale' => '%locale%', - ), - array( + ], + [ '_locale' => 'en|es', - ), array(), '', array(), array(), '"%foo%" == "bar"' + ], [], '', [], [], '"%foo%" == "bar"' )); $sc = $this->getPsr11ServiceContainer($routes); @@ -77,8 +77,8 @@ class RouterTest extends TestCase $router = new Router($sc, 'foo'); - $this->assertSame('/en', $router->generate('foo', array('_locale' => 'en'))); - $this->assertSame('/', $router->generate('foo', array('_locale' => 'es'))); + $this->assertSame('/en', $router->generate('foo', ['_locale' => 'en'])); + $this->assertSame('/', $router->generate('foo', ['_locale' => 'es'])); $this->assertSame('"bar" == "bar"', $router->getRouteCollection()->get('foo')->getCondition()); } @@ -88,15 +88,15 @@ class RouterTest extends TestCase $routes->add('foo', new Route( '/foo', - array( + [ 'foo' => 'before_%parameter.foo%', 'bar' => '%parameter.bar%_after', 'baz' => '%%escaped%%', - 'boo' => array('%parameter%', '%%escaped_parameter%%', array('%bee_parameter%', 'bee')), - 'bee' => array('bee', 'bee'), - ), - array( - ) + 'boo' => ['%parameter%', '%%escaped_parameter%%', ['%bee_parameter%', 'bee']], + 'bee' => ['bee', 'bee'], + ], + [ + ] )); $sc = $this->getPsr11ServiceContainer($routes); @@ -151,13 +151,13 @@ class RouterTest extends TestCase $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( - array( + [ 'foo' => 'before_foo', 'bar' => 'bar_after', 'baz' => '%escaped%', - 'boo' => array('boo', '%escaped_parameter%', array('foo_bee', 'bee')), - 'bee' => array('bee', 'bee'), - ), + 'boo' => ['boo', '%escaped_parameter%', ['foo_bee', 'bee']], + 'bee' => ['bee', 'bee'], + ], $route->getDefaults() ); } @@ -168,13 +168,13 @@ class RouterTest extends TestCase $routes->add('foo', new Route( '/foo', - array( - ), - array( + [ + ], + [ 'foo' => 'before_%parameter.foo%', 'bar' => '%parameter.bar%_after', 'baz' => '%%escaped%%', - ) + ] )); $sc = $this->getPsr11ServiceContainer($routes); @@ -220,11 +220,11 @@ class RouterTest extends TestCase $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( - array( + [ 'foo' => 'before_foo', 'bar' => 'bar_after', 'baz' => '%escaped%', - ), + ], $route->getRequirements() ); } @@ -391,7 +391,7 @@ class RouterTest extends TestCase public function testDefaultValuesAsNonStrings($value) { $routes = new RouteCollection(); - $routes->add('foo', new Route('foo', array('foo' => $value), array('foo' => '\d+'))); + $routes->add('foo', new Route('foo', ['foo' => $value], ['foo' => '\d+'])); $sc = $this->getPsr11ServiceContainer($routes); @@ -444,12 +444,12 @@ class RouterTest extends TestCase $routeCollection = $router->getRouteCollection(); - $this->assertEquals(array(new ContainerParametersResource(array('locale' => 'en'))), $routeCollection->getResources()); + $this->assertEquals([new ContainerParametersResource(['locale' => 'en'])], $routeCollection->getResources()); } public function getNonStringValues() { - return array(array(null), array(false), array(true), array(new \stdClass()), array(array('foo', 'bar')), array(array(array()))); + return [[null], [false], [true], [new \stdClass()], [['foo', 'bar']], [[[]]]]; } /** @@ -465,7 +465,7 @@ class RouterTest extends TestCase ->will($this->returnValue($routes)) ; - $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(array('get'))->getMock(); + $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); $sc ->expects($this->once()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php index e3ff92b874..73983e47ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -19,12 +19,12 @@ class DelegatingEngineTest extends TestCase { public function testSupportsRetrievesEngineFromTheContainer() { - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'engine.first' => $this->getEngineMock('template.php', false), 'engine.second' => $this->getEngineMock('template.php', true), - )); + ]); - $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); + $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); $this->assertTrue($delegatingEngine->supports('template.php')); } @@ -33,12 +33,12 @@ class DelegatingEngineTest extends TestCase { $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', true); - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'engine.first' => $firstEngine, 'engine.second' => $secondEngine, - )); + ]); - $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); + $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); $this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php')); } @@ -51,12 +51,12 @@ class DelegatingEngineTest extends TestCase { $firstEngine = $this->getEngineMock('template.php', false); $secondEngine = $this->getEngineMock('template.php', false); - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'engine.first' => $firstEngine, 'engine.second' => $secondEngine, - )); + ]); - $delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second')); + $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); $delegatingEngine->getEngine('template.php'); } @@ -66,22 +66,22 @@ class DelegatingEngineTest extends TestCase $engine = $this->getFrameworkEngineMock('template.php', true); $engine->expects($this->once()) ->method('renderResponse') - ->with('template.php', array('foo' => 'bar')) + ->with('template.php', ['foo' => 'bar']) ->will($this->returnValue($response)); - $container = $this->getContainerMock(array('engine' => $engine)); + $container = $this->getContainerMock(['engine' => $engine]); - $delegatingEngine = new DelegatingEngine($container, array('engine')); + $delegatingEngine = new DelegatingEngine($container, ['engine']); - $this->assertSame($response, $delegatingEngine->renderResponse('template.php', array('foo' => 'bar'))); + $this->assertSame($response, $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); } public function testRenderResponseWithTemplatingEngine() { $engine = $this->getEngineMock('template.php', true); - $container = $this->getContainerMock(array('engine' => $engine)); - $delegatingEngine = new DelegatingEngine($container, array('engine')); + $container = $this->getContainerMock(['engine' => $engine]); + $delegatingEngine = new DelegatingEngine($container, ['engine']); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', array('foo' => 'bar'))); + $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); } private function getEngineMock($template, $supports) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index 348820b321..d6c6b299eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -93,14 +93,14 @@ class GlobalVariablesTest extends TestCase $std = new \stdClass(); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - return array( - array($user, $user), - array($std, $std), - array($token, $token), - array('Anon.', null), - array(null, null), - array(10, null), - array(true, null), - ); + return [ + [$user, $user], + [$std, $std], + [$token, $token], + ['Anon.', null], + [null, null], + [10, null], + [true, null], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php index 01fac959db..83df0640bf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php @@ -26,7 +26,7 @@ class AssetsHelperTest extends TestCase $fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s')); $barPackage = new Package(new StaticVersionStrategy('22', '%s?%s')); - $packages = new Packages($fooPackage, array('bar' => $barPackage)); + $packages = new Packages($fooPackage, ['bar' => $barPackage]); $this->helper = new AssetsHelper($packages); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php index 17d1fd4fc6..53a77f24cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php @@ -15,12 +15,12 @@ use Symfony\Component\Translation\TranslatorInterface; class StubTranslator implements TranslatorInterface { - public function trans($id, array $parameters = array(), $domain = null, $locale = null) + public function trans($id, array $parameters = [], $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } - public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) + public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) { return '[trans]'.$id.'[/trans]'; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index e673c45e52..691464438e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -35,19 +35,19 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); - $loader = new FilesystemLoader(array()); + $loader = new FilesystemLoader([]); $this->engine = new PhpEngine($templateNameParser, $loader); $this->engine->addGlobal('global', ''); - $this->engine->setHelpers(array( + $this->engine->setHelpers([ new TranslatorHelper(new StubTranslator()), - )); + ]); - return array_merge(parent::getExtensions(), array( - new TemplatingExtension($this->engine, $this->csrfTokenManager, array( + return array_merge(parent::getExtensions(), [ + new TemplatingExtension($this->engine, $this->csrfTokenManager, [ 'FrameworkBundle:Form', - )), - )); + ]), + ]); } protected function tearDown() @@ -59,10 +59,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -71,10 +71,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); @@ -93,12 +93,12 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest $this->assertSame('€ ', $this->renderWidget($view)); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->form($view, $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { return (string) $this->engine->get('form')->label($view, $label, $vars); } @@ -113,27 +113,27 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest return (string) $this->engine->get('form')->errors($view); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->widget($view, $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->row($view, $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->rest($view, $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->start($view, $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->end($view, $vars); } @@ -145,15 +145,15 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest public static function themeBlockInheritanceProvider() { - return array( - array(array('TestBundle:Parent')), - ); + return [ + [['TestBundle:Parent']], + ]; } public static function themeInheritanceProvider() { - return array( - array(array('TestBundle:Parent'), array('TestBundle:Child')), - ); + return [ + [['TestBundle:Parent'], ['TestBundle:Child']], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index e6e0604a26..cdf7cbdc05 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -29,10 +29,10 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest public function testStartTagHasNoActionAttributeWhenActionIsEmpty() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '', - )); + ]); $html = $this->renderStart($form->createView()); @@ -41,10 +41,10 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest public function testStartTagHasActionAttributeWhenActionIsZero() { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( + $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ 'method' => 'get', 'action' => '0', - )); + ]); $html = $this->renderStart($form->createView()); @@ -59,20 +59,20 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); $rootTheme = realpath(__DIR__.'/Resources'); $templateNameParser = new StubTemplateNameParser($root, $rootTheme); - $loader = new FilesystemLoader(array()); + $loader = new FilesystemLoader([]); $this->engine = new PhpEngine($templateNameParser, $loader); $this->engine->addGlobal('global', ''); - $this->engine->setHelpers(array( + $this->engine->setHelpers([ new TranslatorHelper(new StubTranslator()), - )); + ]); - return array_merge(parent::getExtensions(), array( - new TemplatingExtension($this->engine, $this->csrfTokenManager, array( + return array_merge(parent::getExtensions(), [ + new TemplatingExtension($this->engine, $this->csrfTokenManager, [ 'FrameworkBundle:Form', 'FrameworkBundle:FormTable', - )), - )); + ]), + ]); } protected function tearDown() @@ -82,12 +82,12 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest parent::tearDown(); } - protected function renderForm(FormView $view, array $vars = array()) + protected function renderForm(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->form($view, $vars); } - protected function renderLabel(FormView $view, $label = null, array $vars = array()) + protected function renderLabel(FormView $view, $label = null, array $vars = []) { return (string) $this->engine->get('form')->label($view, $label, $vars); } @@ -102,27 +102,27 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest return (string) $this->engine->get('form')->errors($view); } - protected function renderWidget(FormView $view, array $vars = array()) + protected function renderWidget(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->widget($view, $vars); } - protected function renderRow(FormView $view, array $vars = array()) + protected function renderRow(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->row($view, $vars); } - protected function renderRest(FormView $view, array $vars = array()) + protected function renderRest(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->rest($view, $vars); } - protected function renderStart(FormView $view, array $vars = array()) + protected function renderStart(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->start($view, $vars); } - protected function renderEnd(FormView $view, array $vars = array()) + protected function renderEnd(FormView $view, array $vars = []) { return (string) $this->engine->get('form')->end($view, $vars); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php index 6795bc1a59..a2068ae757 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php @@ -24,7 +24,7 @@ class RequestHelperTest extends TestCase { $this->requestStack = new RequestStack(); $request = new Request(); - $request->initialize(array('foobar' => 'bar')); + $request->initialize(['foobar' => 'bar']); $this->requestStack->push($request); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php index 05240035c0..4ad7e75ddc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php @@ -1,2 +1,2 @@ humanize($name); } ?> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php index e165a429a5..71de9d4631 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php @@ -1,4 +1,4 @@ humanize($name); } ?> - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php index c0fc0ba0bb..06984095f1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php @@ -47,13 +47,13 @@ class SessionHelperTest extends TestCase $this->assertTrue($helper->hasFlash('notice')); - $this->assertEquals(array('bar'), $helper->getFlash('notice')); + $this->assertEquals(['bar'], $helper->getFlash('notice')); } public function testGetFlashes() { $helper = new SessionHelper($this->requestStack); - $this->assertEquals(array('notice' => array('bar')), $helper->getFlashes()); + $this->assertEquals(['notice' => ['bar']], $helper->getFlashes()); } public function testGet() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 37ea5b484b..3317b15d90 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -90,8 +90,8 @@ class TemplateLocatorTest extends TestCase { return $this ->getMockBuilder('Symfony\Component\Config\FileLocator') - ->setMethods(array('locate')) - ->setConstructorArgs(array('/path/to/fallback')) + ->setMethods(['locate']) + ->setConstructorArgs(['/path/to/fallback']) ->getMock() ; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php index eedbcd27df..3c44612b87 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php @@ -45,12 +45,12 @@ class TemplateFilenameParserTest extends TestCase public function getFilenameToTemplateProvider() { - return array( - array('/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')), - array('\\path\\to\\section\\name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')), - array('name.format.engine', new TemplateReference('', '', 'name', 'format', 'engine')), - array('name.format', false), - array('name', false), - ); + return [ + ['/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')], + ['\\path\\to\\section\\name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')], + ['name.format.engine', new TemplateReference('', '', 'name', 'format', 'engine')], + ['name.format', false], + ['name', false], + ]; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php index 0321d0532f..66872049ad 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php @@ -26,11 +26,11 @@ class TemplateTest extends TestCase public function getTemplateToPathProvider() { - return array( - array(new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'), - array(new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'), - array(new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'), - array(new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'), - ); + return [ + [new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'], + [new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'], + [new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'], + [new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'], + ]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php index 1715fbf117..17ffeb90f4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php +++ b/src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php @@ -53,7 +53,7 @@ final class WrappedListener implements ListenerInterface */ public function __call($method, $arguments) { - return \call_user_func_array(array($this->listener, $method), $arguments); + return \call_user_func_array([$this->listener, $method], $arguments); } public function getWrappedListener(): ListenerInterface @@ -67,10 +67,10 @@ final class WrappedListener implements ListenerInterface $this->stub = self::$hasVarDumper ? new ClassStub(\get_class($this->listener)) : \get_class($this->listener); } - return array( + return [ 'response' => $this->response, 'time' => $this->time, 'stub' => $this->stub, - ); + ]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/RegisterCsrfTokenClearingLogoutHandlerPass.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/RegisterCsrfTokenClearingLogoutHandlerPass.php index d4d28ecc4e..0d7527c26b 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/RegisterCsrfTokenClearingLogoutHandlerPass.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/RegisterCsrfTokenClearingLogoutHandlerPass.php @@ -37,6 +37,6 @@ class RegisterCsrfTokenClearingLogoutHandlerPass implements CompilerPassInterfac ->addArgument(new Reference('security.csrf.token_storage')) ->setPublic(false); - $container->findDefinition('security.logout_listener')->addMethodCall('addHandler', array(new Reference('security.logout.handler.csrf_token_clearing'))); + $container->findDefinition('security.logout_listener')->addMethodCall('addHandler', [new Reference('security.logout.handler.csrf_token_clearing')]); } } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index 195ef4c23a..00bb451e0e 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -26,26 +26,26 @@ use Symfony\Component\DependencyInjection\Reference; */ abstract class AbstractFactory implements SecurityFactoryInterface { - protected $options = array( + protected $options = [ 'check_path' => '/login_check', 'use_forward' => false, 'require_previous_session' => false, - ); + ]; - protected $defaultSuccessHandlerOptions = array( + protected $defaultSuccessHandlerOptions = [ 'always_use_default_target_path' => false, 'default_target_path' => '/', 'login_path' => '/login', 'target_path_parameter' => '_target_path', 'use_referer' => false, - ); + ]; - protected $defaultFailureHandlerOptions = array( + protected $defaultFailureHandlerOptions = [ 'failure_path' => null, 'failure_forward' => false, 'login_path' => '/login', 'failure_path_parameter' => '_failure_path', - ); + ]; public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId) { @@ -59,14 +59,14 @@ abstract class AbstractFactory implements SecurityFactoryInterface if ($this->isRememberMeAware($config)) { $container ->getDefinition($listenerId) - ->addTag('security.remember_me_aware', array('id' => $id, 'provider' => $userProviderId)) + ->addTag('security.remember_me_aware', ['id' => $id, 'provider' => $userProviderId]) ; } // create entry point if applicable (optional) $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPointId); - return array($authProviderId, $listenerId, $entryPointId); + return [$authProviderId, $listenerId, $entryPointId]; } public function addConfiguration(NodeDefinition $node) @@ -178,8 +178,8 @@ abstract class AbstractFactory implements SecurityFactoryInterface $successHandler->replaceArgument(2, $id); } else { $successHandler = $container->setDefinition($successHandlerId, new ChildDefinition('security.authentication.success_handler')); - $successHandler->addMethodCall('setOptions', array($options)); - $successHandler->addMethodCall('setProviderKey', array($id)); + $successHandler->addMethodCall('setOptions', [$options]); + $successHandler->addMethodCall('setProviderKey', [$id]); } return $successHandlerId; @@ -196,7 +196,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface $failureHandler->replaceArgument(1, $options); } else { $failureHandler = $container->setDefinition($id, new ChildDefinition('security.authentication.failure_handler')); - $failureHandler->addMethodCall('setOptions', array($options)); + $failureHandler->addMethodCall('setOptions', [$options]); } return $id; diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php index 8bd389dc95..3d9d4b2186 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php @@ -37,7 +37,7 @@ class FormLoginLdapFactory extends FormLoginFactory ; if (!empty($config['query_string'])) { - $definition->addMethodCall('setQueryString', array($config['query_string'])); + $definition->addMethodCall('setQueryString', [$config['query_string']]); } return $provider; diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php index 03b299e50d..8384c42da7 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php @@ -58,7 +58,7 @@ class GuardAuthenticationFactory implements SecurityFactoryInterface public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $authenticatorIds = $config['authenticators']; - $authenticatorReferences = array(); + $authenticatorReferences = []; foreach ($authenticatorIds as $authenticatorId) { $authenticatorReferences[] = new Reference($authenticatorId); } @@ -87,9 +87,9 @@ class GuardAuthenticationFactory implements SecurityFactoryInterface // this is always injected - then the listener decides if it should be used $container ->getDefinition($listenerId) - ->addTag('security.remember_me_aware', array('id' => $id, 'provider' => $userProvider)); + ->addTag('security.remember_me_aware', ['id' => $id, 'provider' => $userProvider]); - return array($providerId, $listenerId, $entryPointId); + return [$providerId, $listenerId, $entryPointId]; } private function determineEntryPoint($defaultEntryPointId, array $config) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php index 7c90ef6205..f3b5bc167e 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicFactory.php @@ -41,9 +41,9 @@ class HttpBasicFactory implements SecurityFactoryInterface $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.basic')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($entryPointId)); - $listener->addMethodCall('setSessionAuthenticationStrategy', array(new Reference('security.authentication.session_strategy.'.$id))); + $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); - return array($provider, $listenerId, $entryPointId); + return [$provider, $listenerId, $entryPointId]; } public function getPosition() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php index ce3cdda96e..8ae0201568 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php @@ -41,7 +41,7 @@ class HttpBasicLdapFactory extends HttpBasicFactory $entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPoint); if (!empty($config['query_string'])) { - $definition->addMethodCall('setQueryString', array($config['query_string'])); + $definition->addMethodCall('setQueryString', [$config['query_string']]); } // listener @@ -50,7 +50,7 @@ class HttpBasicLdapFactory extends HttpBasicFactory $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($entryPointId)); - return array($provider, $listenerId, $entryPointId); + return [$provider, $listenerId, $entryPointId]; } public function addConfiguration(NodeDefinition $node) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginFactory.php index 6c7adb0323..a660401dbe 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginFactory.php @@ -26,8 +26,8 @@ class JsonLoginFactory extends AbstractFactory { $this->addOption('username_path', 'username'); $this->addOption('password_path', 'password'); - $this->defaultFailureHandlerOptions = array(); - $this->defaultSuccessHandlerOptions = array(); + $this->defaultFailureHandlerOptions = []; + $this->defaultSuccessHandlerOptions = []; } /** @@ -89,7 +89,7 @@ class JsonLoginFactory extends AbstractFactory $listener->replaceArgument(4, isset($config['success_handler']) ? new Reference($this->createAuthenticationSuccessHandler($container, $id, $config)) : null); $listener->replaceArgument(5, isset($config['failure_handler']) ? new Reference($this->createAuthenticationFailureHandler($container, $id, $config)) : null); $listener->replaceArgument(6, array_intersect_key($config, $this->options)); - $listener->addMethodCall('setSessionAuthenticationStrategy', array(new Reference('security.authentication.session_strategy.'.$id))); + $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); $listenerId .= '.'.$id; $container->setDefinition($listenerId, $listener); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index 89b428a27d..34de3d6701 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\Reference; class RememberMeFactory implements SecurityFactoryInterface { - protected $options = array( + protected $options = [ 'name' => 'REMEMBERME', 'lifetime' => 31536000, 'path' => '/', @@ -27,7 +27,7 @@ class RememberMeFactory implements SecurityFactoryInterface 'httponly' => true, 'always_remember_me' => false, 'remember_me_parameter' => '_remember_me', - ); + ]; public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { @@ -52,7 +52,7 @@ class RememberMeFactory implements SecurityFactoryInterface if ($container->hasDefinition('security.logout_listener.'.$id)) { $container ->getDefinition('security.logout_listener.'.$id) - ->addMethodCall('addHandler', array(new Reference($rememberMeServicesId))) + ->addMethodCall('addHandler', [new Reference($rememberMeServicesId)]) ; } @@ -61,16 +61,16 @@ class RememberMeFactory implements SecurityFactoryInterface $rememberMeServices->replaceArgument(2, $id); if (isset($config['token_provider'])) { - $rememberMeServices->addMethodCall('setTokenProvider', array( + $rememberMeServices->addMethodCall('setTokenProvider', [ new Reference($config['token_provider']), - )); + ]); } // remember-me options $rememberMeServices->replaceArgument(3, array_intersect_key($config, $this->options)); // attach to remember-me aware listeners - $userProviders = array(); + $userProviders = []; foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) { foreach ($attributes as $attribute) { if (!isset($attribute['id']) || $attribute['id'] !== $id) { @@ -84,12 +84,12 @@ class RememberMeFactory implements SecurityFactoryInterface $userProviders[] = new Reference($attribute['provider']); $container ->getDefinition($serviceId) - ->addMethodCall('setRememberMeServices', array(new Reference($rememberMeServicesId))) + ->addMethodCall('setRememberMeServices', [new Reference($rememberMeServicesId)]) ; } } if ($config['user_providers']) { - $userProviders = array(); + $userProviders = []; foreach ($config['user_providers'] as $providerName) { $userProviders[] = new Reference('security.user.provider.concrete.'.$providerName); } @@ -106,7 +106,7 @@ class RememberMeFactory implements SecurityFactoryInterface $listener->replaceArgument(1, new Reference($rememberMeServicesId)); $listener->replaceArgument(5, $config['catch_exceptions']); - return array($authProviderId, $listenerId, $defaultEntryPoint); + return [$authProviderId, $listenerId, $defaultEntryPoint]; } public function getPosition() @@ -131,7 +131,7 @@ class RememberMeFactory implements SecurityFactoryInterface ->scalarNode('token_provider')->end() ->arrayNode('user_providers') ->beforeNormalization() - ->ifString()->then(function ($v) { return array($v); }) + ->ifString()->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php index 654816e50e..176f65b135 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RemoteUserFactory.php @@ -38,9 +38,9 @@ class RemoteUserFactory implements SecurityFactoryInterface $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.remote_user')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, $config['user']); - $listener->addMethodCall('setSessionAuthenticationStrategy', array(new Reference('security.authentication.session_strategy.'.$id))); + $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); - return array($providerId, $listenerId, $defaultEntryPoint); + return [$providerId, $listenerId, $defaultEntryPoint]; } public function getPosition() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php index de0df6868f..f92796d58a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php @@ -57,8 +57,8 @@ class SimplePreAuthenticationFactory implements SecurityFactoryInterface $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.simple_preauth')); $listener->replaceArgument(2, $id); $listener->replaceArgument(3, new Reference($config['authenticator'])); - $listener->addMethodCall('setSessionAuthenticationStrategy', array(new Reference('security.authentication.session_strategy.'.$id))); + $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); - return array($provider, $listenerId, null); + return [$provider, $listenerId, null]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php index 17390f4b82..35879ee495 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/X509Factory.php @@ -39,9 +39,9 @@ class X509Factory implements SecurityFactoryInterface $listener->replaceArgument(2, $id); $listener->replaceArgument(3, $config['user']); $listener->replaceArgument(4, $config['credentials']); - $listener->addMethodCall('setSessionAuthenticationStrategy', array(new Reference('security.authentication.session_strategy.'.$id))); + $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); - return array($providerId, $listenerId, $defaultEntryPoint); + return [$providerId, $listenerId, $defaultEntryPoint]; } public function getPosition() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php index 6b0800953b..1e76601105 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php @@ -28,10 +28,10 @@ class InMemoryFactory implements UserProviderFactoryInterface { $definition = $container->setDefinition($id, new ChildDefinition('security.user.provider.in_memory')); $defaultPassword = new Parameter('container.build_id'); - $users = array(); + $users = []; foreach ($config['users'] as $username => $user) { - $users[$username] = array('password' => null !== $user['password'] ? (string) $user['password'] : $defaultPassword, 'roles' => $user['roles']); + $users[$username] = ['password' => null !== $user['password'] ? (string) $user['password'] : $defaultPassword, 'roles' => $user['roles']]; } $definition->addArgument($users); diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php index 92539413f1..d33cfdc7b1 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php @@ -40,10 +40,10 @@ class FirewallMap implements FirewallMapInterface $context = $this->getFirewallContext($request); if (null === $context) { - return array(array(), null, null); + return [[], null, null]; } - return array($context->getListeners(), $context->getExceptionListener(), $context->getLogoutListener()); + return [$context->getListeners(), $context->getExceptionListener(), $context->getLogoutListener()]; } /** diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 5e71ac6d8a..f8b06f148b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -92,12 +92,12 @@ class SecurityDataCollectorTest extends TestCase public function testCollectImpersonatedToken() { - $adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', array('ROLE_ADMIN')); + $adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', ['ROLE_ADMIN']); - $userRoles = array( + $userRoles = [ 'ROLE_USER', new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $adminToken), - ); + ]; $tokenStorage = new TokenStorage(); $tokenStorage->setToken(new UsernamePasswordToken('hhamon', 'P4$$w0rD', 'provider', $userRoles)); @@ -112,8 +112,8 @@ class SecurityDataCollectorTest extends TestCase $this->assertSame('yceruto', $collector->getImpersonatorUser()); $this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $collector->getTokenClass()->getValue()); $this->assertTrue($collector->supportsRoleHierarchy()); - $this->assertSame(array('ROLE_USER', 'ROLE_PREVIOUS_ADMIN'), $collector->getRoles()->getValue(true)); - $this->assertSame(array(), $collector->getInheritedRoles()->getValue(true)); + $this->assertSame(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $collector->getRoles()->getValue(true)); + $this->assertSame([], $collector->getInheritedRoles()->getValue(true)); $this->assertSame('hhamon', $collector->getUser()); } @@ -208,7 +208,7 @@ class SecurityDataCollectorTest extends TestCase ->expects($this->once()) ->method('getListeners') ->with($request) - ->willReturn(array(array($listener), null)); + ->willReturn([[$listener], null]); $firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()); $firewall->onKernelRequest($event); @@ -223,43 +223,43 @@ class SecurityDataCollectorTest extends TestCase public function provideRoles() { - return array( + return [ // Basic roles - array( - array('ROLE_USER'), - array('ROLE_USER'), - array(), - ), - array( - array(new Role('ROLE_USER')), - array('ROLE_USER'), - array(), - ), + [ + ['ROLE_USER'], + ['ROLE_USER'], + [], + ], + [ + [new Role('ROLE_USER')], + ['ROLE_USER'], + [], + ], // Inherited roles - array( - array('ROLE_ADMIN'), - array('ROLE_ADMIN'), - array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), - ), - array( - array(new Role('ROLE_ADMIN')), - array('ROLE_ADMIN'), - array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), - ), - array( - array('ROLE_ADMIN', 'ROLE_OPERATOR'), - array('ROLE_ADMIN', 'ROLE_OPERATOR'), - array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), - ), - ); + [ + ['ROLE_ADMIN'], + ['ROLE_ADMIN'], + ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], + ], + [ + [new Role('ROLE_ADMIN')], + ['ROLE_ADMIN'], + ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], + ], + [ + ['ROLE_ADMIN', 'ROLE_OPERATOR'], + ['ROLE_ADMIN', 'ROLE_OPERATOR'], + ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], + ], + ]; } private function getRoleHierarchy() { - return new RoleHierarchy(array( - 'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), - 'ROLE_OPERATOR' => array('ROLE_USER'), - )); + return new RoleHierarchy([ + 'ROLE_ADMIN' => ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], + 'ROLE_OPERATOR' => ['ROLE_USER'], + ]); } private function getRequest() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php index 854391c235..ed5bba4412 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Debug/TraceableFirewallListenerTest.php @@ -51,7 +51,7 @@ class TraceableFirewallListenerTest extends TestCase ->expects($this->once()) ->method('getListeners') ->with($request) - ->willReturn(array(array($listener), null)); + ->willReturn([[$listener], null]); $firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()); $firewall->onKernelRequest($event); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php index 382bdebe01..2d34dc9376 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php @@ -22,7 +22,7 @@ class AddSessionDomainConstraintPassTest extends TestCase { public function testSessionCookie() { - $container = $this->createContainer(array('cookie_domain' => '.symfony.com.', 'cookie_secure' => true)); + $container = $this->createContainer(['cookie_domain' => '.symfony.com.', 'cookie_secure' => true]); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); @@ -37,7 +37,7 @@ class AddSessionDomainConstraintPassTest extends TestCase public function testSessionNoDomain() { - $container = $this->createContainer(array('cookie_secure' => true)); + $container = $this->createContainer(['cookie_secure' => true]); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); @@ -52,7 +52,7 @@ class AddSessionDomainConstraintPassTest extends TestCase public function testSessionNoSecure() { - $container = $this->createContainer(array('cookie_domain' => '.symfony.com.')); + $container = $this->createContainer(['cookie_domain' => '.symfony.com.']); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); @@ -67,7 +67,7 @@ class AddSessionDomainConstraintPassTest extends TestCase public function testSessionNoSecureAndNoDomain() { - $container = $this->createContainer(array()); + $container = $this->createContainer([]); $utils = $container->get('security.http_utils'); $request = Request::create('/', 'get'); @@ -99,7 +99,7 @@ class AddSessionDomainConstraintPassTest extends TestCase private function createContainer($sessionStorageOptions) { $container = new ContainerBuilder(); - $container->setParameter('kernel.bundles_metadata', array()); + $container->setParameter('kernel.bundles_metadata', []); $container->setParameter('kernel.cache_dir', __DIR__); $container->setParameter('kernel.charset', 'UTF-8'); $container->setParameter('kernel.container_class', 'cc'); @@ -113,15 +113,15 @@ class AddSessionDomainConstraintPassTest extends TestCase $container->setParameter('request_listener.http_port', 80); $container->setParameter('request_listener.https_port', 443); - $config = array( - 'security' => array( - 'providers' => array('some_provider' => array('id' => 'foo')), - 'firewalls' => array('some_firewall' => array('security' => false)), - ), - ); + $config = [ + 'security' => [ + 'providers' => ['some_provider' => ['id' => 'foo']], + 'firewalls' => ['some_firewall' => ['security' => false]], + ], + ]; $ext = new FrameworkExtension(); - $ext->load(array('framework' => array('csrf_protection' => false)), $container); + $ext->load(['framework' => ['csrf_protection' => false]], $container); $ext = new SecurityExtension(); $ext->load($config, $container); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_customized_config.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_customized_config.php index cd3cc12000..1d0a090f3f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_customized_config.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_customized_config.php @@ -1,20 +1,20 @@ loadFromExtension('security', array( - 'access_decision_manager' => array( +$container->loadFromExtension('security', [ + 'access_decision_manager' => [ 'allow_if_all_abstain' => true, 'allow_if_equal_granted_denied' => false, - ), - 'providers' => array( - 'default' => array( - 'memory' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - ), - ), - ), - ), - 'firewalls' => array( - 'simple' => array('pattern' => '/login', 'security' => false), - ), -)); + ], + 'providers' => [ + 'default' => [ + 'memory' => [ + 'users' => [ + 'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'], + ], + ], + ], + ], + 'firewalls' => [ + 'simple' => ['pattern' => '/login', 'security' => false], + ], +]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_default_strategy.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_default_strategy.php index d06fc3e686..1f0adbf301 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_default_strategy.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_default_strategy.php @@ -1,16 +1,16 @@ loadFromExtension('security', array( - 'providers' => array( - 'default' => array( - 'memory' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - ), - ), - ), - ), - 'firewalls' => array( - 'simple' => array('pattern' => '/login', 'security' => false), - ), -)); +$container->loadFromExtension('security', [ + 'providers' => [ + 'default' => [ + 'memory' => [ + 'users' => [ + 'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'], + ], + ], + ], + ], + 'firewalls' => [ + 'simple' => ['pattern' => '/login', 'security' => false], + ], +]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service.php index 29db539362..8f615904dd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service.php @@ -1,19 +1,19 @@ loadFromExtension('security', array( - 'access_decision_manager' => array( +$container->loadFromExtension('security', [ + 'access_decision_manager' => [ 'service' => 'app.access_decision_manager', - ), - 'providers' => array( - 'default' => array( - 'memory' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - ), - ), - ), - ), - 'firewalls' => array( - 'simple' => array('pattern' => '/login', 'security' => false), - ), -)); + ], + 'providers' => [ + 'default' => [ + 'memory' => [ + 'users' => [ + 'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'], + ], + ], + ], + ], + 'firewalls' => [ + 'simple' => ['pattern' => '/login', 'security' => false], + ], +]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service_and_strategy.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service_and_strategy.php index f7175e21f6..bd78bdf24d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service_and_strategy.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access_decision_manager_service_and_strategy.php @@ -1,20 +1,20 @@ loadFromExtension('security', array( - 'access_decision_manager' => array( +$container->loadFromExtension('security', [ + 'access_decision_manager' => [ 'service' => 'app.access_decision_manager', 'strategy' => 'affirmative', - ), - 'providers' => array( - 'default' => array( - 'memory' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - ), - ), - ), - ), - 'firewalls' => array( - 'simple' => array('pattern' => '/login', 'security' => false), - ), -)); + ], + 'providers' => [ + 'default' => [ + 'memory' => [ + 'users' => [ + 'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'], + ], + ], + ], + ], + 'firewalls' => [ + 'simple' => ['pattern' => '/login', 'security' => false], + ], +]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php index a367a67682..ca82e805c3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -19,13 +19,13 @@ class AbstractFactoryTest extends TestCase { public function testCreate() { - list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', array( + list($container, $authProviderId, $listenerId, $entryPointId) = $this->callFactory('foo', [ 'use_forward' => true, 'failure_path' => '/foo', 'success_handler' => 'custom_success_handler', 'failure_handler' => 'custom_failure_handler', 'remember_me' => true, - ), 'user_provider', 'entry_point'); + ], 'user_provider', 'entry_point'); // auth provider $this->assertEquals('auth_provider', $authProviderId); @@ -34,14 +34,14 @@ class AbstractFactoryTest extends TestCase $this->assertEquals('abstract_listener.foo', $listenerId); $this->assertTrue($container->hasDefinition('abstract_listener.foo')); $definition = $container->getDefinition('abstract_listener.foo'); - $this->assertEquals(array( + $this->assertEquals([ 'index_4' => 'foo', 'index_5' => new Reference('security.authentication.success_handler.foo.abstract_factory'), 'index_6' => new Reference('security.authentication.failure_handler.foo.abstract_factory'), - 'index_7' => array( + 'index_7' => [ 'use_forward' => true, - ), - ), $definition->getArguments()); + ], + ], $definition->getArguments()); // entry point $this->assertEquals('entry_point', $entryPointId, '->create() does not change the default entry point.'); @@ -52,10 +52,10 @@ class AbstractFactoryTest extends TestCase */ public function testDefaultFailureHandler($serviceId, $defaultHandlerInjection) { - $options = array( + $options = [ 'remember_me' => true, 'login_path' => '/bar', - ); + ]; if ($serviceId) { $options['failure_handler'] = $serviceId; @@ -71,7 +71,7 @@ class AbstractFactoryTest extends TestCase $methodCalls = $failureHandler->getMethodCalls(); if ($defaultHandlerInjection) { $this->assertEquals('setOptions', $methodCalls[0][0]); - $this->assertEquals(array('login_path' => '/bar'), $methodCalls[0][1][0]); + $this->assertEquals(['login_path' => '/bar'], $methodCalls[0][1][0]); } else { $this->assertCount(0, $methodCalls); } @@ -79,10 +79,10 @@ class AbstractFactoryTest extends TestCase public function getFailureHandlers() { - return array( - array(null, true), - array('custom_failure_handler', false), - ); + return [ + [null, true], + ['custom_failure_handler', false], + ]; } /** @@ -90,10 +90,10 @@ class AbstractFactoryTest extends TestCase */ public function testDefaultSuccessHandler($serviceId, $defaultHandlerInjection) { - $options = array( + $options = [ 'remember_me' => true, 'default_target_path' => '/bar', - ); + ]; if ($serviceId) { $options['success_handler'] = $serviceId; @@ -109,9 +109,9 @@ class AbstractFactoryTest extends TestCase if ($defaultHandlerInjection) { $this->assertEquals('setOptions', $methodCalls[0][0]); - $this->assertEquals(array('default_target_path' => '/bar'), $methodCalls[0][1][0]); + $this->assertEquals(['default_target_path' => '/bar'], $methodCalls[0][1][0]); $this->assertEquals('setProviderKey', $methodCalls[1][0]); - $this->assertEquals(array('foo'), $methodCalls[1][1]); + $this->assertEquals(['foo'], $methodCalls[1][1]); } else { $this->assertCount(0, $methodCalls); } @@ -119,15 +119,15 @@ class AbstractFactoryTest extends TestCase public function getSuccessHandlers() { - return array( - array(null, true), - array('custom_success_handler', false), - ); + return [ + [null, true], + ['custom_success_handler', false], + ]; } protected function callFactory($id, $config, $userProviderId, $defaultEntryPointId) { - $factory = $this->getMockForAbstractClass('Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory', array()); + $factory = $this->getMockForAbstractClass('Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory', []); $factory ->expects($this->once()) @@ -152,6 +152,6 @@ class AbstractFactoryTest extends TestCase list($authProviderId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId); - return array($container, $authProviderId, $listenerId, $entryPointId); + return [$container, $authProviderId, $listenerId, $entryPointId]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php index 55a3ad387c..81db40412a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/GuardAuthenticationFactoryTest.php @@ -54,44 +54,44 @@ class GuardAuthenticationFactoryTest extends TestCase public function getValidConfigurationTests() { - $tests = array(); + $tests = []; // completely basic - $tests[] = array( - array( - 'authenticators' => array('authenticator1', 'authenticator2'), + $tests[] = [ + [ + 'authenticators' => ['authenticator1', 'authenticator2'], 'provider' => 'some_provider', 'entry_point' => 'the_entry_point', - ), - array( - 'authenticators' => array('authenticator1', 'authenticator2'), + ], + [ + 'authenticators' => ['authenticator1', 'authenticator2'], 'provider' => 'some_provider', 'entry_point' => 'the_entry_point', - ), - ); + ], + ]; // testing xml config fix: authenticator -> authenticators - $tests[] = array( - array( - 'authenticator' => array('authenticator1', 'authenticator2'), - ), - array( - 'authenticators' => array('authenticator1', 'authenticator2'), + $tests[] = [ + [ + 'authenticator' => ['authenticator1', 'authenticator2'], + ], + [ + 'authenticators' => ['authenticator1', 'authenticator2'], 'entry_point' => null, - ), - ); + ], + ]; return $tests; } public function getInvalidConfigurationTests() { - $tests = array(); + $tests = []; // testing not empty - $tests[] = array( - array('authenticators' => array()), - ); + $tests[] = [ + ['authenticators' => []], + ]; return $tests; } @@ -99,33 +99,33 @@ class GuardAuthenticationFactoryTest extends TestCase public function testBasicCreate() { // simple configuration - $config = array( - 'authenticators' => array('authenticator123'), + $config = [ + 'authenticators' => ['authenticator123'], 'entry_point' => null, - ); + ]; list($container, $entryPointId) = $this->executeCreate($config, null); $this->assertEquals('authenticator123', $entryPointId); $providerDefinition = $container->getDefinition('security.authentication.provider.guard.my_firewall'); - $this->assertEquals(array( - 'index_0' => new IteratorArgument(array(new Reference('authenticator123'))), + $this->assertEquals([ + 'index_0' => new IteratorArgument([new Reference('authenticator123')]), 'index_1' => new Reference('my_user_provider'), 'index_2' => 'my_firewall', 'index_3' => new Reference('security.user_checker.my_firewall'), - ), $providerDefinition->getArguments()); + ], $providerDefinition->getArguments()); $listenerDefinition = $container->getDefinition('security.authentication.listener.guard.my_firewall'); $this->assertEquals('my_firewall', $listenerDefinition->getArgument(2)); - $this->assertEquals(array(new Reference('authenticator123')), $listenerDefinition->getArgument(3)->getValues()); + $this->assertEquals([new Reference('authenticator123')], $listenerDefinition->getArgument(3)->getValues()); } public function testExistingDefaultEntryPointUsed() { // any existing default entry point is used - $config = array( - 'authenticators' => array('authenticator123'), + $config = [ + 'authenticators' => ['authenticator123'], 'entry_point' => null, - ); + ]; list(, $entryPointId) = $this->executeCreate($config, 'some_default_entry_point'); $this->assertEquals('some_default_entry_point', $entryPointId); } @@ -136,10 +136,10 @@ class GuardAuthenticationFactoryTest extends TestCase public function testCannotOverrideDefaultEntryPoint() { // any existing default entry point is used - $config = array( - 'authenticators' => array('authenticator123'), + $config = [ + 'authenticators' => ['authenticator123'], 'entry_point' => 'authenticator123', - ); + ]; $this->executeCreate($config, 'some_default_entry_point'); } @@ -149,20 +149,20 @@ class GuardAuthenticationFactoryTest extends TestCase public function testMultipleAuthenticatorsRequiresEntryPoint() { // any existing default entry point is used - $config = array( - 'authenticators' => array('authenticator123', 'authenticatorABC'), + $config = [ + 'authenticators' => ['authenticator123', 'authenticatorABC'], 'entry_point' => null, - ); + ]; $this->executeCreate($config, null); } public function testCreateWithEntryPoint() { // any existing default entry point is used - $config = array( - 'authenticators' => array('authenticator123', 'authenticatorABC'), + $config = [ + 'authenticators' => ['authenticator123', 'authenticatorABC'], 'entry_point' => 'authenticatorABC', - ); + ]; list($container, $entryPointId) = $this->executeCreate($config, null); $this->assertEquals('authenticatorABC', $entryPointId); } @@ -178,6 +178,6 @@ class GuardAuthenticationFactoryTest extends TestCase $factory = new GuardAuthenticationFactory(); list($providerId, $listenerId, $entryPointId) = $factory->create($container, $id, $config, $userProviderId, $defaultEntryPointId); - return array($container, $entryPointId); + return [$container, $entryPointId]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php index 6ac0e6a3af..2a31f2a27a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php @@ -15,7 +15,7 @@ class AuthenticationCommencingTest extends WebTestCase { public function testAuthenticationIsCommencingIfAccessDeniedExceptionIsWrapped() { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'config.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'config.yml']); $client->request('GET', '/secure-but-not-covered-by-access-control'); $this->assertRedirect($client->getResponse(), '/login'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php index 90f4d355a4..bafa0f68ce 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php @@ -24,9 +24,9 @@ class LoginController implements ContainerAwareInterface { $form = $this->container->get('form.factory')->create('Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType'); - return new Response($this->container->get('twig')->render('@CsrfFormLogin/Login/login.html.twig', array( + return new Response($this->container->get('twig')->render('@CsrfFormLogin/Login/login.html.twig', [ 'form' => $form->createView(), - ))); + ])); } public function afterLoginAction() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginType.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginType.php index 2f4f20df3a..63b27512d5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginType.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginType.php @@ -65,9 +65,9 @@ class UserLoginType extends AbstractType $event->getForm()->addError(new FormError($error->getMessage())); } - $event->setData(array_replace((array) $event->getData(), array( + $event->setData(array_replace((array) $event->getData(), [ 'username' => $request->getSession()->get(Security::LAST_USERNAME), - ))); + ])); }); } @@ -80,8 +80,8 @@ class UserLoginType extends AbstractType * listener in order for the CSRF token to validate successfully. */ - $resolver->setDefaults(array( + $resolver->setDefaults([ 'csrf_token_id' => 'authenticate', - )); + ]); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php index 33d70ef7df..3bf2a7767c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php @@ -30,11 +30,11 @@ class LocalizedController implements ContainerAwareInterface $error = $request->getSession()->get(Security::AUTHENTICATION_ERROR); } - return new Response($this->container->get('twig')->render('@FormLogin/Localized/login.html.twig', array( + return new Response($this->container->get('twig')->render('@FormLogin/Localized/login.html.twig', [ // last username entered by the user 'last_username' => $request->getSession()->get(Security::LAST_USERNAME), 'error' => $error, - ))); + ])); } public function loginCheckAction() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php index 04fe49055b..60eef86718 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php @@ -32,16 +32,16 @@ class LoginController implements ContainerAwareInterface $error = $request->getSession()->get(Security::AUTHENTICATION_ERROR); } - return new Response($this->container->get('twig')->render('@FormLogin/Login/login.html.twig', array( + return new Response($this->container->get('twig')->render('@FormLogin/Login/login.html.twig', [ // last username entered by the user 'last_username' => $request->getSession()->get(Security::LAST_USERNAME), 'error' => $error, - ))); + ])); } public function afterLoginAction(UserInterface $user) { - return new Response($this->container->get('twig')->render('@FormLogin/Login/after_login.html.twig', array('user' => $user))); + return new Response($this->container->get('twig')->render('@FormLogin/Login/after_login.html.twig', ['user' => $user])); } public function loginCheckAction() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php index 7b97199065..f8f1c450d3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Security/LocalizedFormFailureHandler.php @@ -29,6 +29,6 @@ class LocalizedFormFailureHandler implements AuthenticationFailureHandlerInterfa public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { - return new RedirectResponse($this->router->generate('localized_login_path', array(), UrlGeneratorInterface::ABSOLUTE_URL)); + return new RedirectResponse($this->router->generate('localized_login_path', [], UrlGeneratorInterface::ABSOLUTE_URL)); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller/TestController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller/TestController.php index 3effab9b59..cba75a1526 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller/TestController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Controller/TestController.php @@ -21,6 +21,6 @@ class TestController { public function loginCheckAction(UserInterface $user) { - return new JsonResponse(array('message' => sprintf('Welcome @%s!', $user->getUsername()))); + return new JsonResponse(['message' => sprintf('Welcome @%s!', $user->getUsername())]); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php index fbd482ddff..737c5a5abe 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationFailureHandler.php @@ -20,6 +20,6 @@ class JsonAuthenticationFailureHandler implements AuthenticationFailureHandlerIn { public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { - return new JsonResponse(array('message' => 'Something went wrong'), 500); + return new JsonResponse(['message' => 'Something went wrong'], 500); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php index 0e65bbb56b..0390eb8e35 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/JsonLoginBundle/Security/Http/JsonAuthenticationSuccessHandler.php @@ -20,6 +20,6 @@ class JsonAuthenticationSuccessHandler implements AuthenticationSuccessHandlerIn { public function onAuthenticationSuccess(Request $request, TokenInterface $token) { - return new JsonResponse(array('message' => sprintf('Good game @%s!', $token->getUsername()))); + return new JsonResponse(['message' => sprintf('Good game @%s!', $token->getUsername())]); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php index 2d95d35065..98b52a5f05 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php @@ -18,7 +18,7 @@ class CsrfFormLoginTest extends WebTestCase */ public function testFormLoginAndLogoutWithCsrfTokens($config) { - $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'CsrfFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[username]'] = 'johannes'; @@ -48,7 +48,7 @@ class CsrfFormLoginTest extends WebTestCase */ public function testFormLoginWithInvalidCsrfToken($config) { - $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'CsrfFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[_token]'] = ''; @@ -65,7 +65,7 @@ class CsrfFormLoginTest extends WebTestCase */ public function testFormLoginWithCustomTargetPath($config) { - $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'CsrfFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['user_login[username]'] = 'johannes'; @@ -85,7 +85,7 @@ class CsrfFormLoginTest extends WebTestCase */ public function testFormLoginRedirectsToProtectedResourceAfterLogin($config) { - $client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'CsrfFormLogin', 'root_config' => $config]); $client->request('GET', '/protected-resource'); $this->assertRedirect($client->getResponse(), '/login'); @@ -103,9 +103,9 @@ class CsrfFormLoginTest extends WebTestCase public function getConfigs() { - return array( - array('config.yml'), - array('routes_as_path.yml'), - ); + return [ + ['config.yml'], + ['routes_as_path.yml'], + ]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php index 8179c2e942..8afedc42e4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php @@ -17,12 +17,12 @@ class FirewallEntryPointTest extends WebTestCase { public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials() { - $client = $this->createClient(array('test_case' => 'FirewallEntryPoint')); + $client = $this->createClient(['test_case' => 'FirewallEntryPoint']); - $client->request('GET', '/secure/resource', array(), array(), array( + $client->request('GET', '/secure/resource', [], [], [ 'PHP_AUTH_USER' => 'unknown', 'PHP_AUTH_PW' => 'credentials', - )); + ]); $this->assertEquals( EntryPointStub::RESPONSE_TEXT, @@ -33,7 +33,7 @@ class FirewallEntryPointTest extends WebTestCase public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFormLoginAndNoCredentials() { - $client = $this->createClient(array('test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml')); + $client = $this->createClient(['test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml']); $client->request('GET', '/secure/resource'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php index c2e766e9ac..ec1722188a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php @@ -18,7 +18,7 @@ class FormLoginTest extends WebTestCase */ public function testFormLogin($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; @@ -37,7 +37,7 @@ class FormLoginTest extends WebTestCase */ public function testFormLogout($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; @@ -70,7 +70,7 @@ class FormLoginTest extends WebTestCase */ public function testFormLoginWithCustomTargetPath($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; @@ -90,7 +90,7 @@ class FormLoginTest extends WebTestCase */ public function testFormLoginRedirectsToProtectedResourceAfterLogin($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $client->request('GET', '/protected_resource'); $this->assertRedirect($client->getResponse(), '/login'); @@ -108,9 +108,9 @@ class FormLoginTest extends WebTestCase public function getConfigs() { - return array( - array('config.yml'), - array('routes_as_path.yml'), - ); + return [ + ['config.yml'], + ['routes_as_path.yml'], + ]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php index 7ee4c9b25d..c7e9e2aab7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php @@ -20,56 +20,56 @@ class JsonLoginTest extends WebTestCase { public function testDefaultJsonLoginSuccess() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); - $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "foo"}}'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'config.yml']); + $client->request('POST', '/chk', [], [], ['CONTENT_TYPE' => 'application/json'], '{"user": {"login": "dunglas", "password": "foo"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); - $this->assertSame(array('message' => 'Welcome @dunglas!'), json_decode($response->getContent(), true)); + $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); } public function testDefaultJsonLoginFailure() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); - $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "bad"}}'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'config.yml']); + $client->request('POST', '/chk', [], [], ['CONTENT_TYPE' => 'application/json'], '{"user": {"login": "dunglas", "password": "bad"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(401, $response->getStatusCode()); - $this->assertSame(array('error' => 'Invalid credentials.'), json_decode($response->getContent(), true)); + $this->assertSame(['error' => 'Invalid credentials.'], json_decode($response->getContent(), true)); } public function testCustomJsonLoginSuccess() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml')); - $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "foo"}}'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml']); + $client->request('POST', '/chk', [], [], ['CONTENT_TYPE' => 'application/json'], '{"user": {"login": "dunglas", "password": "foo"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); - $this->assertSame(array('message' => 'Good game @dunglas!'), json_decode($response->getContent(), true)); + $this->assertSame(['message' => 'Good game @dunglas!'], json_decode($response->getContent(), true)); } public function testCustomJsonLoginFailure() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml')); - $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "dunglas", "password": "bad"}}'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'custom_handlers.yml']); + $client->request('POST', '/chk', [], [], ['CONTENT_TYPE' => 'application/json'], '{"user": {"login": "dunglas", "password": "bad"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(500, $response->getStatusCode()); - $this->assertSame(array('message' => 'Something went wrong'), json_decode($response->getContent(), true)); + $this->assertSame(['message' => 'Something went wrong'], json_decode($response->getContent(), true)); } public function testDefaultJsonLoginBadRequest() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'config.yml')); - $client->request('POST', '/chk', array(), array(), array('CONTENT_TYPE' => 'application/json'), 'Not a json content'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'config.yml']); + $client->request('POST', '/chk', [], [], ['CONTENT_TYPE' => 'application/json'], 'Not a json content'); $response = $client->getResponse(); $this->assertSame(400, $response->getStatusCode()); $this->assertSame('application/json', $response->headers->get('Content-Type')); - $this->assertArraySubset(array('error' => array('code' => 400, 'message' => 'Bad Request')), json_decode($response->getContent(), true)); + $this->assertArraySubset(['error' => ['code' => 400, 'message' => 'Bad Request']], json_decode($response->getContent(), true)); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php index cb600764ea..c874ada34a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php @@ -18,7 +18,7 @@ class LocalizedRoutesAsPathTest extends WebTestCase */ public function testLoginLogoutProcedure($locale) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml']); $crawler = $client->request('GET', '/'.$locale.'/login'); $form = $crawler->selectButton('login')->form(); @@ -39,7 +39,7 @@ class LocalizedRoutesAsPathTest extends WebTestCase */ public function testLoginFailureWithLocalizedFailurePath($locale) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_form_failure_handler.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_form_failure_handler.yml']); $crawler = $client->request('GET', '/'.$locale.'/login'); $form = $crawler->selectButton('login')->form(); @@ -55,7 +55,7 @@ class LocalizedRoutesAsPathTest extends WebTestCase */ public function testAccessRestrictedResource($locale) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml']); $client->request('GET', '/'.$locale.'/secure/'); $this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); @@ -66,7 +66,7 @@ class LocalizedRoutesAsPathTest extends WebTestCase */ public function testAccessRestrictedResourceWithForward($locale) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml']); $crawler = $client->request('GET', '/'.$locale.'/secure/'); $this->assertCount(1, $crawler->selectButton('login'), (string) $client->getResponse()); @@ -74,6 +74,6 @@ class LocalizedRoutesAsPathTest extends WebTestCase public function getLocales() { - return array(array('en'), array('de')); + return [['en'], ['de']]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index 5996415e10..0d2d6da0cf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -18,7 +18,7 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $client->request('GET', '/protected_resource'); $this->assertRedirect($client->getResponse(), '/login'); @@ -29,7 +29,7 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $client->request('GET', '/unprotected_resource'); $this->assertEquals(404, $client->getResponse()->getStatusCode(), (string) $client->getResponse()); @@ -40,7 +40,7 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config)); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config]); $form = $client->request('GET', '/login')->selectButton('login')->form(); $form['_username'] = 'johannes'; @@ -57,8 +57,8 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testSecurityConfigurationForSingleIPAddress($config) { - $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.10.10')); - $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '10.10.20.10')); + $allowedClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['REMOTE_ADDR' => '10.10.10.10']); + $barredClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['REMOTE_ADDR' => '10.10.20.10']); $this->assertAllowed($allowedClient, '/secured-by-one-ip'); $this->assertRestricted($barredClient, '/secured-by-one-ip'); @@ -69,9 +69,9 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testSecurityConfigurationForMultipleIPAddresses($config) { - $allowedClientA = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '1.1.1.1')); - $allowedClientB = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '2.2.2.2')); - $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('REMOTE_ADDR' => '192.168.1.1')); + $allowedClientA = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['REMOTE_ADDR' => '1.1.1.1']); + $allowedClientB = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['REMOTE_ADDR' => '2.2.2.2']); + $barredClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['REMOTE_ADDR' => '192.168.1.1']); $this->assertAllowed($allowedClientA, '/secured-by-two-ips'); $this->assertAllowed($allowedClientB, '/secured-by-two-ips'); @@ -83,13 +83,13 @@ class SecurityRoutingIntegrationTest extends WebTestCase */ public function testSecurityConfigurationForExpression($config) { - $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array('HTTP_USER_AGENT' => 'Firefox 1.0')); + $allowedClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], ['HTTP_USER_AGENT' => 'Firefox 1.0']); $this->assertAllowed($allowedClient, '/protected-via-expression'); - $barredClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array()); + $barredClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], []); $this->assertRestricted($barredClient, '/protected-via-expression'); - $allowedClient = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config), array()); + $allowedClient = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => $config], []); $allowedClient->request('GET', '/protected-via-expression'); $form = $allowedClient->followRedirect()->selectButton('login')->form(); @@ -114,6 +114,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase public function getConfigs() { - return array(array('config.yml'), array('routes_as_path.yml')); + return [['config.yml'], ['routes_as_path.yml']]; } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php index bcf8a0d620..ff687d0792 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php @@ -18,13 +18,13 @@ class SecurityTest extends WebTestCase { public function testServiceIsFunctional() { - $kernel = self::createKernel(array('test_case' => 'SecurityHelper', 'root_config' => 'config.yml')); + $kernel = self::createKernel(['test_case' => 'SecurityHelper', 'root_config' => 'config.yml']); $kernel->boot(); $container = $kernel->getContainer(); // put a token into the storage so the final calls can function $user = new User('foo', 'pass'); - $token = new UsernamePasswordToken($user, '', 'provider', array('ROLE_USER')); + $token = new UsernamePasswordToken($user, '', 'provider', ['ROLE_USER']); $container->get('security.token_storage')->setToken($token); $security = $container->get('functional_test.security.helper'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php index 97b0a55919..ddbfd629c8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php @@ -53,29 +53,29 @@ class SwitchUserTest extends WebTestCase public function testSwitchUserStateless() { - $client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'switchuser_stateless.yml')); - $client->request('POST', '/chk', array(), array(), array('HTTP_X_SWITCH_USER' => 'dunglas', 'CONTENT_TYPE' => 'application/json'), '{"user": {"login": "user_can_switch", "password": "test"}}'); + $client = $this->createClient(['test_case' => 'JsonLogin', 'root_config' => 'switchuser_stateless.yml']); + $client->request('POST', '/chk', [], [], ['HTTP_X_SWITCH_USER' => 'dunglas', 'CONTENT_TYPE' => 'application/json'], '{"user": {"login": "user_can_switch", "password": "test"}}'); $response = $client->getResponse(); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertSame(200, $response->getStatusCode()); - $this->assertSame(array('message' => 'Welcome @dunglas!'), json_decode($response->getContent(), true)); + $this->assertSame(['message' => 'Welcome @dunglas!'], json_decode($response->getContent(), true)); $this->assertSame('dunglas', $client->getProfile()->getCollector('security')->getUser()); } public function getTestParameters() { - return array( - 'unauthorized_user_cannot_switch' => array('user_cannot_switch_1', 'user_cannot_switch_1', 'user_cannot_switch_1', 403), - 'authorized_user_can_switch' => array('user_can_switch', 'user_cannot_switch_1', 'user_cannot_switch_1', 200), - 'authorized_user_cannot_switch_to_non_existent' => array('user_can_switch', 'user_does_not_exist', 'user_can_switch', 500), - 'authorized_user_can_switch_to_himself' => array('user_can_switch', 'user_can_switch', 'user_can_switch', 200), - ); + return [ + 'unauthorized_user_cannot_switch' => ['user_cannot_switch_1', 'user_cannot_switch_1', 'user_cannot_switch_1', 403], + 'authorized_user_can_switch' => ['user_can_switch', 'user_cannot_switch_1', 'user_cannot_switch_1', 200], + 'authorized_user_cannot_switch_to_non_existent' => ['user_can_switch', 'user_does_not_exist', 'user_can_switch', 500], + 'authorized_user_can_switch_to_himself' => ['user_can_switch', 'user_can_switch', 'user_can_switch', 200], + ]; } protected function createAuthenticatedClient($username) { - $client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'switchuser.yml')); + $client = $this->createClient(['test_case' => 'StandardFormLogin', 'root_config' => 'switchuser.yml']); $client->followRedirects(true); $form = $client->request('GET', '/login')->selectButton('login')->form(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php index 03e2f3c72c..f1d23b6054 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php @@ -49,7 +49,7 @@ class WebTestCase extends BaseWebTestCase return 'Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel'; } - protected static function createKernel(array $options = array()) + protected static function createKernel(array $options = []) { $class = self::getKernelClass(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index 1aab514f45..0dfbd2ec59 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -86,7 +86,7 @@ class AppKernel extends Kernel public function serialize() { - return serialize(array($this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug())); + return serialize([$this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug()]); } public function unserialize($str) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/bundles.php index 68e5afb125..535a4bf517 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AutowiringTypes/bundles.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -return array( +return [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiringBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/bundles.php index c16ab12f65..65a38200e7 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/bundles.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -return array( +return [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\CsrfFormLoginBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php index 412e1c5d09..7928a468da 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/bundles.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -return array( +return [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\FirewallEntryPointBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/bundles.php index 470ffff088..7dbd6e4380 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/bundles.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -return array( +return [ new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\JsonLoginBundle\JsonLoginBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutAccess/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutAccess/bundles.php index c934b52aee..9a26fb163a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutAccess/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutAccess/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; -return array( +return [ new FrameworkBundle(), new SecurityBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutWithoutSessionInvalidation/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutWithoutSessionInvalidation/bundles.php index c934b52aee..9a26fb163a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutWithoutSessionInvalidation/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/LogoutWithoutSessionInvalidation/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; -return array( +return [ new FrameworkBundle(), new SecurityBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bundles.php index 2e9243712c..bcfd17425c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bundles.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -return array( +return [ new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMeLogout/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMeLogout/bundles.php index c934b52aee..9a26fb163a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMeLogout/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/RememberMeLogout/bundles.php @@ -12,7 +12,7 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; -return array( +return [ new FrameworkBundle(), new SecurityBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/bundles.php index 05df5ef680..181618ba99 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/SecurityHelper/bundles.php @@ -13,8 +13,8 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\TwigBundle\TwigBundle; -return array( +return [ new FrameworkBundle(), new SecurityBundle(), new TwigBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/bundles.php index 3424c1eed1..95041e7ad4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/bundles.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/bundles.php @@ -14,9 +14,9 @@ use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\FormLoginBundle; use Symfony\Bundle\TwigBundle\TwigBundle; -return array( +return [ new FrameworkBundle(), new SecurityBundle(), new TwigBundle(), new FormLoginBundle(), -); +]; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php index 4abf33e276..99e897aa8f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallConfigTest.php @@ -18,8 +18,8 @@ class FirewallConfigTest extends TestCase { public function testGetters() { - $listeners = array('logout', 'remember_me', 'anonymous'); - $options = array( + $listeners = ['logout', 'remember_me', 'anonymous']; + $options = [ 'request_matcher' => 'foo_request_matcher', 'security' => false, 'stateless' => false, @@ -29,8 +29,8 @@ class FirewallConfigTest extends TestCase 'access_denied_url' => 'foo_access_denied_url', 'access_denied_handler' => 'foo_access_denied_handler', 'user_checker' => 'foo_user_checker', - 'switch_user' => array('provider' => null, 'parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH'), - ); + 'switch_user' => ['provider' => null, 'parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH'], + ]; $config = new FirewallConfig( 'foo_firewall', diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php index 42162369cb..bfcac0f81b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php @@ -30,13 +30,13 @@ class FirewallMapTest extends TestCase { $request = new Request(); - $map = array(); + $map = []; $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->never())->method('get'); $firewallMap = new FirewallMap($container, $map); - $this->assertEquals(array(array(), null, null), $firewallMap->getListeners($request)); + $this->assertEquals([[], null, null], $firewallMap->getListeners($request)); $this->assertNull($firewallMap->getFirewallConfig($request)); $this->assertFalse($request->attributes->has(self::ATTRIBUTE_FIREWALL_CONTEXT)); } @@ -46,13 +46,13 @@ class FirewallMapTest extends TestCase $request = new Request(); $request->attributes->set(self::ATTRIBUTE_FIREWALL_CONTEXT, 'foo'); - $map = array(); + $map = []; $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->never())->method('get'); $firewallMap = new FirewallMap($container, $map); - $this->assertEquals(array(array(), null, null), $firewallMap->getListeners($request)); + $this->assertEquals([[], null, null], $firewallMap->getListeners($request)); $this->assertNull($firewallMap->getFirewallConfig($request)); $this->assertFalse($request->attributes->has(self::ATTRIBUTE_FIREWALL_CONTEXT)); } @@ -67,7 +67,7 @@ class FirewallMapTest extends TestCase $firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig); $listener = $this->getMockBuilder(ListenerInterface::class)->getMock(); - $firewallContext->expects($this->once())->method('getListeners')->willReturn(array($listener)); + $firewallContext->expects($this->once())->method('getListeners')->willReturn([$listener]); $exceptionListener = $this->getMockBuilder(ExceptionListener::class)->disableOriginalConstructor()->getMock(); $firewallContext->expects($this->once())->method('getExceptionListener')->willReturn($exceptionListener); @@ -84,9 +84,9 @@ class FirewallMapTest extends TestCase $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->exactly(2))->method('get')->willReturn($firewallContext); - $firewallMap = new FirewallMap($container, array('security.firewall.map.context.foo' => $matcher)); + $firewallMap = new FirewallMap($container, ['security.firewall.map.context.foo' => $matcher]); - $this->assertEquals(array(array($listener), $exceptionListener, $logoutListener), $firewallMap->getListeners($request)); + $this->assertEquals([[$listener], $exceptionListener, $logoutListener], $firewallMap->getListeners($request)); $this->assertEquals($firewallConfig, $firewallMap->getFirewallConfig($request)); $this->assertEquals('security.firewall.map.context.foo', $request->attributes->get(self::ATTRIBUTE_FIREWALL_CONTEXT)); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php index d26708ae08..d015165739 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/SecurityUserValueResolverTest.php @@ -69,7 +69,7 @@ class SecurityUserValueResolverTest extends TestCase $metadata = new ArgumentMetadata('foo', UserInterface::class, false, false, null); $this->assertTrue($resolver->supports(Request::create('/'), $metadata)); - $this->assertSame(array($user), iterator_to_array($resolver->resolve(Request::create('/'), $metadata))); + $this->assertSame([$user], iterator_to_array($resolver->resolve(Request::create('/'), $metadata))); } public function testIntegration() @@ -80,8 +80,8 @@ class SecurityUserValueResolverTest extends TestCase $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); - $argumentResolver = new ArgumentResolver(null, array(new SecurityUserValueResolver($tokenStorage))); - $this->assertSame(array($user), $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user) {})); + $argumentResolver = new ArgumentResolver(null, [new SecurityUserValueResolver($tokenStorage)]); + $this->assertSame([$user], $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user) {})); } public function testIntegrationNoUser() @@ -90,8 +90,8 @@ class SecurityUserValueResolverTest extends TestCase $tokenStorage = new TokenStorage(); $tokenStorage->setToken($token); - $argumentResolver = new ArgumentResolver(null, array(new SecurityUserValueResolver($tokenStorage), new DefaultValueResolver())); - $this->assertSame(array(null), $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user = null) {})); + $argumentResolver = new ArgumentResolver(null, [new SecurityUserValueResolver($tokenStorage), new DefaultValueResolver()]); + $this->assertSame([null], $argumentResolver->getArguments(Request::create('/'), function (UserInterface $user = null) {})); } } diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php index 00964322e9..03233c5985 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php @@ -37,7 +37,7 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscribe /** * @param array $paths Additional twig paths to warm */ - public function __construct(ContainerInterface $container, TemplateFinderInterface $finder = null, array $paths = array()) + public function __construct(ContainerInterface $container, TemplateFinderInterface $finder = null, array $paths = []) { // We don't inject the Twig environment directly as it depends on the // template locator (via the loader) which might be a cached one. @@ -96,9 +96,9 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscribe */ public static function getSubscribedServices() { - return array( + return [ 'twig' => Environment::class, - ); + ]; } /** @@ -112,10 +112,10 @@ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscribe private function findTemplatesInFolder($namespace, $dir) { if (!is_dir($dir)) { - return array(); + return []; } - $templates = array(); + $templates = []; $finder = new Finder(); foreach ($finder->files()->followLinks()->in($dir) as $file) { diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php index cdd3a5d740..cb9af8a462 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php @@ -67,8 +67,8 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte */ public static function getSubscribedServices() { - return array( + return [ 'twig' => Environment::class, - ); + ]; } } diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index 8cd7fa18bc..5269a49de8 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -61,14 +61,14 @@ class ExceptionController return new Response($this->twig->render( (string) $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), - array( + [ 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, - ) - ), 200, array('Content-Type' => $request->getMimeType($request->getRequestFormat()) ?: 'text/html')); + ] + ), 200, ['Content-Type' => $request->getMimeType($request->getRequestFormat()) ?: 'text/html']); } /** diff --git a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php b/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php index a8b25adcf0..c529cfbb46 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/PreviewErrorController.php @@ -43,13 +43,13 @@ class PreviewErrorController * the additional "showException" flag. */ - $subRequest = $request->duplicate(null, null, array( + $subRequest = $request->duplicate(null, null, [ '_controller' => $this->controller, 'exception' => $exception, 'logger' => null, 'format' => $request->getRequestFormat(), 'showException' => false, - )); + ]); return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 5089fc0651..79a6ad9ae8 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -45,7 +45,7 @@ class ExtensionPass implements CompilerPassInterface $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form'; - $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath)); + $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', [$coreThemePath]); $paths = $container->getDefinition('twig.template_iterator')->getArgument(2); $paths[$coreThemePath] = null; @@ -67,9 +67,9 @@ class ExtensionPass implements CompilerPassInterface $container->getDefinition('twig.runtime.httpkernel')->addTag('twig.runtime'); // inject Twig in the hinclude service if Twig is the only registered templating engine - if ((!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) { + if ((!$container->hasParameter('templating.engines') || ['twig'] == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) { $container->getDefinition('fragment.renderer.hinclude') - ->addTag('kernel.fragment_renderer', array('alias' => 'hinclude')) + ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude']) ->replaceArgument(0, new Reference('twig')) ; } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php index bd6393bc9c..82cf1c145a 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php @@ -28,7 +28,7 @@ class RuntimeLoaderPass implements CompilerPassInterface } $definition = $container->getDefinition('twig.runtime_loader'); - $mapping = array(); + $mapping = []; foreach ($container->findTaggedServiceIds('twig.runtime', true) as $id => $attributes) { $def = $container->getDefinition($id); $mapping[$def->getClass()] = new Reference($id); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php index 3fc2696904..51b6d9b4f0 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php @@ -29,7 +29,7 @@ class TwigLoaderPass implements CompilerPassInterface return; } - $prioritizedLoaders = array(); + $prioritizedLoaders = []; $found = 0; foreach ($container->findTaggedServiceIds('twig.loader', true) as $id => $attributes) { @@ -50,7 +50,7 @@ class TwigLoaderPass implements CompilerPassInterface foreach ($prioritizedLoaders as $loaders) { foreach ($loaders as $loader) { - $chainLoader->addMethodCall('addLoader', array(new Reference($loader))); + $chainLoader->addMethodCall('addLoader', [new Reference($loader)]); } } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 748f3b7d29..8730a34e32 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -54,11 +54,11 @@ class Configuration implements ConfigurationInterface ->arrayNode('form_themes') ->addDefaultChildrenIfNoneSet() ->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end() - ->example(array('MyBundle::form.html.twig')) + ->example(['MyBundle::form.html.twig']) ->validate() ->ifTrue(function ($v) { return !\in_array('form_div_layout.html.twig', $v); }) ->then(function ($v) { - return array_merge(array('form_div_layout.html.twig'), $v); + return array_merge(['form_div_layout.html.twig'], $v); }) ->end() ->end() @@ -74,7 +74,7 @@ class Configuration implements ConfigurationInterface ->arrayNode('globals') ->normalizeKeys(false) ->useAttributeAsKey('key') - ->example(array('foo' => '"@bar"', 'pi' => 3.14)) + ->example(['foo' => '"@bar"', 'pi' => 3.14]) ->prototype('array') ->normalizeKeys(false) ->beforeNormalization() @@ -84,7 +84,7 @@ class Configuration implements ConfigurationInterface return substr($v, 1); } - return array('id' => substr($v, 1), 'type' => 'service'); + return ['id' => substr($v, 1), 'type' => 'service']; }) ->end() ->beforeNormalization() @@ -93,18 +93,18 @@ class Configuration implements ConfigurationInterface $keys = array_keys($v); sort($keys); - return $keys !== array('id', 'type') && $keys !== array('value'); + return $keys !== ['id', 'type'] && $keys !== ['value']; } return true; }) - ->then(function ($v) { return array('value' => $v); }) + ->then(function ($v) { return ['value' => $v]; }) ->end() ->children() ->scalarNode('id')->end() ->scalarNode('type') ->validate() - ->ifNotInArray(array('service')) + ->ifNotInArray(['service']) ->thenInvalid('The %s type is not supported') ->end() ->end() @@ -147,7 +147,7 @@ class Configuration implements ConfigurationInterface ->beforeNormalization() ->always() ->then(function ($paths) { - $normalized = array(); + $normalized = []; foreach ($paths as $path => $namespace) { if (\is_array($namespace)) { // xml diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index ff092c3d19..0f8b8b2720 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -33,7 +33,7 @@ class FilesystemLoader extends BaseFilesystemLoader */ public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, string $rootPath = null) { - parent::__construct(array(), $rootPath); + parent::__construct([], $rootPath); $this->locator = $locator; $this->parser = $parser; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php index c58cf686f0..800da68c9b 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php @@ -22,7 +22,7 @@ class ExceptionControllerTest extends TestCase { public function testShowActionCanBeForcedToShowErrorPage() { - $twig = $this->createTwigEnv(array('@Twig/Exception/error404.html.twig' => 'not found')); + $twig = $this->createTwigEnv(['@Twig/Exception/error404.html.twig' => 'not found']); $request = $this->createRequest('html'); $request->attributes->set('showException', false); @@ -37,7 +37,7 @@ class ExceptionControllerTest extends TestCase public function testFallbackToHtmlIfNoTemplateForRequestedFormat() { - $twig = $this->createTwigEnv(array('@Twig/Exception/error.html.twig' => '')); + $twig = $this->createTwigEnv(['@Twig/Exception/error.html.twig' => '']); $request = $this->createRequest('txt'); $exception = FlattenException::create(new \Exception()); @@ -50,7 +50,7 @@ class ExceptionControllerTest extends TestCase public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown() { - $twig = $this->createTwigEnv(array('@Twig/Exception/exception_full.html.twig' => '')); + $twig = $this->createTwigEnv(['@Twig/Exception/exception_full.html.twig' => '']); $request = $this->createRequest('txt'); $request->attributes->set('showException', true); @@ -64,7 +64,7 @@ class ExceptionControllerTest extends TestCase public function testResponseHasRequestedMimeType() { - $twig = $this->createTwigEnv(array('@Twig/Exception/error.json.twig' => '{}')); + $twig = $this->createTwigEnv(['@Twig/Exception/error.json.twig' => '{}']); $request = $this->createRequest('json'); $exception = FlattenException::create(new \Exception()); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php index 00c2217f07..539a952a60 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php @@ -30,12 +30,12 @@ class ExtensionPassTest extends TestCase $container->register('twig.extension.expression'); $nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader'); - $nativeTwigLoader->addMethodCall('addPath', array()); + $nativeTwigLoader->addMethodCall('addPath', []); $container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader); $filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader'); - $filesystemLoader->setArguments(array(null, null, null)); - $filesystemLoader->addMethodCall('addPath', array()); + $filesystemLoader->setArguments([null, null, null]); + $filesystemLoader->addMethodCall('addPath', []); $container->setDefinition('twig.loader.filesystem', $filesystemLoader); $extensionPass = new ExtensionPass(); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php index 621967a596..3b65273d6d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php @@ -72,9 +72,9 @@ class TwigLoaderPassTest extends TestCase { $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); $this->builder->register('test_loader_1') - ->addTag('twig.loader', array('priority' => 100)); + ->addTag('twig.loader', ['priority' => 100]); $this->builder->register('test_loader_2') - ->addTag('twig.loader', array('priority' => 200)); + ->addTag('twig.loader', ['priority' => 200]); $this->pass->process($this->builder); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 47b9e5d835..8dd2be4096 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -1,15 +1,15 @@ loadFromExtension('twig', array( - 'form_themes' => array( +$container->loadFromExtension('twig', [ + 'form_themes' => [ 'MyBundle::form.html.twig', - ), - 'globals' => array( + ], + 'globals' => [ 'foo' => '@bar', 'baz' => '@@qux', 'pi' => 3.14, - 'bad' => array('key' => 'foo'), - ), + 'bad' => ['key' => 'foo'], + ], 'auto_reload' => true, 'autoescape' => true, 'base_template_class' => 'stdClass', @@ -18,10 +18,10 @@ $container->loadFromExtension('twig', array( 'debug' => true, 'strict_variables' => true, 'default_path' => '%kernel.project_dir%/Fixtures/templates', - 'paths' => array( + 'paths' => [ 'path1', 'path2', 'namespaced_path1' => 'namespace1', 'namespaced_path2' => 'namespace2', - ), -)); + ], +]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php index 5d66e20f87..8dde94f2c6 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php @@ -32,7 +32,7 @@ class EmptyAppKernel extends Kernel { public function registerBundles() { - return array(new TwigBundle()); + return [new TwigBundle()]; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 04eb5e1878..33a873dba8 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -22,22 +22,22 @@ class TemplateIteratorTest extends TestCase $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); - $kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array( + $kernel->expects($this->any())->method('getBundles')->will($this->returnValue([ $bundle, - ))); - $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'), __DIR__.'/DependencyInjection/Fixtures/templates'); + ])); + $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); $sorted = iterator_to_array($iterator); sort($sorted); $this->assertEquals( - array( + [ '@Bar/base.html.twig', '@Bar/index.html.twig', '@Bar/layout.html.twig', '@Foo/index.html.twig', 'layout.html.twig', 'sub/sub.html.twig', - ), + ], $sorted ); } diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 1ac56a6f59..39115199e5 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -39,7 +39,7 @@ class TwigEngine extends BaseEngine implements EngineInterface /** * {@inheritdoc} */ - public function render($name, array $parameters = array()) + public function render($name, array $parameters = []) { try { return parent::render($name, $parameters); @@ -63,7 +63,7 @@ class TwigEngine extends BaseEngine implements EngineInterface * * @throws Error if something went wrong like a thrown exception while rendering the template */ - public function renderResponse($view, array $parameters = array(), Response $response = null) + public function renderResponse($view, array $parameters = [], Response $response = null) { if (null === $response) { $response = new Response(); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php index 47caadd01f..bc40f4f8dd 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php @@ -63,21 +63,21 @@ class ExceptionController if (!$this->twig->getLoader()->exists($template)) { $handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat); - return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html')); + return new Response($handler->getContent($exception), 200, ['Content-Type' => 'text/html']); } $code = $exception->getStatusCode(); return new Response($this->twig->render( $template, - array( + [ 'status_code' => $code, 'status_text' => Response::$statusTexts[$code], 'exception' => $exception, 'logger' => null, 'currentContent' => '', - ) - ), 200, array('Content-Type' => 'text/html')); + ] + ), 200, ['Content-Type' => 'text/html']); } /** @@ -103,10 +103,10 @@ class ExceptionController if (!$this->templateExists($template)) { $handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat); - return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); + return new Response($handler->getStylesheet($exception), 200, ['Content-Type' => 'text/css']); } - return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css')); + return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, ['Content-Type' => 'text/css']); } protected function getTemplate() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 82264f0a45..35cf31fbf9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -60,7 +60,7 @@ class ProfilerController $this->profiler->disable(); - return new RedirectResponse($this->generator->generate('_profiler_search_results', array('token' => 'empty', 'limit' => 10)), 302, array('Content-Type' => 'text/html')); + return new RedirectResponse($this->generator->generate('_profiler_search_results', ['token' => 'empty', 'limit' => 10]), 302, ['Content-Type' => 'text/html']); } /** @@ -93,14 +93,14 @@ class ProfilerController } if (!$profile = $this->profiler->loadProfile($token)) { - return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array('about' => 'no_token', 'token' => $token, 'request' => $request)), 200, array('Content-Type' => 'text/html')); + return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', ['about' => 'no_token', 'token' => $token, 'request' => $request]), 200, ['Content-Type' => 'text/html']); } if (!$profile->hasCollector($panel)) { throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token)); } - return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array( + return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), [ 'token' => $token, 'profile' => $profile, 'collector' => $profile->getCollector($panel), @@ -110,7 +110,7 @@ class ProfilerController 'templates' => $this->getTemplateManager()->getNames($profile), 'is_ajax' => $request->isXmlHttpRequest(), 'profiler_markup_version' => 2, // 1 = original profiler, 2 = Symfony 2.8+ profiler - )), 200, array('Content-Type' => 'text/html')); + ]), 200, ['Content-Type' => 'text/html']); } /** @@ -135,30 +135,30 @@ class ProfilerController } if ('empty' === $token || null === $token) { - return new Response('', 200, array('Content-Type' => 'text/html')); + return new Response('', 200, ['Content-Type' => 'text/html']); } $this->profiler->disable(); if (!$profile = $this->profiler->loadProfile($token)) { - return new Response('', 404, array('Content-Type' => 'text/html')); + return new Response('', 404, ['Content-Type' => 'text/html']); } $url = null; try { - $url = $this->generator->generate('_profiler', array('token' => $token)); + $url = $this->generator->generate('_profiler', ['token' => $token]); } catch (\Exception $e) { // the profiler is not enabled } - return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', array( + return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', [ 'request' => $request, 'profile' => $profile, 'templates' => $this->getTemplateManager()->getNames($profile), 'profiler_url' => $url, 'token' => $token, 'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar - )); + ]); } /** @@ -203,7 +203,7 @@ class ProfilerController } return new Response( - $this->twig->render('@WebProfiler/Profiler/search.html.twig', array( + $this->twig->render('@WebProfiler/Profiler/search.html.twig', [ 'token' => $token, 'ip' => $ip, 'method' => $method, @@ -213,9 +213,9 @@ class ProfilerController 'end' => $end, 'limit' => $limit, 'request' => $request, - )), + ]), 200, - array('Content-Type' => 'text/html') + ['Content-Type' => 'text/html'] ); } @@ -251,7 +251,7 @@ class ProfilerController $end = $request->query->get('end', null); $limit = $request->query->get('limit'); - return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array( + return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', [ 'request' => $request, 'token' => $token, 'profile' => $profile, @@ -264,7 +264,7 @@ class ProfilerController 'end' => $end, 'limit' => $limit, 'panel' => null, - )), 200, array('Content-Type' => 'text/html')); + ]), 200, ['Content-Type' => 'text/html']); } /** @@ -305,12 +305,12 @@ class ProfilerController } if (!empty($token)) { - return new RedirectResponse($this->generator->generate('_profiler', array('token' => $token)), 302, array('Content-Type' => 'text/html')); + return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']); } $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode); - return new RedirectResponse($this->generator->generate('_profiler_search_results', array( + return new RedirectResponse($this->generator->generate('_profiler_search_results', [ 'token' => $tokens ? $tokens[0]['token'] : 'empty', 'ip' => $ip, 'method' => $method, @@ -319,7 +319,7 @@ class ProfilerController 'start' => $start, 'end' => $end, 'limit' => $limit, - )), 302, array('Content-Type' => 'text/html')); + ]), 302, ['Content-Type' => 'text/html']); } /** @@ -345,7 +345,7 @@ class ProfilerController phpinfo(); $phpinfo = ob_get_clean(); - return new Response($phpinfo, 200, array('Content-Type' => 'text/html')); + return new Response($phpinfo, 200, ['Content-Type' => 'text/html']); } /** @@ -374,11 +374,11 @@ class ProfilerController throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file)); } - return new Response($this->twig->render('@WebProfiler/Profiler/open.html.twig', array( + return new Response($this->twig->render('@WebProfiler/Profiler/open.html.twig', [ 'filename' => $filename, 'file' => $file, 'line' => $line, - )), 200, array('Content-Type' => 'text/html')); + ]), 200, ['Content-Type' => 'text/html']); } /** @@ -395,11 +395,11 @@ class ProfilerController return $this->templateManager; } - private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = array('Content-Type' => 'text/html')) + private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = ['Content-Type' => 'text/html']) { $response = new Response('', $code, $headers); - $nonces = $this->cspHandler ? $this->cspHandler->getNonces($request, $response) : array(); + $nonces = $this->cspHandler ? $this->cspHandler->getNonces($request, $response) : []; $variables['csp_script_nonce'] = isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null; $variables['csp_style_nonce'] = isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index 14e33a1107..f3f68fe5d8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -60,7 +60,7 @@ class RouterController $this->profiler->disable(); if (null === $this->matcher || null === $this->routes) { - return new Response('The Router is not enabled.', 200, array('Content-Type' => 'text/html')); + return new Response('The Router is not enabled.', 200, ['Content-Type' => 'text/html']); } $profile = $this->profiler->loadProfile($token); @@ -68,11 +68,11 @@ class RouterController /** @var RequestDataCollector $request */ $request = $profile->getCollector('request'); - return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', array( + return new Response($this->twig->render('@WebProfiler/Router/panel.html.twig', [ 'request' => $request, 'router' => $profile->getCollector('router'), 'traces' => $this->getTraces($request, $profile->getMethod()), - )), 200, array('Content-Type' => 'text/html')); + ]), 200, ['Content-Type' => 'text/html']); } /** @@ -83,9 +83,9 @@ class RouterController $traceRequest = Request::create( $request->getPathInfo(), $request->getRequestServer(true)->get('REQUEST_METHOD'), - array(), + [], $request->getRequestCookies(true)->all(), - array(), + [], $request->getRequestServer(true)->all() ); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php index df4458474b..a38e7c686f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php @@ -44,23 +44,23 @@ class ContentSecurityPolicyHandler public function getNonces(Request $request, Response $response) { if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) { - return array( + return [ 'csp_script_nonce' => $request->headers->get('X-SymfonyProfiler-Script-Nonce'), 'csp_style_nonce' => $request->headers->get('X-SymfonyProfiler-Style-Nonce'), - ); + ]; } if ($response->headers->has('X-SymfonyProfiler-Script-Nonce') && $response->headers->has('X-SymfonyProfiler-Style-Nonce')) { - return array( + return [ 'csp_script_nonce' => $response->headers->get('X-SymfonyProfiler-Script-Nonce'), 'csp_style_nonce' => $response->headers->get('X-SymfonyProfiler-Style-Nonce'), - ); + ]; } - $nonces = array( + $nonces = [ 'csp_script_nonce' => $this->generateNonce(), 'csp_style_nonce' => $this->generateNonce(), - ); + ]; $response->headers->set('X-SymfonyProfiler-Script-Nonce', $nonces['csp_script_nonce']); $response->headers->set('X-SymfonyProfiler-Style-Nonce', $nonces['csp_style_nonce']); @@ -88,7 +88,7 @@ class ContentSecurityPolicyHandler if ($this->cspDisabled) { $this->removeCspHeaders($response); - return array(); + return []; } $nonces = $this->getNonces($request, $response); @@ -116,19 +116,19 @@ class ContentSecurityPolicyHandler * * @return array */ - private function updateCspHeaders(Response $response, array $nonces = array()) + private function updateCspHeaders(Response $response, array $nonces = []) { - $nonces = array_replace(array( + $nonces = array_replace([ 'csp_script_nonce' => $this->generateNonce(), 'csp_style_nonce' => $this->generateNonce(), - ), $nonces); + ], $nonces); $ruleIsSet = false; $headers = $this->getCspHeaders($response); foreach ($headers as $header => $directives) { - foreach (array('script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce') as $type => $tokenName) { + foreach (['script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce'] as $type => $tokenName) { if ($this->authorizesInline($directives, $type)) { continue; } @@ -192,7 +192,7 @@ class ContentSecurityPolicyHandler */ private function parseDirectives($header) { - $directives = array(); + $directives = []; foreach (explode(';', $header) as $directive) { $parts = explode(' ', trim($directive)); @@ -236,7 +236,7 @@ class ContentSecurityPolicyHandler if ('\'nonce-' === substr($directive, 0, 7)) { return true; } - if (\in_array(substr($directive, 0, 8), array('\'sha256-', '\'sha384-', '\'sha512-'), true)) { + if (\in_array(substr($directive, 0, 8), ['\'sha256-', '\'sha384-', '\'sha512-'], true)) { return true; } } @@ -252,7 +252,7 @@ class ContentSecurityPolicyHandler */ private function getCspHeaders(Response $response) { - $headers = array(); + $headers = []; if ($response->headers->has('Content-Security-Policy')) { $headers['Content-Security-Policy'] = $this->parseDirectives($response->headers->get('Content-Security-Policy')); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php index 0c6ca6591d..fed7a6463b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php @@ -69,7 +69,7 @@ class TemplateManager */ public function getNames(Profile $profile) { - $templates = array(); + $templates = []; foreach ($this->templates as $arguments) { if (null === $arguments) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index 5139778369..bbf96c3b2b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -55,21 +55,21 @@ class ContentSecurityPolicyHandlerTest extends TestCase $responseScriptNonce = 'response-with-headers-script-nonce'; $responseStyleNonce = 'response-with-headers-style-nonce'; - $requestNonceHeaders = array( + $requestNonceHeaders = [ 'X-SymfonyProfiler-Script-Nonce' => $requestScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $requestStyleNonce, - ); - $responseNonceHeaders = array( + ]; + $responseNonceHeaders = [ 'X-SymfonyProfiler-Script-Nonce' => $responseScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $responseStyleNonce, - ); + ]; - return array( - array($nonce, array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), $this->createRequest(), $this->createResponse()), - array($nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse($responseNonceHeaders)), - array($nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), $this->createRequest($requestNonceHeaders), $this->createResponse()), - array($nonce, array('csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce), $this->createRequest(), $this->createResponse($responseNonceHeaders)), - ); + return [ + [$nonce, ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), $this->createResponse()], + [$nonce, ['csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce], $this->createRequest($requestNonceHeaders), $this->createResponse($responseNonceHeaders)], + [$nonce, ['csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce], $this->createRequest($requestNonceHeaders), $this->createResponse()], + [$nonce, ['csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce], $this->createRequest(), $this->createResponse($responseNonceHeaders)], + ]; } public function provideRequestAndResponsesForOnKernelResponse() @@ -82,103 +82,103 @@ class ContentSecurityPolicyHandlerTest extends TestCase $responseScriptNonce = 'response-with-headers-script-nonce'; $responseStyleNonce = 'response-with-headers-style-nonce'; - $requestNonceHeaders = array( + $requestNonceHeaders = [ 'X-SymfonyProfiler-Script-Nonce' => $requestScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $requestStyleNonce, - ); - $responseNonceHeaders = array( + ]; + $responseNonceHeaders = [ 'X-SymfonyProfiler-Script-Nonce' => $responseScriptNonce, 'X-SymfonyProfiler-Style-Nonce' => $responseStyleNonce, - ); + ]; - return array( - array( + return [ + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), $this->createResponse(), - array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), - ), - array( - $nonce, array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), + ['Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null], + ], + [ + $nonce, ['csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce], $this->createRequest($requestNonceHeaders), $this->createResponse($responseNonceHeaders), - array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), - ), - array( + ['Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce), + ['csp_script_nonce' => $requestScriptNonce, 'csp_style_nonce' => $requestStyleNonce], $this->createRequest($requestNonceHeaders), $this->createResponse(), - array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), - ), - array( + ['Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce), + ['csp_script_nonce' => $responseScriptNonce, 'csp_style_nonce' => $responseStyleNonce], $this->createRequest(), $this->createResponse($responseNonceHeaders), - array('Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null), - ), - array( + ['Content-Security-Policy' => null, 'Content-Security-Policy-Report-Only' => null, 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:')), - array('Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:', 'X-Content-Security-Policy' => null), - ), - array( + $this->createResponse(['Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:']), + ['Content-Security-Policy' => 'frame-ancestors https: ; form-action: https:', 'Content-Security-Policy-Report-Only' => 'frame-ancestors http: ; form-action: http:', 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'')), - array('Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain-report-only.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null), - ), - array( + $this->createResponse(['Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'']), + ['Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'; style-src \'self\' domain-report-only.com \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'')), - array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'X-Content-Security-Policy' => null), - ), - array( + $this->createResponse(['Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'']), + ['Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'')), - array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null), - ), - array( + $this->createResponse(['Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'']), + ['Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'')), - array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy' => null), - ), - array( + $this->createResponse(['X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'']), + ['X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'', 'Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\'')), - array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null), - ), - array( + $this->createResponse(['X-Content-Security-Policy' => 'script-src \'self\'']), + ['X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\'')), - array('X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null), - ), - array( + $this->createResponse(['X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\'']), + ['X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'sha384-LALALALALAAL\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy' => null], + ], + [ $nonce, - array('csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce), + ['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce], $this->createRequest(), - $this->createResponse(array('Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\'')), - array('Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\''), - ), - ); + $this->createResponse(['Content-Security-Policy' => 'script-src \'self\'; style-src \'self\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\'']), + ['Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => 'script-src \'self\' \'unsafe-inline\'; style-src \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\''], + ], + ]; } - private function createRequest(array $headers = array()) + private function createRequest(array $headers = []) { $request = new Request(); $request->headers->add($headers); @@ -186,7 +186,7 @@ class ContentSecurityPolicyHandlerTest extends TestCase return $request; } - private function createResponse(array $headers = array()) + private function createResponse(array $headers = []) { $response = new Response(); $response->headers->add($headers); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 0fb7f85eb5..b5633bb409 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -28,9 +28,9 @@ class WebProfilerExtensionTest extends TestCase */ private $container; - public static function assertSaneContainer(Container $container, $message = '', $knownPrivates = array()) + public static function assertSaneContainer(Container $container, $message = '', $knownPrivates = []) { - $errors = array(); + $errors = []; $knownPrivates[] = 'debug.file_link_formatter.url_format'; foreach ($container->getServiceIds() as $id) { if (\in_array($id, $knownPrivates, true)) { // for BC with 3.4 @@ -43,7 +43,7 @@ class WebProfilerExtensionTest extends TestCase } } - self::assertEquals(array(), $errors, $message); + self::assertEquals([], $errors, $message); } protected function setUp() @@ -56,19 +56,19 @@ class WebProfilerExtensionTest extends TestCase $this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true); $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface'))->setPublic(true); $this->container->register('twig', 'Twig\Environment')->setPublic(true); - $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument(array())->setPublic(true); + $this->container->register('twig_loader', 'Twig\Loader\ArrayLoader')->addArgument([])->setPublic(true); $this->container->register('twig', 'Twig\Environment')->addArgument(new Reference('twig_loader'))->setPublic(true); - $this->container->setParameter('kernel.bundles', array()); + $this->container->setParameter('kernel.bundles', []); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); $this->container->setParameter('kernel.project_dir', __DIR__); $this->container->setParameter('kernel.charset', 'UTF-8'); $this->container->setParameter('debug.file_link_format', null); - $this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')); + $this->container->setParameter('profiler.class', ['Symfony\\Component\\HttpKernel\\Profiler\\Profiler']); $this->container->register('profiler', $this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')) ->setPublic(true) ->addArgument(new Definition($this->getMockClass('Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface'))); - $this->container->setParameter('data_collector.templates', array()); + $this->container->setParameter('data_collector.templates', []); $this->container->set('kernel', $this->kernel); $this->container->addCompilerPass(new RegisterListenersPass()); } @@ -89,7 +89,7 @@ class WebProfilerExtensionTest extends TestCase $this->container->setParameter('kernel.debug', $debug); $extension = new WebProfilerExtension(); - $extension->load(array(array()), $this->container); + $extension->load([[]], $this->container); $this->assertFalse($this->container->has('web_profiler.debug_toolbar')); @@ -102,11 +102,11 @@ class WebProfilerExtensionTest extends TestCase public function testToolbarConfig($toolbarEnabled, $interceptRedirects, $listenerInjected, $listenerEnabled) { $extension = new WebProfilerExtension(); - $extension->load(array(array('toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects)), $this->container); + $extension->load([['toolbar' => $toolbarEnabled, 'intercept_redirects' => $interceptRedirects]], $this->container); $this->assertSame($listenerInjected, $this->container->has('web_profiler.debug_toolbar')); - $this->assertSaneContainer($this->getCompiledContainer(), '', array('web_profiler.csp.handler')); + $this->assertSaneContainer($this->getCompiledContainer(), '', ['web_profiler.csp.handler']); if ($listenerInjected) { $this->assertSame($listenerEnabled, $this->container->get('web_profiler.debug_toolbar')->isEnabled()); @@ -115,12 +115,12 @@ class WebProfilerExtensionTest extends TestCase public function getDebugModes() { - return array( - array(false, false, false, false), - array(true, false, true, true), - array(false, true, true, false), - array(true, true, true, true), - ); + return [ + [false, false, false, false], + [true, false, true, true], + [false, true, true, false], + [true, true, true, true], + ]; } private function getCompiledContainer() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index c0f061af9d..1d6bd12dae 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -33,15 +33,15 @@ class WebDebugToolbarListenerTest extends TestCase $response = new Response($content); - $m->invoke($listener, $response, Request::create('/'), array('csp_script_nonce' => 'scripto', 'csp_style_nonce' => 'stylo')); + $m->invoke($listener, $response, Request::create('/'), ['csp_script_nonce' => 'scripto', 'csp_style_nonce' => 'stylo']); $this->assertEquals($expected, $response->getContent()); } public function getInjectToolbarTests() { - return array( - array('', "\nWDT\n"), - array(' + return [ + ['', "\nWDT\n"], + [' @@ -51,8 +51,8 @@ class WebDebugToolbarListenerTest extends TestCase \nWDT\n - "), - ); + "], + ]; } /** @@ -134,12 +134,12 @@ class WebDebugToolbarListenerTest extends TestCase public function provideRedirects() { - return array( - array(301, true), - array(302, true), - array(301, false), - array(302, false), - ); + return [ + [301, true], + [302, true], + [301, false], + [302, false], + ]; } /** @@ -230,7 +230,7 @@ class WebDebugToolbarListenerTest extends TestCase $urlGenerator ->expects($this->once()) ->method('generate') - ->with('_profiler', array('token' => 'xxxxxxxx'), UrlGeneratorInterface::ABSOLUTE_URL) + ->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL) ->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx')) ; @@ -251,7 +251,7 @@ class WebDebugToolbarListenerTest extends TestCase $urlGenerator ->expects($this->once()) ->method('generate') - ->with('_profiler', array('token' => 'xxxxxxxx')) + ->with('_profiler', ['token' => 'xxxxxxxx']) ->willThrowException(new \Exception('foo')) ; @@ -272,7 +272,7 @@ class WebDebugToolbarListenerTest extends TestCase $urlGenerator ->expects($this->once()) ->method('generate') - ->with('_profiler', array('token' => 'xxxxxxxx')) + ->with('_profiler', ['token' => 'xxxxxxxx']) ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")) ; @@ -286,7 +286,7 @@ class WebDebugToolbarListenerTest extends TestCase protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true) { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock(); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') ->will($this->returnValue($isXmlHttpRequest)); diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php index a9c62c99c6..73c51cc8e0 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php @@ -27,7 +27,7 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; */ class ServerLogCommand extends Command { - private static $bgColor = array('black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'); + private static $bgColor = ['black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow']; private $el; private $handler; @@ -87,12 +87,12 @@ EOF $this->handler = new ConsoleHandler($output); - $this->handler->setFormatter(new ConsoleFormatter(array( + $this->handler->setFormatter(new ConsoleFormatter([ 'format' => str_replace('\n', "\n", $input->getOption('format')), 'date_format' => $input->getOption('date-format'), 'colors' => $output->isDecorated(), 'multiline' => OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity(), - ))); + ])); if (false === strpos($host = $input->getOption('host'), '://')) { $host = 'tcp://'.$host; @@ -120,8 +120,8 @@ EOF private function getLogs($socket) { - $sockets = array((int) $socket => $socket); - $write = array(); + $sockets = [(int) $socket => $socket]; + $write = []; while (true) { $read = $sockets; diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php index 1c671bf668..124dd9e7ab 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php @@ -48,11 +48,11 @@ class ServerRunCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'), new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root, usually where your front controllers are stored'), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), - )) + ]) ->setDescription('Runs a local web server') ->setHelp(<<<'EOF' %command.name% runs a local web server: By default, the server diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php index daeada8ec0..562e79ad88 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -48,12 +48,12 @@ class ServerStartCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'), new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root'), new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'), new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), - )) + ]) ->setDescription('Starts a local web server in the background') ->setHelp(<<<'EOF' %command.name% runs a local web server: By default, the server @@ -91,10 +91,10 @@ EOF $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); if (!\extension_loaded('pcntl')) { - $io->error(array( + $io->error([ 'This command needs the pcntl extension to run.', 'You can either install it or use the "server:run" command instead.', - )); + ]); if ($io->confirm('Do you want to execute server:run immediately?', false)) { return $this->getApplication()->find('server:run')->run($input, $output); diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php index 938c5ca24a..95e8122a2d 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php @@ -36,10 +36,10 @@ class ServerStatusCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'The value to display (one of port, host, or address)'), - )) + ]) ->setDescription('Outputs the status of the local web server') ->setHelp(<<<'EOF' %command.name% shows the details of the given local web diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php index a64bbcbb05..f86df7ff00 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php @@ -34,9 +34,9 @@ class ServerStopCommand extends Command protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'), - )) + ]) ->setDescription('Stops the local web server that was started with the server:start command') ->setHelp(<<<'EOF' %command.name% stops the local web server: diff --git a/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php index 0d9c2f4bd5..f52f0d2c58 100644 --- a/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php +++ b/src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php @@ -22,7 +22,7 @@ class WebServerExtensionTest extends TestCase { $container = new ContainerBuilder(); $container->setParameter('kernel.project_dir', __DIR__); - (new WebServerExtension())->load(array(), $container); + (new WebServerExtension())->load([], $container); $this->assertSame( __DIR__.'/test', diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index f727b3ed4e..3f28c73263 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -150,12 +150,12 @@ class WebServer throw new \RuntimeException('Unable to find the PHP binary.'); } - $process = new Process(array_merge(array($binary), $finder->findArguments(), array('-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()))); + $process = new Process(array_merge([$binary], $finder->findArguments(), ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()])); $process->setWorkingDirectory($config->getDocumentRoot()); $process->setTimeout(null); if (\in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) { - $process->setEnv(array('APP_ENV' => false)); + $process->setEnv(['APP_ENV' => false]); $process->inheritEnvironmentVariables(); } diff --git a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php index 8a46208ead..9488ee5cc0 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php @@ -114,7 +114,7 @@ class WebServerConfig private function getFrontControllerFileNames($env) { - return array('app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'); + return ['app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php']; } private function findBestPort() diff --git a/src/Symfony/Component/Asset/Packages.php b/src/Symfony/Component/Asset/Packages.php index 63808d9078..3e82dcdcd4 100644 --- a/src/Symfony/Component/Asset/Packages.php +++ b/src/Symfony/Component/Asset/Packages.php @@ -23,13 +23,13 @@ use Symfony\Component\Asset\Exception\LogicException; class Packages { private $defaultPackage; - private $packages = array(); + private $packages = []; /** * @param PackageInterface $defaultPackage The default package * @param PackageInterface[] $packages Additional packages indexed by name */ - public function __construct(PackageInterface $defaultPackage = null, array $packages = array()) + public function __construct(PackageInterface $defaultPackage = null, array $packages = []) { $this->defaultPackage = $defaultPackage; diff --git a/src/Symfony/Component/Asset/Tests/PackageTest.php b/src/Symfony/Component/Asset/Tests/PackageTest.php index a5da219b59..8f6626ae4d 100644 --- a/src/Symfony/Component/Asset/Tests/PackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PackageTest.php @@ -29,22 +29,22 @@ class PackageTest extends TestCase public function getConfigs() { - return array( - array('v1', '', 'http://example.com/foo', 'http://example.com/foo'), - array('v1', '', 'https://example.com/foo', 'https://example.com/foo'), - array('v1', '', '//example.com/foo', '//example.com/foo'), + return [ + ['v1', '', 'http://example.com/foo', 'http://example.com/foo'], + ['v1', '', 'https://example.com/foo', 'https://example.com/foo'], + ['v1', '', '//example.com/foo', '//example.com/foo'], - array('v1', '', '/foo', '/foo?v1'), - array('v1', '', 'foo', 'foo?v1'), + ['v1', '', '/foo', '/foo?v1'], + ['v1', '', 'foo', 'foo?v1'], - array(null, '', '/foo', '/foo'), - array(null, '', 'foo', 'foo'), + [null, '', '/foo', '/foo'], + [null, '', 'foo', 'foo'], - array('v1', 'version-%2$s/%1$s', '/foo', '/version-v1/foo'), - array('v1', 'version-%2$s/%1$s', 'foo', 'version-v1/foo'), - array('v1', 'version-%2$s/%1$s', 'foo/', 'version-v1/foo/'), - array('v1', 'version-%2$s/%1$s', '/foo/', '/version-v1/foo/'), - ); + ['v1', 'version-%2$s/%1$s', '/foo', '/version-v1/foo'], + ['v1', 'version-%2$s/%1$s', 'foo', 'version-v1/foo'], + ['v1', 'version-%2$s/%1$s', 'foo/', 'version-v1/foo/'], + ['v1', 'version-%2$s/%1$s', '/foo/', '/version-v1/foo/'], + ]; } public function testGetVersion() diff --git a/src/Symfony/Component/Asset/Tests/PackagesTest.php b/src/Symfony/Component/Asset/Tests/PackagesTest.php index 4b0872f7f2..b751986d48 100644 --- a/src/Symfony/Component/Asset/Tests/PackagesTest.php +++ b/src/Symfony/Component/Asset/Tests/PackagesTest.php @@ -27,7 +27,7 @@ class PackagesTest extends TestCase $this->assertEquals($default, $packages->getPackage()); $this->assertEquals($a, $packages->getPackage('a')); - $packages = new Packages($default, array('a' => $a)); + $packages = new Packages($default, ['a' => $a]); $this->assertEquals($default, $packages->getPackage()); $this->assertEquals($a, $packages->getPackage('a')); @@ -37,7 +37,7 @@ class PackagesTest extends TestCase { $packages = new Packages( new Package(new StaticVersionStrategy('default')), - array('a' => new Package(new StaticVersionStrategy('a'))) + ['a' => new Package(new StaticVersionStrategy('a'))] ); $this->assertEquals('default', $packages->getVersion('/foo')); @@ -48,7 +48,7 @@ class PackagesTest extends TestCase { $packages = new Packages( new Package(new StaticVersionStrategy('default')), - array('a' => new Package(new StaticVersionStrategy('a'))) + ['a' => new Package(new StaticVersionStrategy('a'))] ); $this->assertEquals('/foo?default', $packages->getUrl('/foo')); diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index 4a9f90df90..c6edc8de61 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -28,24 +28,24 @@ class PathPackageTest extends TestCase public function getConfigs() { - return array( - array('/foo', '', 'http://example.com/foo', 'http://example.com/foo'), - array('/foo', '', 'https://example.com/foo', 'https://example.com/foo'), - array('/foo', '', '//example.com/foo', '//example.com/foo'), + return [ + ['/foo', '', 'http://example.com/foo', 'http://example.com/foo'], + ['/foo', '', 'https://example.com/foo', 'https://example.com/foo'], + ['/foo', '', '//example.com/foo', '//example.com/foo'], - array('', '', '/foo', '/foo?v1'), + ['', '', '/foo', '/foo?v1'], - array('/foo', '', '/bar', '/bar?v1'), - array('/foo', '', 'bar', '/foo/bar?v1'), - array('foo', '', 'bar', '/foo/bar?v1'), - array('foo/', '', 'bar', '/foo/bar?v1'), - array('/foo/', '', 'bar', '/foo/bar?v1'), + ['/foo', '', '/bar', '/bar?v1'], + ['/foo', '', 'bar', '/foo/bar?v1'], + ['foo', '', 'bar', '/foo/bar?v1'], + ['foo/', '', 'bar', '/foo/bar?v1'], + ['/foo/', '', 'bar', '/foo/bar?v1'], - array('/foo', 'version-%2$s/%1$s', '/bar', '/version-v1/bar'), - array('/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'), - array('/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'), - array('/foo', 'version-%2$s/%1$s', '/bar/', '/version-v1/bar/'), - ); + ['/foo', 'version-%2$s/%1$s', '/bar', '/version-v1/bar'], + ['/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'], + ['/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'], + ['/foo', 'version-%2$s/%1$s', '/bar/', '/version-v1/bar/'], + ]; } /** @@ -60,19 +60,19 @@ class PathPackageTest extends TestCase public function getContextConfigs() { - return array( - array('', '/foo', '', '/baz', '/baz?v1'), - array('', '/foo', '', 'baz', '/foo/baz?v1'), - array('', 'foo', '', 'baz', '/foo/baz?v1'), - array('', 'foo/', '', 'baz', '/foo/baz?v1'), - array('', '/foo/', '', 'baz', '/foo/baz?v1'), + return [ + ['', '/foo', '', '/baz', '/baz?v1'], + ['', '/foo', '', 'baz', '/foo/baz?v1'], + ['', 'foo', '', 'baz', '/foo/baz?v1'], + ['', 'foo/', '', 'baz', '/foo/baz?v1'], + ['', '/foo/', '', 'baz', '/foo/baz?v1'], - array('/bar', '/foo', '', '/baz', '/baz?v1'), - array('/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'), - array('/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'), - array('/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'), - array('/bar', '/foo/', '', 'baz', '/bar/foo/baz?v1'), - ); + ['/bar', '/foo', '', '/baz', '/baz?v1'], + ['/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'], + ['/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'], + ['/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'], + ['/bar', '/foo/', '', 'baz', '/bar/foo/baz?v1'], + ]; } public function testVersionStrategyGivesAbsoluteURL() diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index d37ba0126c..9b71d45bf3 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -29,26 +29,26 @@ class UrlPackageTest extends TestCase public function getConfigs() { - return array( - array('http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'), - array('http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'), - array('http://example.net', '', '//example.com/foo', '//example.com/foo'), + return [ + ['http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'], + ['http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'], + ['http://example.net', '', '//example.com/foo', '//example.com/foo'], - array('http://example.com', '', '/foo', 'http://example.com/foo?v1'), - array('http://example.com', '', 'foo', 'http://example.com/foo?v1'), - array('http://example.com/', '', 'foo', 'http://example.com/foo?v1'), - array('http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'), - array('http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'), + ['http://example.com', '', '/foo', 'http://example.com/foo?v1'], + ['http://example.com', '', 'foo', 'http://example.com/foo?v1'], + ['http://example.com/', '', 'foo', 'http://example.com/foo?v1'], + ['http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'], + ['http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'], - array(array('http://example.com'), '', '/foo', 'http://example.com/foo?v1'), - array(array('http://example.com', 'http://example.net'), '', '/foo', 'http://example.com/foo?v1'), - array(array('http://example.com', 'http://example.net'), '', '/fooa', 'http://example.net/fooa?v1'), + [['http://example.com'], '', '/foo', 'http://example.com/foo?v1'], + [['http://example.com', 'http://example.net'], '', '/foo', 'http://example.com/foo?v1'], + [['http://example.com', 'http://example.net'], '', '/fooa', 'http://example.net/fooa?v1'], - array('http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'), - array('http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'), - array('http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'), - array('http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'), - ); + ['http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'], + ['http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'], + ['http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'], + ['http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'], + ]; } /** @@ -63,18 +63,18 @@ class UrlPackageTest extends TestCase public function getContextConfigs() { - return array( - array(false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'), - array(false, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'), - array(false, array('http://example.com', 'https://example.com'), '', 'foo', 'http://example.com/foo?v1'), - array(false, array('http://example.com', 'https://example.com'), '', 'fooa', 'https://example.com/fooa?v1'), - array(false, array('http://example.com/bar'), '', 'foo', 'http://example.com/bar/foo?v1'), - array(false, array('http://example.com/bar/'), '', 'foo', 'http://example.com/bar/foo?v1'), - array(false, array('//example.com/bar/'), '', 'foo', '//example.com/bar/foo?v1'), + return [ + [false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'], + [false, ['http://example.com'], '', 'foo', 'http://example.com/foo?v1'], + [false, ['http://example.com', 'https://example.com'], '', 'foo', 'http://example.com/foo?v1'], + [false, ['http://example.com', 'https://example.com'], '', 'fooa', 'https://example.com/fooa?v1'], + [false, ['http://example.com/bar'], '', 'foo', 'http://example.com/bar/foo?v1'], + [false, ['http://example.com/bar/'], '', 'foo', 'http://example.com/bar/foo?v1'], + [false, ['//example.com/bar/'], '', 'foo', '//example.com/bar/foo?v1'], - array(true, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'), - array(true, array('http://example.com', 'https://example.com'), '', 'foo', 'https://example.com/foo?v1'), - ); + [true, ['http://example.com'], '', 'foo', 'http://example.com/foo?v1'], + [true, ['http://example.com', 'https://example.com'], '', 'foo', 'https://example.com/foo?v1'], + ]; } public function testVersionStrategyGivesAbsoluteURL() @@ -93,7 +93,7 @@ class UrlPackageTest extends TestCase */ public function testNoBaseUrls() { - new UrlPackage(array(), new EmptyVersionStrategy()); + new UrlPackage([], new EmptyVersionStrategy()); } /** @@ -101,7 +101,7 @@ class UrlPackageTest extends TestCase */ public function testWrongBaseUrl() { - new UrlPackage(array('not-a-url'), new EmptyVersionStrategy()); + new UrlPackage(['not-a-url'], new EmptyVersionStrategy()); } private function getContext($secure) diff --git a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php index 7b5a3e8d5c..c56a8726a8 100644 --- a/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php +++ b/src/Symfony/Component/Asset/Tests/VersionStrategy/StaticVersionStrategyTest.php @@ -36,9 +36,9 @@ class StaticVersionStrategyTest extends TestCase public function getConfigs() { - return array( - array('test-path', 'v1', null), - array('test-path', 'v2', '%s?test%s'), - ); + return [ + ['test-path', 'v1', null], + ['test-path', 'v2', '%s?test%s'], + ]; } } diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index 77055e43db..23809a55fd 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -35,7 +35,7 @@ use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface; */ class UrlPackage extends Package { - private $baseUrls = array(); + private $baseUrls = []; private $sslPackage; /** @@ -125,7 +125,7 @@ class UrlPackage extends Package private function getSslUrls($urls) { - $sslUrls = array(); + $sslUrls = []; foreach ($urls as $url) { if ('https://' === substr($url, 0, 8) || '//' === substr($url, 0, 2)) { $sslUrls[] = $url; diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index 0fd530af8b..0fb9320238 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -22,7 +22,7 @@ class Cookie * Handles dates as defined by RFC 2616 section 3.3.1, and also some other * non-standard, but common formats. */ - private static $dateFormats = array( + private static $dateFormats = [ 'D, d M Y H:i:s T', 'D, d-M-y H:i:s T', 'D, d-M-Y H:i:s T', @@ -30,7 +30,7 @@ class Cookie 'D, d-m-Y H:i:s T', 'D M j G:i:s Y', 'D M d H:i:s Y T', - ); + ]; protected $name; protected $value; @@ -129,7 +129,7 @@ class Cookie list($name, $value) = explode('=', array_shift($parts), 2); - $values = array( + $values = [ 'name' => trim($name), 'value' => trim($value), 'expires' => null, @@ -138,7 +138,7 @@ class Cookie 'secure' => false, 'httponly' => false, 'passedRawValue' => true, - ); + ]; if (null !== $url) { if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) { diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index 24eb9abedd..bce66197d3 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -18,7 +18,7 @@ namespace Symfony\Component\BrowserKit; */ class CookieJar { - protected $cookieJar = array(); + protected $cookieJar = []; public function set(Cookie $cookie) { @@ -84,7 +84,7 @@ class CookieJar // this should never happen but it allows for a better BC $domains = array_keys($this->cookieJar); } else { - $domains = array($domain); + $domains = [$domain]; } foreach ($domains as $domain) { @@ -105,7 +105,7 @@ class CookieJar */ public function clear() { - $this->cookieJar = array(); + $this->cookieJar = []; } /** @@ -116,7 +116,7 @@ class CookieJar */ public function updateFromSetCookie(array $setCookies, $uri = null) { - $cookies = array(); + $cookies = []; foreach ($setCookies as $cookie) { foreach (explode(',', $cookie) as $i => $part) { @@ -157,7 +157,7 @@ class CookieJar { $this->flushExpiredCookies(); - $flattenedCookies = array(); + $flattenedCookies = []; foreach ($this->cookieJar as $path) { foreach ($path as $cookies) { foreach ($cookies as $cookie) { @@ -181,8 +181,8 @@ class CookieJar { $this->flushExpiredCookies(); - $parts = array_replace(array('path' => '/'), parse_url($uri)); - $cookies = array(); + $parts = array_replace(['path' => '/'], parse_url($uri)); + $cookies = []; foreach ($this->cookieJar as $domain => $pathCookies) { if ($domain) { $domain = '.'.ltrim($domain, '.'); diff --git a/src/Symfony/Component/BrowserKit/History.php b/src/Symfony/Component/BrowserKit/History.php index beec17c6b4..8ed3fd17fe 100644 --- a/src/Symfony/Component/BrowserKit/History.php +++ b/src/Symfony/Component/BrowserKit/History.php @@ -18,7 +18,7 @@ namespace Symfony\Component\BrowserKit; */ class History { - protected $stack = array(); + protected $stack = []; protected $position = -1; /** @@ -26,7 +26,7 @@ class History */ public function clear() { - $this->stack = array(); + $this->stack = []; $this->position = -1; } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index d54bb8f88e..b9b88540af 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -76,13 +76,13 @@ class ClientTest extends TestCase { public function testGetHistory() { - $client = new TestClient(array(), $history = new History()); + $client = new TestClient([], $history = new History()); $this->assertSame($history, $client->getHistory(), '->getHistory() returns the History'); } public function testGetCookieJar() { - $client = new TestClient(array(), null, $cookieJar = new CookieJar()); + $client = new TestClient([], null, $cookieJar = new CookieJar()); $this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar'); } @@ -115,7 +115,7 @@ class ClientTest extends TestCase public function testGetRequestWithIpAsHttpHost() { $client = new TestClient(); - $client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1')); + $client->request('GET', 'https://example.com/foo', [], [], ['HTTP_HOST' => '127.0.0.1']); $this->assertEquals('https://example.com/foo', $client->getRequest()->getUri()); $headers = $client->getRequest()->getServer(); @@ -168,7 +168,7 @@ class ClientTest extends TestCase $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; $client = new TestClient(); - $client->request('POST', 'http://example.com/jsonrpc', array(), array(), array(), $json); + $client->request('POST', 'http://example.com/jsonrpc', [], [], [], $json); $this->assertEquals($json, $client->getRequest()->getContent()); } @@ -294,18 +294,18 @@ class ClientTest extends TestCase public function testRequestCookies() { $client = new TestClient(); - $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar'))); + $client->setNextResponse(new Response('foo', 200, ['Set-Cookie' => 'foo=bar'])); $client->request('GET', 'http://www.example.com/foo/foobar'); - $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + $this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); $client->request('GET', 'bar'); - $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + $this->assertEquals(['foo' => 'bar'], $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); } public function testRequestSecureCookies() { $client = new TestClient(); - $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar; path=/; secure'))); + $client->setNextResponse(new Response('foo', 200, ['Set-Cookie' => 'foo=bar; path=/; secure'])); $client->request('GET', 'https://www.example.com/foo/foobar'); $this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure()); @@ -346,7 +346,7 @@ class ClientTest extends TestCase public function testSubmitPreserveAuth() { - $client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar')); + $client = new TestClient(['PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar']); $client->setNextResponse(new Response('')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -394,26 +394,26 @@ class ClientTest extends TestCase $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); } - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $client->followRedirect(); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); $client = new TestClient(); - $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); $client = new TestClient(); - $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 201, ['Location' => 'http://www.example.com/redirected'])); $client->followRedirects(false); $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -428,12 +428,12 @@ class ClientTest extends TestCase public function testFollowRelativeRedirect() { $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => '/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234'))); + $client->setNextResponse(new Response('', 302, ['Location' => '/redirected:1234'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); } @@ -442,11 +442,11 @@ class ClientTest extends TestCase { $client = new TestClient(); $client->setMaxRedirects(1); - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2'))); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected2'])); try { $client->followRedirect(); $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); @@ -454,60 +454,60 @@ class ClientTest extends TestCase $this->assertInstanceOf('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); } - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); - $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->setNextResponse(new Response('', 302, ['Location' => '/redirected'])); $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/'))); + $client->setNextResponse(new Response('', 302, ['Location' => '//www.example.org/'])); $client->request('GET', 'https://www.example.com/'); $this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); - $client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar')); + $client->setNextResponse(new Response('', 302, ['Location' => 'http://www.example.com/redirected'])); + $client->request('POST', 'http://www.example.com/foo/foobar', ['name' => 'bar']); $this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() uses a GET for 302'); - $this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); + $this->assertEquals([], $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); } public function testFollowRedirectWithCookies() { $client = new TestClient(); $client->followRedirects(false); - $client->setNextResponse(new Response('', 302, array( + $client->setNextResponse(new Response('', 302, [ 'Location' => 'http://www.example.com/redirected', 'Set-Cookie' => 'foo=bar', - ))); + ])); $client->request('GET', 'http://www.example.com/'); - $this->assertEquals(array(), $client->getRequest()->getCookies()); + $this->assertEquals([], $client->getRequest()->getCookies()); $client->followRedirect(); - $this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies()); + $this->assertEquals(['foo' => 'bar'], $client->getRequest()->getCookies()); } public function testFollowRedirectWithHeaders() { - $headers = array( + $headers = [ 'HTTP_HOST' => 'www.example.com', 'HTTP_USER_AGENT' => 'Symfony BrowserKit', 'CONTENT_TYPE' => 'application/vnd.custom+xml', 'HTTPS' => false, - ); + ]; $client = new TestClient(); $client->followRedirects(false); - $client->setNextResponse(new Response('', 302, array( + $client->setNextResponse(new Response('', 302, [ 'Location' => 'http://www.example.com/redirected', - ))); - $client->request('GET', 'http://www.example.com/', array(), array(), array( + ])); + $client->request('GET', 'http://www.example.com/', [], [], [ 'CONTENT_TYPE' => 'application/vnd.custom+xml', - )); + ]); $this->assertEquals($headers, $client->getRequest()->getServer()); @@ -520,17 +520,17 @@ class ClientTest extends TestCase public function testFollowRedirectWithPort() { - $headers = array( + $headers = [ 'HTTP_HOST' => 'www.example.com:8080', 'HTTP_USER_AGENT' => 'Symfony BrowserKit', 'HTTPS' => false, 'HTTP_REFERER' => 'http://www.example.com:8080/', - ); + ]; $client = new TestClient(); - $client->setNextResponse(new Response('', 302, array( + $client->setNextResponse(new Response('', 302, [ 'Location' => 'http://www.example.com:8080/redirected', - ))); + ])); $client->request('GET', 'http://www.example.com:8080/'); $this->assertEquals($headers, $client->getRequest()->getServer()); @@ -554,14 +554,14 @@ class ClientTest extends TestCase public function testFollowRedirectWithPostMethod() { - $parameters = array('foo' => 'bar'); - $files = array('myfile.foo' => 'baz'); - $server = array('X_TEST_FOO' => 'bazbar'); + $parameters = ['foo' => 'bar']; + $files = ['myfile.foo' => 'baz']; + $server = ['X_TEST_FOO' => 'bazbar']; $content = 'foobarbaz'; $client = new TestClient(); - $client->setNextResponse(new Response('', 307, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 307, ['Location' => 'http://www.example.com/redirected'])); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method'); @@ -574,15 +574,15 @@ class ClientTest extends TestCase public function testFollowRedirectDropPostMethod() { - $parameters = array('foo' => 'bar'); - $files = array('myfile.foo' => 'baz'); - $server = array('X_TEST_FOO' => 'bazbar'); + $parameters = ['foo' => 'bar']; + $files = ['myfile.foo' => 'baz']; + $server = ['X_TEST_FOO' => 'bazbar']; $content = 'foobarbaz'; $client = new TestClient(); - foreach (array(301, 302, 303) as $code) { - $client->setNextResponse(new Response('', $code, array('Location' => 'http://www.example.com/redirected'))); + foreach ([301, 302, 303] as $code) { + $client->setNextResponse(new Response('', $code, ['Location' => 'http://www.example.com/redirected'])); $client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method on response code: '.$code.'.'); @@ -598,9 +598,9 @@ class ClientTest extends TestCase { $client = new TestClient(); - $parameters = array('foo' => 'bar'); - $files = array('myfile.foo' => 'baz'); - $server = array('X_TEST_FOO' => 'bazbar'); + $parameters = ['foo' => 'bar']; + $files = ['myfile.foo' => 'baz']; + $server = ['X_TEST_FOO' => 'bazbar']; $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); @@ -618,9 +618,9 @@ class ClientTest extends TestCase { $client = new TestClient(); - $parameters = array('foo' => 'bar'); - $files = array('myfile.foo' => 'baz'); - $server = array('X_TEST_FOO' => 'bazbar'); + $parameters = ['foo' => 'bar']; + $files = ['myfile.foo' => 'baz']; + $server = ['X_TEST_FOO' => 'bazbar']; $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -640,7 +640,7 @@ class ClientTest extends TestCase $client = new TestClient(); $client->request('GET', 'http://www.example.com/foo'); - $client->setNextResponse(new Response('', 301, array('Location' => 'http://www.example.com/redirected'))); + $client->setNextResponse(new Response('', 301, ['Location' => 'http://www.example.com/redirected'])); $client->request('GET', 'http://www.example.com/bar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), 'client followed redirect'); @@ -658,9 +658,9 @@ class ClientTest extends TestCase { $client = new TestClient(); - $parameters = array('foo' => 'bar'); - $files = array('myfile.foo' => 'baz'); - $server = array('X_TEST_FOO' => 'bazbar'); + $parameters = ['foo' => 'bar']; + $files = ['myfile.foo' => 'baz']; + $server = ['X_TEST_FOO' => 'bazbar']; $content = 'foobarbaz'; $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); @@ -680,7 +680,7 @@ class ClientTest extends TestCase $client->restart(); $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history'); - $this->assertEquals(array(), $client->getCookieJar()->all(), '->restart() clears the cookies'); + $this->assertEquals([], $client->getCookieJar()->all(), '->restart() clears the cookies'); } public function testInsulatedRequests() @@ -731,12 +731,12 @@ class ClientTest extends TestCase $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( + $client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [ 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, 'NEW_SERVER_KEY' => 'new-server-key-value', - )); + ]); $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); @@ -762,16 +762,16 @@ class ClientTest extends TestCase { $client = new TestClient(); - $client->request('GET', '/', array(), array(), array( + $client->request('GET', '/', [], [], [ 'HTTP_HOST' => 'testhost', 'HTTPS' => true, - )); + ]); $this->assertEquals('https://testhost/', $client->getRequest()->getUri()); - $client->request('GET', 'https://www.example.com/', array(), array(), array( + $client->request('GET', 'https://www.example.com/', [], [], [ 'HTTP_HOST' => 'testhost', 'HTTPS' => false, - )); + ]); $this->assertEquals('https://www.example.com/', $client->getRequest()->getUri()); } @@ -779,12 +779,12 @@ class ClientTest extends TestCase { $client = new TestClient(); - $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( + $client->request('GET', 'https://www.example.com/https/www.example.com', [], [], [ 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, 'NEW_SERVER_KEY' => 'new-server-key-value', - )); + ]); $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index 3117e5ce47..d88f0234c6 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -45,7 +45,7 @@ class CookieJarTest extends TestCase $cookieJar->set($cookie1 = new Cookie('foo', 'bar')); $cookieJar->set($cookie2 = new Cookie('bar', 'foo')); - $this->assertEquals(array($cookie1, $cookie2), $cookieJar->all(), '->all() returns all cookies in the jar'); + $this->assertEquals([$cookie1, $cookie2], $cookieJar->all(), '->all() returns all cookies in the jar'); } public function testClear() @@ -56,12 +56,12 @@ class CookieJarTest extends TestCase $cookieJar->clear(); - $this->assertEquals(array(), $cookieJar->all(), '->clear() expires all cookies'); + $this->assertEquals([], $cookieJar->all(), '->clear() expires all cookies'); } public function testUpdateFromResponse() { - $response = new Response('', 200, array('Set-Cookie' => 'foo=foo')); + $response = new Response('', 200, ['Set-Cookie' => 'foo=foo']); $cookieJar = new CookieJar(); $cookieJar->updateFromResponse($response); @@ -71,7 +71,7 @@ class CookieJarTest extends TestCase public function testUpdateFromSetCookie() { - $setCookies = array('foo=foo'); + $setCookies = ['foo=foo']; $cookieJar = new CookieJar(); $cookieJar->set(new Cookie('bar', 'bar')); @@ -86,15 +86,15 @@ class CookieJarTest extends TestCase public function testUpdateFromEmptySetCookie() { $cookieJar = new CookieJar(); - $cookieJar->updateFromSetCookie(array('')); - $this->assertEquals(array(), $cookieJar->all()); + $cookieJar->updateFromSetCookie(['']); + $this->assertEquals([], $cookieJar->all()); } public function testUpdateFromSetCookieWithMultipleCookies() { $timestamp = time() + 3600; $date = gmdate('D, d M Y H:i:s \G\M\T', $timestamp); - $setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%1$s', $date)); + $setCookies = [sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%1$s', $date)]; $cookieJar = new CookieJar(); $cookieJar->updateFromSetCookie($setCookies); @@ -132,15 +132,15 @@ class CookieJarTest extends TestCase public function provideAllValuesValues() { - return array( - array('http://www.example.com', array('foo_nothing', 'foo_domain')), - array('http://www.example.com/', array('foo_nothing', 'foo_domain')), - array('http://foo.example.com/', array('foo_nothing', 'foo_domain')), - array('http://foo.example1.com/', array('foo_nothing')), - array('https://foo.example.com/', array('foo_nothing', 'foo_secure', 'foo_domain')), - array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')), - array('http://www4.example.com/', array('foo_nothing', 'foo_domain', 'foo_strict_domain')), - ); + return [ + ['http://www.example.com', ['foo_nothing', 'foo_domain']], + ['http://www.example.com/', ['foo_nothing', 'foo_domain']], + ['http://foo.example.com/', ['foo_nothing', 'foo_domain']], + ['http://foo.example1.com/', ['foo_nothing']], + ['https://foo.example.com/', ['foo_nothing', 'foo_secure', 'foo_domain']], + ['http://www.example.com/foo/bar', ['foo_nothing', 'foo_path', 'foo_domain']], + ['http://www4.example.com/', ['foo_nothing', 'foo_domain', 'foo_strict_domain']], + ]; } public function testEncodedValues() @@ -148,8 +148,8 @@ class CookieJarTest extends TestCase $cookieJar = new CookieJar(); $cookieJar->set($cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true)); - $this->assertEquals(array('foo' => 'bar=baz'), $cookieJar->allValues('/')); - $this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/')); + $this->assertEquals(['foo' => 'bar=baz'], $cookieJar->allValues('/')); + $this->assertEquals(['foo' => 'bar%3Dbaz'], $cookieJar->allRawValues('/')); } public function testCookieExpireWithSameNameButDifferentPaths() @@ -160,9 +160,9 @@ class CookieJarTest extends TestCase $cookieJar->expire('foo', '/foo'); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); - $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); - $this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo')); - $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); + $this->assertEquals([], array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals([], $cookieJar->allValues('http://example.com/foo')); + $this->assertEquals(['foo' => 'bar2'], $cookieJar->allValues('http://example.com/bar')); } public function testCookieExpireWithNullPaths() @@ -172,7 +172,7 @@ class CookieJarTest extends TestCase $cookieJar->expire('foo', null); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); - $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals([], array_keys($cookieJar->allValues('http://example.com/'))); } public function testCookieExpireWithDomain() @@ -182,7 +182,7 @@ class CookieJarTest extends TestCase $cookieJar->expire('foo', '/foo', 'http://example2.com/'); $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); - $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example2.com/'))); + $this->assertEquals([], array_keys($cookieJar->allValues('http://example2.com/'))); } public function testCookieWithSameNameButDifferentPaths() @@ -191,9 +191,9 @@ class CookieJarTest extends TestCase $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo')); $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar')); - $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); - $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://example.com/foo')); - $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); + $this->assertEquals([], array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals(['foo' => 'bar1'], $cookieJar->allValues('http://example.com/foo')); + $this->assertEquals(['foo' => 'bar2'], $cookieJar->allValues('http://example.com/bar')); } public function testCookieWithSameNameButDifferentDomains() @@ -202,9 +202,9 @@ class CookieJarTest extends TestCase $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/', 'foo.example.com')); $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/', 'bar.example.com')); - $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); - $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://foo.example.com/')); - $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/')); + $this->assertEquals([], array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals(['foo' => 'bar1'], $cookieJar->allValues('http://foo.example.com/')); + $this->assertEquals(['foo' => 'bar2'], $cookieJar->allValues('http://bar.example.com/')); } public function testCookieGetWithSubdomain() @@ -246,7 +246,7 @@ class CookieJarTest extends TestCase $cookieJar = new CookieJar(); $cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com')); - $this->assertEquals(array('foo' => 'bar'), $cookieJar->allValues('http://www.example.com')); + $this->assertEquals(['foo' => 'bar'], $cookieJar->allValues('http://www.example.com')); $this->assertEmpty($cookieJar->allValues('http://wwwexample.com')); } } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 2f5a08d104..1ffa1d87ed 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -41,16 +41,16 @@ class CookieTest extends TestCase public function getTestsForToFromString() { - return array( - array('foo=bar; path=/'), - array('foo=bar; path=/foo'), - array('foo=bar; domain=google.com; path=/'), - array('foo=bar; domain=example.com; path=/; secure', 'https://example.com/'), - array('foo=bar; path=/; httponly'), - array('foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'), - array('foo=bar=baz; path=/'), - array('foo=bar%3Dbaz; path=/'), - ); + return [ + ['foo=bar; path=/'], + ['foo=bar; path=/foo'], + ['foo=bar; domain=google.com; path=/'], + ['foo=bar; domain=example.com; path=/; secure', 'https://example.com/'], + ['foo=bar; path=/; httponly'], + ['foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'], + ['foo=bar=baz; path=/'], + ['foo=bar%3Dbaz; path=/'], + ]; } public function testFromStringIgnoreSecureFlag() @@ -69,16 +69,16 @@ class CookieTest extends TestCase public function getExpireCookieStrings() { - return array( - array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'), - array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'), - array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'), - array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'), - array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'), - array('foo=bar; expires=Fri Jul 31 08:49:37 2020'), - array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''), - array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'), - ); + return [ + ['foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'], + ['foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'], + ['foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'], + ['foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'], + ['foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'], + ['foo=bar; expires=Fri Jul 31 08:49:37 2020'], + ['foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''], + ['foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'], + ]; } public function testFromStringWithCapitalization() diff --git a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php index f163de9674..e7718eef87 100644 --- a/src/Symfony/Component/BrowserKit/Tests/RequestTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/RequestTest.php @@ -30,25 +30,25 @@ class RequestTest extends TestCase public function testGetParameters() { - $request = new Request('http://www.example.com/', 'get', array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $request->getParameters(), '->getParameters() returns the parameters of the request'); + $request = new Request('http://www.example.com/', 'get', ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $request->getParameters(), '->getParameters() returns the parameters of the request'); } public function testGetFiles() { - $request = new Request('http://www.example.com/', 'get', array(), array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $request->getFiles(), '->getFiles() returns the uploaded files of the request'); + $request = new Request('http://www.example.com/', 'get', [], ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $request->getFiles(), '->getFiles() returns the uploaded files of the request'); } public function testGetCookies() { - $request = new Request('http://www.example.com/', 'get', array(), array(), array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $request->getCookies(), '->getCookies() returns the cookies of the request'); + $request = new Request('http://www.example.com/', 'get', [], [], ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $request->getCookies(), '->getCookies() returns the cookies of the request'); } public function testGetServer() { - $request = new Request('http://www.example.com/', 'get', array(), array(), array(), array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $request->getServer(), '->getServer() returns the server parameters of the request'); + $request = new Request('http://www.example.com/', 'get', [], [], [], ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request'); } } diff --git a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php index 0ba4e3b3a7..56f49aee19 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -30,40 +30,40 @@ class ResponseTest extends TestCase public function testGetHeaders() { - $response = new Response('foo', 200, array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $response->getHeaders(), '->getHeaders() returns the headers of the response'); + $response = new Response('foo', 200, ['foo' => 'bar']); + $this->assertEquals(['foo' => 'bar'], $response->getHeaders(), '->getHeaders() returns the headers of the response'); } public function testGetHeader() { - $response = new Response('foo', 200, array( + $response = new Response('foo', 200, [ 'Content-Type' => 'text/html', - 'Set-Cookie' => array('foo=bar', 'bar=foo'), - )); + 'Set-Cookie' => ['foo=bar', 'bar=foo'], + ]); $this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response'); $this->assertEquals('text/html', $response->getHeader('content-type'), '->getHeader() returns a header of the response'); $this->assertEquals('text/html', $response->getHeader('content_type'), '->getHeader() returns a header of the response'); $this->assertEquals('foo=bar', $response->getHeader('Set-Cookie'), '->getHeader() returns the first header value'); - $this->assertEquals(array('foo=bar', 'bar=foo'), $response->getHeader('Set-Cookie', false), '->getHeader() returns all header values if first is false'); + $this->assertEquals(['foo=bar', 'bar=foo'], $response->getHeader('Set-Cookie', false), '->getHeader() returns all header values if first is false'); $this->assertNull($response->getHeader('foo'), '->getHeader() returns null if the header is not defined'); - $this->assertEquals(array(), $response->getHeader('foo', false), '->getHeader() returns an empty array if the header is not defined and first is set to false'); + $this->assertEquals([], $response->getHeader('foo', false), '->getHeader() returns an empty array if the header is not defined and first is set to false'); } public function testMagicToString() { - $response = new Response('foo', 304, array('foo' => 'bar')); + $response = new Response('foo', 304, ['foo' => 'bar']); $this->assertEquals("foo: bar\n\nfoo", $response->__toString(), '->__toString() returns the headers and the content as a string'); } public function testMagicToStringWithMultipleSetCookieHeader() { - $headers = array( + $headers = [ 'content-type' => 'text/html; charset=utf-8', - 'set-cookie' => array('foo=bar', 'bar=foo'), - ); + 'set-cookie' => ['foo=bar', 'bar=foo'], + ]; $expected = 'content-type: text/html; charset=utf-8'."\n"; $expected .= 'set-cookie: foo=bar'."\n"; diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 8899e22ecd..f3ab76f20e 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -55,9 +55,9 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $getId = \Closure::fromCallable(array($this, 'getId')); $this->mergeByLifetime = \Closure::bind( function ($deferred, $namespace, &$expiredIds) use ($getId) { - $byLifetime = array(); + $byLifetime = []; $now = time(); - $expiredIds = array(); + $expiredIds = []; foreach ($deferred as $key => $item) { $key = (string) $key; @@ -120,10 +120,10 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $apcu->setLogger($logger); } - return new ChainAdapter(array($apcu, $fs)); + return new ChainAdapter([$apcu, $fs]); } - public static function createConnection($dsn, array $options = array()) + public static function createConnection($dsn, array $options = []) { if (!\is_string($dsn)) { throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, \gettype($dsn))); @@ -153,11 +153,11 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $value = null; try { - foreach ($this->doFetch(array($id)) as $value) { + foreach ($this->doFetch([$id]) as $value) { $isHit = true; } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]); } return $f($key, $value, $isHit); @@ -166,12 +166,12 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { if ($this->deferred) { $this->commit(); } - $ids = array(); + $ids = []; foreach ($keys as $key) { $ids[] = $this->getId($key); @@ -179,8 +179,8 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface try { $items = $this->doFetch($ids); } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => $keys, 'exception' => $e)); - $items = array(); + CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => $keys, 'exception' => $e]); + $items = []; } $ids = array_combine($ids, $keys); @@ -221,7 +221,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $ok = true; $byLifetime = $this->mergeByLifetime; $byLifetime = $byLifetime($this->deferred, $this->namespace, $expiredIds); - $retry = $this->deferred = array(); + $retry = $this->deferred = []; if ($expiredIds) { $this->doDelete($expiredIds); @@ -231,7 +231,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $e = $this->doSave($values, $lifetime); } catch (\Exception $e) { } - if (true === $e || array() === $e) { + if (true === $e || [] === $e) { continue; } if (\is_array($e) || 1 === \count($values)) { @@ -239,7 +239,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface $ok = false; $v = $values[$id]; $type = \is_object($v) ? \get_class($v) : \gettype($v); - CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null)); + CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]); } } else { foreach ($values as $id => $v) { @@ -253,15 +253,15 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface foreach ($ids as $id) { try { $v = $byLifetime[$lifetime][$id]; - $e = $this->doSave(array($id => $v), $lifetime); + $e = $this->doSave([$id => $v], $lifetime); } catch (\Exception $e) { } - if (true === $e || array() === $e) { + if (true === $e || [] === $e) { continue; } $ok = false; $type = \is_object($v) ? \get_class($v) : \gettype($v); - CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null)); + CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]); } } @@ -289,7 +289,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface yield $key => $f($key, $value, true); } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => array_values($keys), 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => array_values($keys), 'exception' => $e]); } foreach ($keys as $key) { diff --git a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php index 41222c1ab5..85fe07684f 100644 --- a/src/Symfony/Component/Cache/Adapter/AdapterInterface.php +++ b/src/Symfony/Component/Cache/Adapter/AdapterInterface.php @@ -33,5 +33,5 @@ interface AdapterInterface extends CacheItemPoolInterface * * @return \Traversable|CacheItem[] */ - public function getItems(array $keys = array()); + public function getItems(array $keys = []); } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 830d6ddced..5dc8e0d648 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -66,7 +66,7 @@ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, Resettable $isHit = false; } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', ['key' => $key, 'exception' => $e]); $this->values[$key] = $value = null; $isHit = false; } @@ -78,7 +78,7 @@ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, Resettable /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { foreach ($keys as $key) { CacheItem::validateKey($key); @@ -122,7 +122,7 @@ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, Resettable $value = serialize($value); } catch (\Exception $e) { $type = \is_object($value) ? \get_class($value) : \gettype($value); - CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => $key, 'type' => $type, 'exception' => $e]); return false; } diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index db0da4fb5b..9ca99ddd5e 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -28,7 +28,7 @@ use Symfony\Component\Cache\ResettableInterface; */ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { - private $adapters = array(); + private $adapters = []; private $adapterCount; private $syncItem; @@ -81,7 +81,7 @@ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableIn public function getItem($key) { $syncItem = $this->syncItem; - $misses = array(); + $misses = []; foreach ($this->adapters as $i => $adapter) { $item = $adapter->getItem($key); @@ -103,15 +103,15 @@ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableIn /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { return $this->generateItems($this->adapters[0]->getItems($keys), 0); } private function generateItems($items, $adapterIndex) { - $missing = array(); - $misses = array(); + $missing = []; + $misses = []; $nextAdapterIndex = $adapterIndex + 1; $nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null; diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index f58f81e5b8..c81a1cd646 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -49,7 +49,7 @@ class NullAdapter implements AdapterInterface /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { return $this->generateItems($keys); } diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 01242b65b6..e98a60ae77 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -114,7 +114,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { foreach ($keys as $key) { if (!\is_string($key)) { @@ -164,7 +164,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl public function deleteItems(array $keys) { $deleted = true; - $fallbackKeys = array(); + $fallbackKeys = []; foreach ($keys as $key) { if (!\is_string($key)) { @@ -223,7 +223,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl private function generateItems(array $keys): \Generator { $f = $this->createCacheItem; - $fallbackKeys = array(); + $fallbackKeys = []; foreach ($keys as $key) { if (isset($this->values[$key])) { @@ -261,10 +261,10 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl { $e = new \ReflectionException("Class $class does not exist"); $trace = $e->getTrace(); - $autoloadFrame = array( + $autoloadFrame = [ 'function' => 'spl_autoload_call', - 'args' => array($class), - ); + 'args' => [$class], + ]; $i = 1 + array_search($autoloadFrame, $trace, true); if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) { diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 0d4fcc4725..af499dcca5 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -68,7 +68,7 @@ class ProxyAdapter implements AdapterInterface, PruneableInterface, ResettableIn /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { if ($this->namespaceLen) { foreach ($keys as $i => $key) { diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 9110511b9a..9da9e69651 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -27,13 +27,13 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R use ProxyTrait; - private $deferred = array(); + private $deferred = []; private $createCacheItem; private $setCacheItemTags; private $getTagsByKey; private $invalidateTags; private $tags; - private $knownTagVersions = array(); + private $knownTagVersions = []; private $knownTagVersionsTtl; public function __construct(AdapterInterface $itemsPool, AdapterInterface $tagsPool = null, float $knownTagVersionsTtl = 0.15) @@ -78,7 +78,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R ); $this->getTagsByKey = \Closure::bind( function ($deferred) { - $tagsByKey = array(); + $tagsByKey = []; foreach ($deferred as $key => $item) { $tagsByKey[$key] = $item->tags; } @@ -109,8 +109,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R public function invalidateTags(array $tags) { $ok = true; - $tagsByKey = array(); - $invalidatedTags = array(); + $tagsByKey = []; + $invalidatedTags = []; foreach ($tags as $tag) { CacheItem::validateKey($tag); $invalidatedTags[$tag] = 0; @@ -127,7 +127,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R $f = $this->getTagsByKey; $tagsByKey = $f($items); - $this->deferred = array(); + $this->deferred = []; } $tagVersions = $this->getTagVersions($tagsByKey, $invalidatedTags); @@ -161,7 +161,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R return true; } - foreach ($this->getTagVersions(array($itemTags)) as $tag => $version) { + foreach ($this->getTagVersions([$itemTags]) as $tag => $version) { if ($itemTags[$tag] !== $version && 1 !== $itemTags[$tag] - $version) { return false; } @@ -175,7 +175,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R */ public function getItem($key) { - foreach ($this->getItems(array($key)) as $item) { + foreach ($this->getItems([$key]) as $item) { return $item; } } @@ -183,12 +183,12 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { if ($this->deferred) { $this->commit(); } - $tagKeys = array(); + $tagKeys = []; foreach ($keys as $key) { if ('' !== $key && \is_string($key)) { @@ -213,7 +213,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R */ public function clear() { - $this->deferred = array(); + $this->deferred = []; return $this->pool->clear(); } @@ -223,7 +223,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R */ public function deleteItem($key) { - return $this->deleteItems(array($key)); + return $this->deleteItems([$key]); } /** @@ -271,7 +271,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R */ public function commit() { - return $this->invalidateTags(array()); + return $this->invalidateTags([]); } public function __destruct() @@ -281,7 +281,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R private function generateItems($items, array $tagKeys) { - $bufferedItems = $itemTags = array(); + $bufferedItems = $itemTags = []; $f = $this->setCacheItemTags; foreach ($items as $key => $item) { @@ -295,7 +295,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R } unset($tagKeys[$key]); - $itemTags[$key] = $item->get() ?: array(); + $itemTags[$key] = $item->get() ?: []; if (!$tagKeys) { $tagVersions = $this->getTagVersions($itemTags); @@ -318,7 +318,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R } } - private function getTagVersions(array $tagsByKey, array &$invalidatedTags = array()) + private function getTagVersions(array $tagsByKey, array &$invalidatedTags = []) { $tagVersions = $invalidatedTags; @@ -327,7 +327,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R } if (!$tagVersions) { - return array(); + return []; } if (!$fetchTagVersions = 1 !== \func_num_args()) { @@ -341,7 +341,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R } $now = microtime(true); - $tags = array(); + $tags = []; foreach ($tagVersions as $tag => $version) { $tags[$tag.static::TAGS_PREFIX] = $tag; if ($fetchTagVersions || !isset($this->knownTagVersions[$tag])) { @@ -366,7 +366,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R if (isset($invalidatedTags[$tag])) { $invalidatedTags[$tag] = $version->set(++$tagVersions[$tag]); } - $this->knownTagVersions[$tag] = array($now, $tagVersions[$tag]); + $this->knownTagVersions[$tag] = [$now, $tagVersions[$tag]]; } return $tagVersions; diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 98d0e52693..4aed2d7181 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -25,7 +25,7 @@ use Symfony\Component\Cache\ResettableInterface; class TraceableAdapter implements AdapterInterface, PruneableInterface, ResettableInterface { protected $pool; - private $calls = array(); + private $calls = []; public function __construct(AdapterInterface $pool) { @@ -107,7 +107,7 @@ class TraceableAdapter implements AdapterInterface, PruneableInterface, Resettab /** * {@inheritdoc} */ - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { $event = $this->start(__FUNCTION__); try { @@ -116,7 +116,7 @@ class TraceableAdapter implements AdapterInterface, PruneableInterface, Resettab $event->end = microtime(true); } $f = function () use ($result, $event) { - $event->result = array(); + $event->result = []; foreach ($result as $key => $item) { if ($event->result[$key] = $item->isHit()) { ++$event->hits; @@ -209,7 +209,7 @@ class TraceableAdapter implements AdapterInterface, PruneableInterface, Resettab public function clearCalls() { - $this->calls = array(); + $this->calls = []; } protected function start($name) diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 58ecad82d2..4ab5d1a264 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -25,8 +25,8 @@ final class CacheItem implements CacheItemInterface protected $isHit = false; protected $expiry; protected $defaultLifetime; - protected $tags = array(); - protected $prevTags = array(); + protected $tags = []; + protected $prevTags = []; protected $innerItem; protected $poolHash; @@ -110,7 +110,7 @@ final class CacheItem implements CacheItemInterface public function tag($tags) { if (!\is_array($tags)) { - $tags = array($tags); + $tags = [$tags]; } foreach ($tags as $tag) { if (!\is_string($tag)) { @@ -170,12 +170,12 @@ final class CacheItem implements CacheItemInterface * * @internal */ - public static function log(LoggerInterface $logger = null, $message, $context = array()) + public static function log(LoggerInterface $logger = null, $message, $context = []) { if ($logger) { $logger->warning($message, $context); } else { - $replace = array(); + $replace = []; foreach ($context as $k => $v) { if (is_scalar($v)) { $replace['{'.$k.'}'] = $v; diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 91763e5a9f..dd6263b1ad 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -27,7 +27,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter /** * @var TraceableAdapter[] */ - private $instances = array(); + private $instances = []; /** * @param string $name @@ -43,8 +43,8 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $empty = array('calls' => array(), 'config' => array(), 'options' => array(), 'statistics' => array()); - $this->data = array('instances' => $empty, 'total' => $empty); + $empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []]; + $this->data = ['instances' => $empty, 'total' => $empty]; foreach ($this->instances as $name => $instance) { $this->data['instances']['calls'][$name] = $instance->getCalls(); } @@ -55,7 +55,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter public function reset() { - $this->data = array(); + $this->data = []; foreach ($this->instances as $instance) { $instance->clearCalls(); } @@ -106,9 +106,9 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter private function calculateStatistics(): array { - $statistics = array(); + $statistics = []; foreach ($this->data['instances']['calls'] as $name => $calls) { - $statistics[$name] = array( + $statistics[$name] = [ 'calls' => 0, 'time' => 0, 'reads' => 0, @@ -116,7 +116,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter 'deletes' => 0, 'hits' => 0, 'misses' => 0, - ); + ]; /** @var TraceableAdapterEvent $call */ foreach ($calls as $call) { ++$statistics[$name]['calls']; @@ -158,7 +158,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter private function calculateTotalStatistics(): array { $statistics = $this->getStatistics(); - $totals = array( + $totals = [ 'calls' => 0, 'time' => 0, 'reads' => 0, @@ -166,7 +166,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter 'deletes' => 0, 'hits' => 0, 'misses' => 0, - ); + ]; foreach ($statistics as $name => $values) { foreach ($totals as $key => $value) { $totals[$key] += $statistics[$name][$key]; diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php index 08456f588f..7a2a3cb36e 100644 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php @@ -48,11 +48,11 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re $id = $this->getId($key); try { - foreach ($this->doFetch(array($id)) as $value) { + foreach ($this->doFetch([$id]) as $value) { return $value; } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]); } return $default; @@ -65,7 +65,7 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re { CacheItem::validateKey($key); - return $this->setMultiple(array($key => $value), $ttl); + return $this->setMultiple([$key => $value], $ttl); } /** @@ -78,7 +78,7 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re } elseif (!\is_array($keys)) { throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); } - $ids = array(); + $ids = []; foreach ($keys as $key) { $ids[] = $this->getId($key); @@ -86,8 +86,8 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re try { $values = $this->doFetch($ids); } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch requested values', array('keys' => $keys, 'exception' => $e)); - $values = array(); + CacheItem::log($this->logger, 'Failed to fetch requested values', ['keys' => $keys, 'exception' => $e]); + $values = []; } $ids = array_combine($ids, $keys); @@ -102,7 +102,7 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re if (!\is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); } - $valuesById = array(); + $valuesById = []; foreach ($values as $key => $value) { if (\is_int($key)) { @@ -118,14 +118,14 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re $e = $this->doSave($valuesById, $ttl); } catch (\Exception $e) { } - if (true === $e || array() === $e) { + if (true === $e || [] === $e) { return true; } - $keys = array(); + $keys = []; foreach (\is_array($e) ? $e : array_keys($valuesById) as $id) { $keys[] = substr($id, \strlen($this->namespace)); } - CacheItem::log($this->logger, 'Failed to save values', array('keys' => $keys, 'exception' => $e instanceof \Exception ? $e : null)); + CacheItem::log($this->logger, 'Failed to save values', ['keys' => $keys, 'exception' => $e instanceof \Exception ? $e : null]); return false; } @@ -171,7 +171,7 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re yield $key => $value; } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch requested values', array('keys' => array_values($keys), 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to fetch requested values', ['keys' => array_values($keys), 'exception' => $e]); } foreach ($keys as $key) { diff --git a/src/Symfony/Component/Cache/Simple/ArrayCache.php b/src/Symfony/Component/Cache/Simple/ArrayCache.php index aadefe2046..735e97678e 100644 --- a/src/Symfony/Component/Cache/Simple/ArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/ArrayCache.php @@ -45,7 +45,7 @@ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInte */ public function get($key, $default = null) { - foreach ($this->getMultiple(array($key), $default) as $v) { + foreach ($this->getMultiple([$key], $default) as $v) { return $v; } } @@ -89,7 +89,7 @@ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInte { CacheItem::validateKey($key); - return $this->setMultiple(array($key => $value), $ttl); + return $this->setMultiple([$key => $value], $ttl); } /** @@ -100,7 +100,7 @@ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInte if (!\is_array($values) && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); } - $valuesArray = array(); + $valuesArray = []; foreach ($values as $key => $value) { \is_int($key) || CacheItem::validateKey($key); @@ -115,7 +115,7 @@ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInte $valuesArray[$key] = serialize($value); } catch (\Exception $e) { $type = \is_object($value) ? \get_class($value) : \gettype($value); - CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => $key, 'type' => $type, 'exception' => $e]); return false; } diff --git a/src/Symfony/Component/Cache/Simple/ChainCache.php b/src/Symfony/Component/Cache/Simple/ChainCache.php index 38c0a9b359..f34ec80c67 100644 --- a/src/Symfony/Component/Cache/Simple/ChainCache.php +++ b/src/Symfony/Component/Cache/Simple/ChainCache.php @@ -27,7 +27,7 @@ use Symfony\Component\Cache\ResettableInterface; class ChainCache implements CacheInterface, PruneableInterface, ResettableInterface { private $miss; - private $caches = array(); + private $caches = []; private $defaultLifetime; private $cacheCount; @@ -87,7 +87,7 @@ class ChainCache implements CacheInterface, PruneableInterface, ResettableInterf private function generateItems($values, $cacheIndex, $miss, $default) { - $missing = array(); + $missing = []; $nextCacheIndex = $cacheIndex + 1; $nextCache = isset($this->caches[$nextCacheIndex]) ? $this->caches[$nextCacheIndex] : null; @@ -201,7 +201,7 @@ class ChainCache implements CacheInterface, PruneableInterface, ResettableInterf if ($values instanceof \Traversable) { $valuesIterator = $values; $values = function () use ($valuesIterator, &$values) { - $generatedValues = array(); + $generatedValues = []; foreach ($valuesIterator as $key => $value) { yield $key => $value; diff --git a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php index 19f9d5dbd7..119bb947dd 100644 --- a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php @@ -149,7 +149,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt } $deleted = true; - $fallbackKeys = array(); + $fallbackKeys = []; foreach ($keys as $key) { if (!\is_string($key)) { @@ -198,7 +198,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt } $saved = true; - $fallbackValues = array(); + $fallbackValues = []; foreach ($values as $key => $value) { if (!\is_string($key) && !\is_int($key)) { @@ -221,7 +221,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt private function generateItems(array $keys, $default) { - $fallbackKeys = array(); + $fallbackKeys = []; foreach ($keys as $key) { if (isset($this->values[$key])) { diff --git a/src/Symfony/Component/Cache/Simple/Psr6Cache.php b/src/Symfony/Component/Cache/Simple/Psr6Cache.php index 853d46e26b..85d75becbe 100644 --- a/src/Symfony/Component/Cache/Simple/Psr6Cache.php +++ b/src/Symfony/Component/Cache/Simple/Psr6Cache.php @@ -145,7 +145,7 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa } catch (Psr6CacheException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } - $values = array(); + $values = []; foreach ($items as $key => $item) { $values[$key] = $item->isHit() ? $item->get() : $default; @@ -163,7 +163,7 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa if (!$valuesIsArray && !$values instanceof \Traversable) { throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); } - $items = array(); + $items = []; try { if (null !== $f = $this->createCacheItem) { @@ -172,7 +172,7 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa $items[$key] = $f($key, $value, true); } } elseif ($valuesIsArray) { - $items = array(); + $items = []; foreach ($values as $key => $value) { $items[] = (string) $key; } diff --git a/src/Symfony/Component/Cache/Simple/TraceableCache.php b/src/Symfony/Component/Cache/Simple/TraceableCache.php index 181934eff5..61b22963eb 100644 --- a/src/Symfony/Component/Cache/Simple/TraceableCache.php +++ b/src/Symfony/Component/Cache/Simple/TraceableCache.php @@ -24,7 +24,7 @@ class TraceableCache implements CacheInterface, PruneableInterface, ResettableIn { private $pool; private $miss; - private $calls = array(); + private $calls = []; public function __construct(CacheInterface $pool) { @@ -99,7 +99,7 @@ class TraceableCache implements CacheInterface, PruneableInterface, ResettableIn public function setMultiple($values, $ttl = null) { $event = $this->start(__FUNCTION__); - $event->result['keys'] = array(); + $event->result['keys'] = []; if ($values instanceof \Traversable) { $values = function () use ($values, $event) { @@ -133,7 +133,7 @@ class TraceableCache implements CacheInterface, PruneableInterface, ResettableIn $event->end = microtime(true); } $f = function () use ($result, $event, $miss, $default) { - $event->result = array(); + $event->result = []; foreach ($result as $key => $value) { if ($event->result[$key] = $miss !== $value) { ++$event->hits; @@ -216,7 +216,7 @@ class TraceableCache implements CacheInterface, PruneableInterface, ResettableIn try { return $this->calls; } finally { - $this->calls = array(); + $this->calls = []; } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php index 147dfcd153..5fcec9a263 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AbstractRedisAdapterTest.php @@ -15,11 +15,11 @@ use Symfony\Component\Cache\Adapter\RedisAdapter; abstract class AbstractRedisAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testExpiration' => 'Testing expiration slows down the test suite', 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; protected static $redis; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index 018d149467..3a5f95b8b6 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -81,11 +81,11 @@ abstract class AdapterTestCase extends CachePoolTest $item = $cache->getItem('foo'); $this->assertFalse($item->isHit()); - foreach ($cache->getItems(array('foo')) as $item) { + foreach ($cache->getItems(['foo']) as $item) { } $cache->save($item->set(new NotUnserializable())); - foreach ($cache->getItems(array('foo')) as $item) { + foreach ($cache->getItems(['foo']) as $item) { } $this->assertFalse($item->isHit()); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index a17b42bce4..5cca73f561 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -16,11 +16,11 @@ use Symfony\Component\Cache\Adapter\ApcuAdapter; class ApcuAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testExpiration' => 'Testing expiration slows down the test suite', 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; public function createCachePool($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php index 725d790150..e6adc9d012 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ArrayAdapterTest.php @@ -18,10 +18,10 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; */ class ArrayAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', - ); + ]; public function createCachePool($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index a47058f513..010f68b973 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -26,7 +26,7 @@ class ChainAdapterTest extends AdapterTestCase { public function createCachePool($defaultLifetime = 0) { - return new ChainAdapter(array(new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime); + return new ChainAdapter([new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime); } /** @@ -35,7 +35,7 @@ class ChainAdapterTest extends AdapterTestCase */ public function testEmptyAdaptersException() { - new ChainAdapter(array()); + new ChainAdapter([]); } /** @@ -44,7 +44,7 @@ class ChainAdapterTest extends AdapterTestCase */ public function testInvalidAdapterException() { - new ChainAdapter(array(new \stdClass())); + new ChainAdapter([new \stdClass()]); } public function testPrune() @@ -53,18 +53,18 @@ class ChainAdapterTest extends AdapterTestCase $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } - $cache = new ChainAdapter(array( + $cache = new ChainAdapter([ $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), - )); + ]); $this->assertTrue($cache->prune()); - $cache = new ChainAdapter(array( + $cache = new ChainAdapter([ $this->getPruneableMock(), $this->getFailingPruneableMock(), $this->getPruneableMock(), - )); + ]); $this->assertFalse($cache->prune()); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php index 8d4dfe2858..8f520cb59a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php @@ -19,11 +19,11 @@ use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; */ class DoctrineAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayCache is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayCache is not.', 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', - ); + ]; public function createCachePool($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php index 5e301f2509..8bea26810c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -19,15 +19,15 @@ class MaxIdLengthAdapterTest extends TestCase public function testLongKey() { $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) - ->setConstructorArgs(array(str_repeat('-', 10))) - ->setMethods(array('doHave', 'doFetch', 'doDelete', 'doSave', 'doClear')) + ->setConstructorArgs([str_repeat('-', 10)]) + ->setMethods(['doHave', 'doFetch', 'doDelete', 'doSave', 'doClear']) ->getMock(); $cache->expects($this->exactly(2)) ->method('doHave') ->withConsecutive( - array($this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')), - array($this->equalTo('----------:---------------------------------------')) + [$this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')], + [$this->equalTo('----------:---------------------------------------')] ); $cache->hasItem(str_repeat('-', 40)); @@ -37,7 +37,7 @@ class MaxIdLengthAdapterTest extends TestCase public function testLongKeyVersioning() { $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) - ->setConstructorArgs(array(str_repeat('-', 26))) + ->setConstructorArgs([str_repeat('-', 26)]) ->getMock(); $reflectionClass = new \ReflectionClass(AbstractAdapter::class); @@ -46,20 +46,20 @@ class MaxIdLengthAdapterTest extends TestCase $reflectionMethod->setAccessible(true); // No versioning enabled - $this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23))))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40))))); + $this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); $reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($cache, true); // Versioning enabled - $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23))))); - $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40))))); + $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); + $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); } /** @@ -69,7 +69,7 @@ class MaxIdLengthAdapterTest extends TestCase public function testTooLongNamespace() { $cache = $this->getMockBuilder(MaxIdLengthAdapter::class) - ->setConstructorArgs(array(str_repeat('-', 40))) + ->setConstructorArgs([str_repeat('-', 40)]) ->getMock(); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php index 1f2f4d40ac..2a88fea18b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php @@ -16,10 +16,10 @@ use Symfony\Component\Cache\Adapter\MemcachedAdapter; class MemcachedAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; protected static $client; @@ -28,7 +28,7 @@ class MemcachedAdapterTest extends AdapterTestCase if (!MemcachedAdapter::isSupported()) { self::markTestSkipped('Extension memcached >=2.2.0 required.'); } - self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)); + self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); self::$client->get('foo'); $code = self::$client->getResultCode(); @@ -46,13 +46,13 @@ class MemcachedAdapterTest extends AdapterTestCase public function testOptions() { - $client = MemcachedAdapter::createConnection(array(), array( + $client = MemcachedAdapter::createConnection([], [ 'libketama_compatible' => false, 'distribution' => 'modula', 'compression' => true, 'serializer' => 'php', 'hash' => 'md5', - )); + ]); $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); @@ -68,24 +68,24 @@ class MemcachedAdapterTest extends AdapterTestCase */ public function testBadOptions($name, $value) { - MemcachedAdapter::createConnection(array(), array($name => $value)); + MemcachedAdapter::createConnection([], [$name => $value]); } public function provideBadOptions() { - return array( - array('foo', 'bar'), - array('hash', 'zyx'), - array('serializer', 'zyx'), - array('distribution', 'zyx'), - ); + return [ + ['foo', 'bar'], + ['hash', 'zyx'], + ['serializer', 'zyx'], + ['distribution', 'zyx'], + ]; } public function testDefaultOptions() { $this->assertTrue(MemcachedAdapter::isSupported()); - $client = MemcachedAdapter::createConnection(array()); + $client = MemcachedAdapter::createConnection([]); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); @@ -103,7 +103,7 @@ class MemcachedAdapterTest extends AdapterTestCase $this->markTestSkipped('Memcached::HAVE_JSON required'); } - new MemcachedAdapter(MemcachedAdapter::createConnection(array(), array('serializer' => 'json'))); + new MemcachedAdapter(MemcachedAdapter::createConnection([], ['serializer' => 'json'])); } /** @@ -112,54 +112,54 @@ class MemcachedAdapterTest extends AdapterTestCase public function testServersSetting($dsn, $host, $port) { $client1 = MemcachedAdapter::createConnection($dsn); - $client2 = MemcachedAdapter::createConnection(array($dsn)); - $client3 = MemcachedAdapter::createConnection(array(array($host, $port))); - $expect = array( + $client2 = MemcachedAdapter::createConnection([$dsn]); + $client3 = MemcachedAdapter::createConnection([[$host, $port]]); + $expect = [ 'host' => $host, 'port' => $port, - ); + ]; - $f = function ($s) { return array('host' => $s['host'], 'port' => $s['port']); }; - $this->assertSame(array($expect), array_map($f, $client1->getServerList())); - $this->assertSame(array($expect), array_map($f, $client2->getServerList())); - $this->assertSame(array($expect), array_map($f, $client3->getServerList())); + $f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; }; + $this->assertSame([$expect], array_map($f, $client1->getServerList())); + $this->assertSame([$expect], array_map($f, $client2->getServerList())); + $this->assertSame([$expect], array_map($f, $client3->getServerList())); } public function provideServersSetting() { - yield array( + yield [ 'memcached://127.0.0.1/50', '127.0.0.1', 11211, - ); - yield array( + ]; + yield [ 'memcached://localhost:11222?weight=25', 'localhost', 11222, - ); + ]; if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield array( + yield [ 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', 11211, - ); + ]; } - yield array( + yield [ 'memcached:///var/run/memcached.sock?weight=25', '/var/run/memcached.sock', 0, - ); - yield array( + ]; + yield [ 'memcached:///var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, - ); + ]; if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield array( + yield [ 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, - ); + ]; } } @@ -181,16 +181,16 @@ class MemcachedAdapterTest extends AdapterTestCase self::markTestSkipped('Extension memcached required.'); } - yield array( + yield [ 'memcached://localhost:11222?retry_timeout=10', - array(\Memcached::OPT_RETRY_TIMEOUT => 8), - array(\Memcached::OPT_RETRY_TIMEOUT => 10), - ); - yield array( + [\Memcached::OPT_RETRY_TIMEOUT => 8], + [\Memcached::OPT_RETRY_TIMEOUT => 10], + ]; + yield [ 'memcached://localhost:11222?socket_recv_size=1&socket_send_size=2', - array(\Memcached::OPT_RETRY_TIMEOUT => 8), - array(\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8), - ); + [\Memcached::OPT_RETRY_TIMEOUT => 8], + [\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8], + ]; } public function testClear() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php index 73e5cad552..b771fa0ed8 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php @@ -43,7 +43,7 @@ class NullAdapterTest extends TestCase { $adapter = $this->createCachePool(); - $keys = array('foo', 'bar', 'baz', 'biz'); + $keys = ['foo', 'bar', 'baz', 'biz']; /** @var CacheItemInterface[] $items */ $items = $adapter->getItems($keys); @@ -89,7 +89,7 @@ class NullAdapterTest extends TestCase public function testDeleteItems() { - $this->assertTrue($this->createCachePool()->deleteItems(array('key', 'foo', 'bar'))); + $this->assertTrue($this->createCachePool()->deleteItems(['key', 'foo', 'bar'])); } public function testSave() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index f89a27ce64..d0699f1e34 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -32,7 +32,7 @@ class PdoDbalAdapterTest extends AdapterTestCase self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); - $pool = new PdoAdapter(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile))); + $pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); $pool->createTable(); } @@ -43,6 +43,6 @@ class PdoDbalAdapterTest extends AdapterTestCase public function createCachePool($defaultLifetime = 0) { - return new PdoAdapter(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile)), '', $defaultLifetime); + return new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php index 8078064ad3..74694b21b7 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -20,7 +20,7 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter; */ class PhpArrayAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testBasicUsage' => 'PhpArrayAdapter is read-only.', 'testBasicUsageWithLongKey' => 'PhpArrayAdapter is read-only.', 'testClear' => 'PhpArrayAdapter is read-only.', @@ -51,7 +51,7 @@ class PhpArrayAdapterTest extends AdapterTestCase 'testDefaultLifeTime' => 'PhpArrayAdapter does not allow configuring a default lifetime.', 'testPrune' => 'PhpArrayAdapter just proxies', - ); + ]; protected static $file; @@ -74,22 +74,22 @@ class PhpArrayAdapterTest extends AdapterTestCase public function testStore() { - $arrayWithRefs = array(); + $arrayWithRefs = []; $arrayWithRefs[0] = 123; $arrayWithRefs[1] = &$arrayWithRefs[0]; - $object = (object) array( + $object = (object) [ 'foo' => 'bar', 'foo2' => 'bar2', - ); + ]; - $expected = array( + $expected = [ 'null' => null, 'serializedString' => serialize($object), 'arrayWithRefs' => $arrayWithRefs, 'object' => $object, - 'arrayWithObject' => array('bar' => $object), - ); + 'arrayWithObject' => ['bar' => $object], + ]; $adapter = $this->createCachePool(); $adapter->warmUp($expected); @@ -101,13 +101,13 @@ class PhpArrayAdapterTest extends AdapterTestCase public function testStoredFile() { - $expected = array( + $expected = [ 'integer' => 42, 'float' => 42.42, 'boolean' => true, - 'array_simple' => array('foo', 'bar'), - 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), - ); + 'array_simple' => ['foo', 'bar'], + 'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'], + ]; $adapter = $this->createCachePool(); $adapter->warmUp($expected); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php index 1a23198c2f..a7feced4ea 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpArrayAdapterWithFallbackTest.php @@ -19,14 +19,14 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter; */ class PhpArrayAdapterWithFallbackTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testHasItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testDeleteItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.', 'testPrune' => 'PhpArrayAdapter just proxies', - ); + ]; protected static $file; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php index 8e93c937f6..247160d53c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PhpFilesAdapterTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Adapter\PhpFilesAdapter; */ class PhpFilesAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.', - ); + ]; public function createCachePool() { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index c005d64abf..f311a35390 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -19,20 +19,20 @@ class PredisAdapterTest extends AbstractRedisAdapterTest public static function setupBeforeClass() { parent::setupBeforeClass(); - self::$redis = new \Predis\Client(array('host' => getenv('REDIS_HOST'))); + self::$redis = new \Predis\Client(['host' => getenv('REDIS_HOST')]); } public function testCreateConnection() { $redisHost = getenv('REDIS_HOST'); - $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', array('class' => \Predis\Client::class, 'timeout' => 3)); + $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/1', ['class' => \Predis\Client::class, 'timeout' => 3]); $this->assertInstanceOf(\Predis\Client::class, $redis); $connection = $redis->getConnection(); $this->assertInstanceOf(StreamConnection::class, $connection); - $params = array( + $params = [ 'scheme' => 'tcp', 'host' => $redisHost, 'path' => '', @@ -47,7 +47,7 @@ class PredisAdapterTest extends AbstractRedisAdapterTest 'lazy' => false, 'database' => '1', 'password' => null, - ); + ]; $this->assertSame($params, $connection->getParameters()->toArray()); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php index 38915397da..f723dc4468 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisClusterAdapterTest.php @@ -16,7 +16,7 @@ class PredisClusterAdapterTest extends AbstractRedisAdapterTest public static function setupBeforeClass() { parent::setupBeforeClass(); - self::$redis = new \Predis\Client(array(array('host' => getenv('REDIS_HOST')))); + self::$redis = new \Predis\Client([['host' => getenv('REDIS_HOST')]]); } public static function tearDownAfterClass() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php index ff4b9d34bc..f69ad67939 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php @@ -21,11 +21,11 @@ use Symfony\Component\Cache\CacheItem; */ class ProxyAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', 'testPrune' => 'ProxyAdapter just proxies', - ); + ]; public function createCachePool($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php index 28c310fb18..eb2cbd46fd 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php @@ -20,7 +20,7 @@ class RedisAdapterTest extends AbstractRedisAdapterTest public static function setupBeforeClass() { parent::setupBeforeClass(); - self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), array('lazy' => true)); + self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true]); } public function createCachePool($defaultLifetime = 0) @@ -43,13 +43,13 @@ class RedisAdapterTest extends AbstractRedisAdapterTest $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); - $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('timeout' => 3)); + $redis = RedisAdapter::createConnection('redis://'.$redisHost, ['timeout' => 3]); $this->assertEquals(3, $redis->getTimeout()); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); - $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); + $redis = RedisAdapter::createConnection('redis://'.$redisHost, ['read_timeout' => 5]); $this->assertEquals(5, $redis->getReadTimeout()); } @@ -65,11 +65,11 @@ class RedisAdapterTest extends AbstractRedisAdapterTest public function provideFailedCreateConnection() { - return array( - array('redis://localhost:1234'), - array('redis://foo@localhost'), - array('redis://localhost/123'), - ); + return [ + ['redis://localhost:1234'], + ['redis://foo@localhost'], + ['redis://localhost/123'], + ]; } /** @@ -84,9 +84,9 @@ class RedisAdapterTest extends AbstractRedisAdapterTest public function provideInvalidCreateConnection() { - return array( - array('foo://localhost'), - array('redis://'), - ); + return [ + ['foo://localhost'], + ['redis://'], + ]; } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php index bef3eb8872..749b039a03 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php @@ -19,6 +19,6 @@ class RedisArrayAdapterTest extends AbstractRedisAdapterTest if (!class_exists('RedisArray')) { self::markTestSkipped('The RedisArray class is required.'); } - self::$redis = new \RedisArray(array(getenv('REDIS_HOST')), array('lazy_connect' => true)); + self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php index 460f3b0954..84713416cd 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Simple\FilesystemCache; */ class SimpleCacheAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testPrune' => 'SimpleCache just proxies', - ); + ]; public function createCachePool($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index 7074299e7a..d0a1e5daf7 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -56,7 +56,7 @@ class TagAwareAdapterTest extends AdapterTestCase $pool->save($i3->tag('foo')->tag('baz')); $pool->save($foo); - $pool->invalidateTags(array('bar')); + $pool->invalidateTags(['bar']); $this->assertFalse($pool->getItem('i0')->isHit()); $this->assertTrue($pool->getItem('i1')->isHit()); @@ -64,7 +64,7 @@ class TagAwareAdapterTest extends AdapterTestCase $this->assertTrue($pool->getItem('i3')->isHit()); $this->assertTrue($pool->getItem('foo')->isHit()); - $pool->invalidateTags(array('foo')); + $pool->invalidateTags(['foo']); $this->assertFalse($pool->getItem('i1')->isHit()); $this->assertFalse($pool->getItem('i3')->isHit()); @@ -85,7 +85,7 @@ class TagAwareAdapterTest extends AdapterTestCase $foo->tag('tag'); $pool1->saveDeferred($foo->set('foo')); - $pool1->invalidateTags(array('tag')); + $pool1->invalidateTags(['tag']); $pool2 = $this->createCachePool(); $foo = $pool2->getItem('foo'); @@ -103,7 +103,7 @@ class TagAwareAdapterTest extends AdapterTestCase $i = $pool->getItem('k'); $pool->save($i->tag('bar')); - $pool->invalidateTags(array('foo')); + $pool->invalidateTags(['foo']); $this->assertTrue($pool->getItem('k')->isHit()); } @@ -116,7 +116,7 @@ class TagAwareAdapterTest extends AdapterTestCase $pool->deleteItem('k'); $pool->save($pool->getItem('k')); - $pool->invalidateTags(array('foo')); + $pool->invalidateTags(['foo']); $this->assertTrue($pool->getItem('k')->isHit()); } @@ -126,11 +126,11 @@ class TagAwareAdapterTest extends AdapterTestCase $pool = $this->createCachePool(10); $item = $pool->getItem('foo'); - $item->tag(array('baz')); + $item->tag(['baz']); $item->expiresAfter(100); $pool->save($item); - $pool->invalidateTags(array('baz')); + $pool->invalidateTags(['baz']); $this->assertFalse($pool->getItem('foo')->isHit()); sleep(20); @@ -146,7 +146,7 @@ class TagAwareAdapterTest extends AdapterTestCase $pool->save($i->tag('foo')); $i = $pool->getItem('k'); - $this->assertSame(array('foo' => 'foo'), $i->getPreviousTags()); + $this->assertSame(['foo' => 'foo'], $i->getPreviousTags()); } public function testPrune() diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php index 3755e88db5..35eba7d77b 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TraceableAdapterTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Adapter\TraceableAdapter; */ class TraceableAdapterTest extends AdapterTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testPrune' => 'TraceableAdapter just proxies', - ); + ]; public function createCachePool($defaultLifetime = 0) { @@ -37,7 +37,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[0]; $this->assertSame('getItem', $call->name); - $this->assertSame(array('k' => false), $call->result); + $this->assertSame(['k' => false], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); @@ -61,7 +61,7 @@ class TraceableAdapterTest extends AdapterTestCase public function testGetItemsMissTrace() { $pool = $this->createCachePool(); - $arg = array('k0', 'k1'); + $arg = ['k0', 'k1']; $items = $pool->getItems($arg); foreach ($items as $item) { } @@ -70,7 +70,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[0]; $this->assertSame('getItems', $call->name); - $this->assertSame(array('k0' => false, 'k1' => false), $call->result); + $this->assertSame(['k0' => false, 'k1' => false], $call->result); $this->assertSame(2, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); @@ -85,7 +85,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[0]; $this->assertSame('hasItem', $call->name); - $this->assertSame(array('k' => false), $call->result); + $this->assertSame(['k' => false], $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } @@ -101,7 +101,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[2]; $this->assertSame('hasItem', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } @@ -115,7 +115,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[0]; $this->assertSame('deleteItem', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -125,14 +125,14 @@ class TraceableAdapterTest extends AdapterTestCase public function testDeleteItemsTrace() { $pool = $this->createCachePool(); - $arg = array('k0', 'k1'); + $arg = ['k0', 'k1']; $pool->deleteItems($arg); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteItems', $call->name); - $this->assertSame(array('keys' => $arg, 'result' => true), $call->result); + $this->assertSame(['keys' => $arg, 'result' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -149,7 +149,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[1]; $this->assertSame('save', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -166,7 +166,7 @@ class TraceableAdapterTest extends AdapterTestCase $call = $calls[1]; $this->assertSame('saveDeferred', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php index 9b50bfabe6..5cd4185cb0 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TraceableTagAwareAdapterTest.php @@ -23,7 +23,7 @@ class TraceableTagAwareAdapterTest extends TraceableAdapterTest public function testInvalidateTags() { $pool = new TraceableTagAwareAdapter(new TagAwareAdapter(new FilesystemAdapter())); - $pool->invalidateTags(array('foo')); + $pool->invalidateTags(['foo']); $calls = $pool->getCalls(); $this->assertCount(1, $calls); diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php index 7cdcafd8e5..13b4f33066 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php @@ -6,7 +6,7 @@ use Doctrine\Common\Cache\CacheProvider; class ArrayCache extends CacheProvider { - private $data = array(); + private $data = []; protected function doFetch($id) { @@ -26,7 +26,7 @@ class ArrayCache extends CacheProvider protected function doSave($id, $data, $lifeTime = 0) { - $this->data[$id] = array($data, $lifeTime ? time() + $lifeTime : false); + $this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false]; return true; } @@ -40,7 +40,7 @@ class ArrayCache extends CacheProvider protected function doFlush() { - $this->data = array(); + $this->data = []; return true; } diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php index 493906ea0c..779a374ec7 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php @@ -34,7 +34,7 @@ class ExternalAdapter implements CacheItemPoolInterface return $this->cache->getItem($key); } - public function getItems(array $keys = array()) + public function getItems(array $keys = []) { return $this->cache->getItems($keys); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php index 3e668fdd12..dd5e1509c1 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php @@ -15,11 +15,11 @@ use Symfony\Component\Cache\Simple\RedisCache; abstract class AbstractRedisCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; protected static $redis; diff --git a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php index 3df32c1c5e..f37b95a093 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php @@ -15,11 +15,11 @@ use Symfony\Component\Cache\Simple\ApcuCache; class ApcuCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; public function createSimpleCache($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php index ab28e3bce7..e6f7c7cc63 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php @@ -24,7 +24,7 @@ class ChainCacheTest extends CacheTestCase { public function createSimpleCache($defaultLifetime = 0) { - return new ChainCache(array(new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)), $defaultLifetime); + return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime); } /** @@ -33,7 +33,7 @@ class ChainCacheTest extends CacheTestCase */ public function testEmptyCachesException() { - new ChainCache(array()); + new ChainCache([]); } /** @@ -42,7 +42,7 @@ class ChainCacheTest extends CacheTestCase */ public function testInvalidCacheException() { - new ChainCache(array(new \stdClass())); + new ChainCache([new \stdClass()]); } public function testPrune() @@ -51,18 +51,18 @@ class ChainCacheTest extends CacheTestCase $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } - $cache = new ChainCache(array( + $cache = new ChainCache([ $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), - )); + ]); $this->assertTrue($cache->prune()); - $cache = new ChainCache(array( + $cache = new ChainCache([ $this->getPruneableMock(), $this->getFailingPruneableMock(), $this->getPruneableMock(), - )); + ]); $this->assertFalse($cache->prune()); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php index 127c96858c..af4331d69b 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php @@ -19,10 +19,10 @@ use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; */ class DoctrineCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize', 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', - ); + ]; public function createSimpleCache($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php index ee9e49d3dd..f83f0a2e34 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php @@ -16,11 +16,11 @@ use Symfony\Component\Cache\Simple\MemcachedCache; class MemcachedCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testSetTtl' => 'Testing expiration slows down the test suite', 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ); + ]; protected static $client; @@ -40,29 +40,29 @@ class MemcachedCacheTest extends CacheTestCase public function createSimpleCache($defaultLifetime = 0) { - $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)) : self::$client; + $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client; return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); } public function testCreatePersistentConnectionShouldNotDupServerList() { - $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent')); + $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); $this->assertCount(1, $instance->getServerList()); - $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('persistent_id' => 'persistent')); + $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); $this->assertCount(1, $instance->getServerList()); } public function testOptions() { - $client = MemcachedCache::createConnection(array(), array( + $client = MemcachedCache::createConnection([], [ 'libketama_compatible' => false, 'distribution' => 'modula', 'compression' => true, 'serializer' => 'php', 'hash' => 'md5', - )); + ]); $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); @@ -78,24 +78,24 @@ class MemcachedCacheTest extends CacheTestCase */ public function testBadOptions($name, $value) { - MemcachedCache::createConnection(array(), array($name => $value)); + MemcachedCache::createConnection([], [$name => $value]); } public function provideBadOptions() { - return array( - array('foo', 'bar'), - array('hash', 'zyx'), - array('serializer', 'zyx'), - array('distribution', 'zyx'), - ); + return [ + ['foo', 'bar'], + ['hash', 'zyx'], + ['serializer', 'zyx'], + ['distribution', 'zyx'], + ]; } public function testDefaultOptions() { $this->assertTrue(MemcachedCache::isSupported()); - $client = MemcachedCache::createConnection(array()); + $client = MemcachedCache::createConnection([]); $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); @@ -112,7 +112,7 @@ class MemcachedCacheTest extends CacheTestCase $this->markTestSkipped('Memcached::HAVE_JSON required'); } - new MemcachedCache(MemcachedCache::createConnection(array(), array('serializer' => 'json'))); + new MemcachedCache(MemcachedCache::createConnection([], ['serializer' => 'json'])); } /** @@ -121,54 +121,54 @@ class MemcachedCacheTest extends CacheTestCase public function testServersSetting($dsn, $host, $port) { $client1 = MemcachedCache::createConnection($dsn); - $client2 = MemcachedCache::createConnection(array($dsn)); - $client3 = MemcachedCache::createConnection(array(array($host, $port))); - $expect = array( + $client2 = MemcachedCache::createConnection([$dsn]); + $client3 = MemcachedCache::createConnection([[$host, $port]]); + $expect = [ 'host' => $host, 'port' => $port, - ); + ]; - $f = function ($s) { return array('host' => $s['host'], 'port' => $s['port']); }; - $this->assertSame(array($expect), array_map($f, $client1->getServerList())); - $this->assertSame(array($expect), array_map($f, $client2->getServerList())); - $this->assertSame(array($expect), array_map($f, $client3->getServerList())); + $f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; }; + $this->assertSame([$expect], array_map($f, $client1->getServerList())); + $this->assertSame([$expect], array_map($f, $client2->getServerList())); + $this->assertSame([$expect], array_map($f, $client3->getServerList())); } public function provideServersSetting() { - yield array( + yield [ 'memcached://127.0.0.1/50', '127.0.0.1', 11211, - ); - yield array( + ]; + yield [ 'memcached://localhost:11222?weight=25', 'localhost', 11222, - ); + ]; if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield array( + yield [ 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', 11211, - ); + ]; } - yield array( + yield [ 'memcached:///var/run/memcached.sock?weight=25', '/var/run/memcached.sock', 0, - ); - yield array( + ]; + yield [ 'memcached:///var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, - ); + ]; if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield array( + yield [ 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', 0, - ); + ]; } } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php index 43cadf9034..13865a6098 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php @@ -18,7 +18,7 @@ class MemcachedCacheTextModeTest extends MemcachedCacheTest { public function createSimpleCache($defaultLifetime = 0) { - $client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), array('binary_protocol' => false)); + $client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php index 7b760fd3bd..31f42c32b6 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php @@ -40,7 +40,7 @@ class NullCacheTest extends TestCase { $cache = $this->createCachePool(); - $keys = array('foo', 'bar', 'baz', 'biz'); + $keys = ['foo', 'bar', 'baz', 'biz']; $default = new \stdClass(); $items = $cache->getMultiple($keys, $default); @@ -75,7 +75,7 @@ class NullCacheTest extends TestCase public function testDeleteMultiple() { - $this->assertTrue($this->createCachePool()->deleteMultiple(array('key', 'foo', 'bar'))); + $this->assertTrue($this->createCachePool()->deleteMultiple(['key', 'foo', 'bar'])); } public function testSet() @@ -90,7 +90,7 @@ class NullCacheTest extends TestCase { $cache = $this->createCachePool(); - $this->assertFalse($cache->setMultiple(array('key' => 'val'))); + $this->assertFalse($cache->setMultiple(['key' => 'val'])); $this->assertNull($cache->get('key')); } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php index 158e2c8924..ce1a9ae4f8 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php @@ -32,7 +32,7 @@ class PdoDbalCacheTest extends CacheTestCase self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); - $pool = new PdoCache(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile))); + $pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); $pool->createTable(); } @@ -43,6 +43,6 @@ class PdoDbalCacheTest extends CacheTestCase public function createSimpleCache($defaultLifetime = 0) { - return new PdoCache(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile)), '', $defaultLifetime); + return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime); } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php index 651e06ebd7..1fe8363260 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php @@ -20,7 +20,7 @@ use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; */ class PhpArrayCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes', 'testDelete' => 'PhpArrayCache does no writes', @@ -45,7 +45,7 @@ class PhpArrayCacheTest extends CacheTestCase 'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.', 'testPrune' => 'PhpArrayCache just proxies', - ); + ]; protected static $file; @@ -68,22 +68,22 @@ class PhpArrayCacheTest extends CacheTestCase public function testStore() { - $arrayWithRefs = array(); + $arrayWithRefs = []; $arrayWithRefs[0] = 123; $arrayWithRefs[1] = &$arrayWithRefs[0]; - $object = (object) array( + $object = (object) [ 'foo' => 'bar', 'foo2' => 'bar2', - ); + ]; - $expected = array( + $expected = [ 'null' => null, 'serializedString' => serialize($object), 'arrayWithRefs' => $arrayWithRefs, 'object' => $object, - 'arrayWithObject' => array('bar' => $object), - ); + 'arrayWithObject' => ['bar' => $object], + ]; $cache = new PhpArrayCache(self::$file, new NullCache()); $cache->warmUp($expected); @@ -95,13 +95,13 @@ class PhpArrayCacheTest extends CacheTestCase public function testStoredFile() { - $expected = array( + $expected = [ 'integer' => 42, 'float' => 42.42, 'boolean' => true, - 'array_simple' => array('foo', 'bar'), - 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), - ); + 'array_simple' => ['foo', 'bar'], + 'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'], + ]; $cache = new PhpArrayCache(self::$file, new NullCache()); $cache->warmUp($expected); diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php index 4b6a94f709..abee5e7872 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php @@ -20,7 +20,7 @@ use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; */ class PhpArrayCacheWithFallbackTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testGetInvalidKeys' => 'PhpArrayCache does no validation', 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', @@ -32,7 +32,7 @@ class PhpArrayCacheWithFallbackTest extends CacheTestCase 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', 'testHasInvalidKeys' => 'PhpArrayCache does no validation', 'testPrune' => 'PhpArrayCache just proxies', - ); + ]; protected static $file; diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php index 7a402682ae..936f29a436 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Simple\PhpFilesCache; */ class PhpFilesCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.', - ); + ]; public function createSimpleCache() { diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php index 78582894fb..1bc75c9060 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Simple\Psr6Cache; */ class Psr6CacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testPrune' => 'Psr6Cache just proxies', - ); + ]; public function createSimpleCache($defaultLifetime = 0) { diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php index 3c903c8a9b..bda39d990b 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php @@ -19,6 +19,6 @@ class RedisArrayCacheTest extends AbstractRedisCacheTest if (!class_exists('RedisArray')) { self::markTestSkipped('The RedisArray class is required.'); } - self::$redis = new \RedisArray(array(getenv('REDIS_HOST')), array('lazy_connect' => true)); + self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php index d33421f9aa..407d916c73 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php @@ -33,13 +33,13 @@ class RedisCacheTest extends AbstractRedisCacheTest $redis = RedisCache::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); - $redis = RedisCache::createConnection('redis://'.$redisHost, array('timeout' => 3)); + $redis = RedisCache::createConnection('redis://'.$redisHost, ['timeout' => 3]); $this->assertEquals(3, $redis->getTimeout()); $redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); - $redis = RedisCache::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); + $redis = RedisCache::createConnection('redis://'.$redisHost, ['read_timeout' => 5]); $this->assertEquals(5, $redis->getReadTimeout()); } @@ -55,11 +55,11 @@ class RedisCacheTest extends AbstractRedisCacheTest public function provideFailedCreateConnection() { - return array( - array('redis://localhost:1234'), - array('redis://foo@localhost'), - array('redis://localhost/123'), - ); + return [ + ['redis://localhost:1234'], + ['redis://foo@localhost'], + ['redis://localhost/123'], + ]; } /** @@ -74,9 +74,9 @@ class RedisCacheTest extends AbstractRedisCacheTest public function provideInvalidCreateConnection() { - return array( - array('foo://localhost'), - array('redis://'), - ); + return [ + ['foo://localhost'], + ['redis://'], + ]; } } diff --git a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php index 535f93da4b..e684caf36e 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php @@ -19,9 +19,9 @@ use Symfony\Component\Cache\Simple\TraceableCache; */ class TraceableCacheTest extends CacheTestCase { - protected $skippedTests = array( + protected $skippedTests = [ 'testPrune' => 'TraceableCache just proxies', - ); + ]; public function createSimpleCache($defaultLifetime = 0) { @@ -37,7 +37,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[0]; $this->assertSame('get', $call->name); - $this->assertSame(array('k' => false), $call->result); + $this->assertSame(['k' => false], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); @@ -61,7 +61,7 @@ class TraceableCacheTest extends CacheTestCase { $pool = $this->createSimpleCache(); $pool->set('k1', 123); - $values = $pool->getMultiple(array('k0', 'k1')); + $values = $pool->getMultiple(['k0', 'k1']); foreach ($values as $value) { } $calls = $pool->getCalls(); @@ -69,7 +69,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[1]; $this->assertSame('getMultiple', $call->name); - $this->assertSame(array('k1' => true, 'k0' => false), $call->result); + $this->assertSame(['k1' => true, 'k0' => false], $call->result); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); @@ -84,7 +84,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[0]; $this->assertSame('has', $call->name); - $this->assertSame(array('k' => false), $call->result); + $this->assertSame(['k' => false], $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } @@ -99,7 +99,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[1]; $this->assertSame('has', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } @@ -113,7 +113,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[0]; $this->assertSame('delete', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -123,14 +123,14 @@ class TraceableCacheTest extends CacheTestCase public function testDeleteMultipleTrace() { $pool = $this->createSimpleCache(); - $arg = array('k0', 'k1'); + $arg = ['k0', 'k1']; $pool->deleteMultiple($arg); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteMultiple', $call->name); - $this->assertSame(array('keys' => $arg, 'result' => true), $call->result); + $this->assertSame(['keys' => $arg, 'result' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -146,7 +146,7 @@ class TraceableCacheTest extends CacheTestCase $call = $calls[0]; $this->assertSame('set', $call->name); - $this->assertSame(array('k' => true), $call->result); + $this->assertSame(['k' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); @@ -156,13 +156,13 @@ class TraceableCacheTest extends CacheTestCase public function testSetMultipleTrace() { $pool = $this->createSimpleCache(); - $pool->setMultiple(array('k' => 'foo')); + $pool->setMultiple(['k' => 'foo']); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('setMultiple', $call->name); - $this->assertSame(array('keys' => array('k'), 'result' => true), $call->result); + $this->assertSame(['keys' => ['k'], 'result' => true], $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index 441eddbde3..be576098e4 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -26,7 +26,7 @@ trait AbstractTrait private $namespace; private $namespaceVersion = ''; private $versioningIsEnabled = false; - private $deferred = array(); + private $deferred = []; /** * @var int|null The maximum length to enforce for identifiers or null when no limit applies @@ -93,7 +93,7 @@ trait AbstractTrait try { return $this->doHave($id); } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached', ['key' => $key, 'exception' => $e]); return false; } @@ -104,15 +104,15 @@ trait AbstractTrait */ public function clear() { - $this->deferred = array(); + $this->deferred = []; if ($cleared = $this->versioningIsEnabled) { $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5); try { - $cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0); + $cleared = $this->doSave(['@'.$this->namespace => $namespaceVersion], 0); } catch (\Exception $e) { $cleared = false; } - if ($cleared = true === $cleared || array() === $cleared) { + if ($cleared = true === $cleared || [] === $cleared) { $this->namespaceVersion = $namespaceVersion; } } @@ -120,7 +120,7 @@ trait AbstractTrait try { return $this->doClear($this->namespace) || $cleared; } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to clear the cache', array('exception' => $e)); + CacheItem::log($this->logger, 'Failed to clear the cache', ['exception' => $e]); return false; } @@ -131,7 +131,7 @@ trait AbstractTrait */ public function deleteItem($key) { - return $this->deleteItems(array($key)); + return $this->deleteItems([$key]); } /** @@ -139,7 +139,7 @@ trait AbstractTrait */ public function deleteItems(array $keys) { - $ids = array(); + $ids = []; foreach ($keys as $key) { $ids[$key] = $this->getId($key); @@ -159,12 +159,12 @@ trait AbstractTrait foreach ($ids as $key => $id) { try { $e = null; - if ($this->doDelete(array($id))) { + if ($this->doDelete([$id])) { continue; } } catch (\Exception $e) { } - CacheItem::log($this->logger, 'Failed to delete key "{key}"', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to delete key "{key}"', ['key' => $key, 'exception' => $e]); $ok = false; } @@ -237,12 +237,12 @@ trait AbstractTrait if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { $this->namespaceVersion = '1:'; try { - foreach ($this->doFetch(array('@'.$this->namespace)) as $v) { + foreach ($this->doFetch(['@'.$this->namespace]) as $v) { $this->namespaceVersion = $v; } if ('1:' === $this->namespaceVersion) { $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5); - $this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0); + $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0); } } catch (\Exception $e) { } diff --git a/src/Symfony/Component/Cache/Traits/ApcuTrait.php b/src/Symfony/Component/Cache/Traits/ApcuTrait.php index 5cfe21f799..df46b81171 100644 --- a/src/Symfony/Component/Cache/Traits/ApcuTrait.php +++ b/src/Symfony/Component/Cache/Traits/ApcuTrait.php @@ -52,7 +52,7 @@ trait ApcuTrait protected function doFetch(array $ids) { try { - foreach (apcu_fetch($ids, $ok) ?: array() as $k => $v) { + foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) { if (null !== $v || $ok) { yield $k => $v; } diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php index 88385ed480..0a60968e9b 100644 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php @@ -24,8 +24,8 @@ trait ArrayTrait use LoggerAwareTrait; private $storeSerialized; - private $values = array(); - private $expiries = array(); + private $values = []; + private $expiries = []; /** * Returns all cached values, with cache miss as null. @@ -52,7 +52,7 @@ trait ArrayTrait */ public function clear() { - $this->values = $this->expiries = array(); + $this->values = $this->expiries = []; return true; } @@ -92,7 +92,7 @@ trait ArrayTrait $isHit = false; } } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e)); + CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', ['key' => $key, 'exception' => $e]); $this->values[$key] = $value = null; $isHit = false; } diff --git a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php index 23974b3bc5..3e0dc86bd1 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php @@ -52,7 +52,7 @@ trait FilesystemTrait */ protected function doFetch(array $ids) { - $values = array(); + $values = []; $now = time(); foreach ($ids as $id) { @@ -83,7 +83,7 @@ trait FilesystemTrait { $file = $this->getFile($id); - return file_exists($file) && (@filemtime($file) > time() || $this->doFetch(array($id))); + return file_exists($file) && (@filemtime($file) > time() || $this->doFetch([$id])); } /** diff --git a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php b/src/Symfony/Component/Cache/Traits/MemcachedTrait.php index 8160f14116..6c2190ab75 100644 --- a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php +++ b/src/Symfony/Component/Cache/Traits/MemcachedTrait.php @@ -22,12 +22,12 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException; */ trait MemcachedTrait { - private static $defaultClientOptions = array( + private static $defaultClientOptions = [ 'persistent_id' => null, 'username' => null, 'password' => null, 'serializer' => 'php', - ); + ]; private $client; private $lazyClient; @@ -64,7 +64,7 @@ trait MemcachedTrait * * Examples for servers: * - 'memcached://user:pass@localhost?weight=33' - * - array(array('localhost', 11211, 33)) + * - [['localhost', 11211, 33]] * * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs * @param array $options An array of options @@ -73,10 +73,10 @@ trait MemcachedTrait * * @throws \ErrorException When invalid options or servers are provided */ - public static function createConnection($servers, array $options = array()) + public static function createConnection($servers, array $options = []) { if (\is_string($servers)) { - $servers = array($servers); + $servers = [$servers]; } elseif (!\is_array($servers)) { throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers))); } @@ -100,7 +100,7 @@ trait MemcachedTrait } $params = preg_replace_callback('#^memcached://(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) { if (!empty($m[1])) { - list($username, $password) = explode(':', $m[1], 2) + array(1 => null); + list($username, $password) = explode(':', $m[1], 2) + [1 => null]; } return 'file://'; @@ -115,18 +115,18 @@ trait MemcachedTrait $params['weight'] = $m[1]; $params['path'] = substr($params['path'], 0, -\strlen($m[0])); } - $params += array( + $params += [ 'host' => isset($params['host']) ? $params['host'] : $params['path'], 'port' => isset($params['host']) ? 11211 : null, 'weight' => 0, - ); + ]; if (isset($params['query'])) { parse_str($params['query'], $query); $params += $query; $options = $query + $options; } - $servers[$i] = array($params['host'], $params['port'], $params['weight']); + $servers[$i] = [$params['host'], $params['port'], $params['weight']]; } // set client's options @@ -154,12 +154,12 @@ trait MemcachedTrait // set client's servers, taking care of persistent connections if (!$client->isPristine()) { - $oldServers = array(); + $oldServers = []; foreach ($client->getServerList() as $server) { - $oldServers[] = array($server['host'], $server['port']); + $oldServers[] = [$server['host'], $server['port']]; } - $newServers = array(); + $newServers = []; foreach ($servers as $server) { if (1 < \count($server)) { $server = array_values($server); @@ -199,7 +199,7 @@ trait MemcachedTrait $lifetime += time(); } - $encodedValues = array(); + $encodedValues = []; foreach ($values as $key => $value) { $encodedValues[rawurlencode($key)] = $value; } @@ -218,7 +218,7 @@ trait MemcachedTrait $encodedResult = $this->checkResultCode($this->getClient()->getMulti($encodedIds)); - $result = array(); + $result = []; foreach ($encodedResult as $key => $value) { $result[rawurldecode($key)] = $value; } diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index a22714c80f..b190fef8b5 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -33,7 +33,7 @@ trait PdoTrait private $timeCol = 'item_time'; private $username = ''; private $password = ''; - private $connectionOptions = array(); + private $connectionOptions = []; private $namespace; private function init($connOrDsn, $namespace, $defaultLifetime, array $options) @@ -85,24 +85,24 @@ trait PdoTrait $conn = $this->getConnection(); if ($conn instanceof Connection) { - $types = array( + $types = [ 'mysql' => 'binary', 'sqlite' => 'text', 'pgsql' => 'string', 'oci' => 'string', 'sqlsrv' => 'string', - ); + ]; if (!isset($types[$this->driver])) { throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); } $schema = new Schema(); $table = $schema->createTable($this->table); - $table->addColumn($this->idCol, $types[$this->driver], array('length' => 255)); - $table->addColumn($this->dataCol, 'blob', array('length' => 16777215)); - $table->addColumn($this->lifetimeCol, 'integer', array('unsigned' => true, 'notnull' => false)); - $table->addColumn($this->timeCol, 'integer', array('unsigned' => true)); - $table->setPrimaryKey(array($this->idCol)); + $table->addColumn($this->idCol, $types[$this->driver], ['length' => 255]); + $table->addColumn($this->dataCol, 'blob', ['length' => 16777215]); + $table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]); + $table->addColumn($this->timeCol, 'integer', ['unsigned' => true]); + $table->setPrimaryKey([$this->idCol]); foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { $conn->exec($sql); @@ -166,7 +166,7 @@ trait PdoTrait protected function doFetch(array $ids) { $now = time(); - $expired = array(); + $expired = []; $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN ($sql)"; @@ -252,8 +252,8 @@ trait PdoTrait */ protected function doSave(array $values, $lifetime) { - $serialized = array(); - $failed = array(); + $serialized = []; + $failed = []; foreach ($values as $id => $value) { try { diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php index 65dded87c2..e96462abf7 100644 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php @@ -60,7 +60,7 @@ trait PhpArrayTrait // This file has been auto-generated by the Symfony Cache Component. -return array( +return [ EOF; @@ -97,7 +97,7 @@ EOF; $dump .= var_export($key, true).' => '.var_export($value, true).",\n"; } - $dump .= "\n);\n"; + $dump .= "\n];\n"; $dump = str_replace("' . \"\\0\" . '", "\0", $dump); $tmpFile = uniqid($this->file, true); @@ -116,7 +116,7 @@ EOF; */ public function clear() { - $this->values = array(); + $this->values = []; $cleared = @unlink($this->file) || !file_exists($this->file); @@ -132,7 +132,7 @@ EOF; $zmb = ini_set('zend.detect_unicode', 0); } try { - $this->values = file_exists($this->file) ? (include $this->file ?: array()) : array(); + $this->values = file_exists($this->file) ? (include $this->file ?: []) : []; } finally { if ($this->zendDetectUnicode) { ini_set('zend.detect_unicode', $zmb); diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php index b15ae8fce7..36c614fe65 100644 --- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php +++ b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php @@ -67,7 +67,7 @@ trait PhpFilesTrait */ protected function doFetch(array $ids) { - $values = array(); + $values = []; $now = time(); if ($this->zendDetectUnicode) { @@ -109,7 +109,7 @@ trait PhpFilesTrait */ protected function doHave($id) { - return (bool) $this->doFetch(array($id)); + return (bool) $this->doFetch([$id]); } /** @@ -118,7 +118,7 @@ trait PhpFilesTrait protected function doSave(array $values, $lifetime) { $ok = true; - $data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, ''); + $data = [$lifetime ? time() + $lifetime : PHP_INT_MAX, '']; $allowCompile = 'cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN); foreach ($values as $key => $value) { diff --git a/src/Symfony/Component/Cache/Traits/RedisProxy.php b/src/Symfony/Component/Cache/Traits/RedisProxy.php index b328f94cd8..98ea3aba76 100644 --- a/src/Symfony/Component/Cache/Traits/RedisProxy.php +++ b/src/Symfony/Component/Cache/Traits/RedisProxy.php @@ -32,7 +32,7 @@ class RedisProxy { $this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); - return \call_user_func_array(array($this->redis, $method), $args); + return \call_user_func_array([$this->redis, $method], $args); } public function hscan($strKey, &$iIterator, $strPattern = null, $iCount = null) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 77e3decf50..a637be8080 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -27,7 +27,7 @@ use Symfony\Component\Cache\Exception\InvalidArgumentException; */ trait RedisTrait { - private static $defaultConnectionOptions = array( + private static $defaultConnectionOptions = [ 'class' => null, 'persistent' => 0, 'persistent_id' => null, @@ -35,7 +35,7 @@ trait RedisTrait 'read_timeout' => 0, 'retry_interval' => 0, 'lazy' => false, - ); + ]; private $redis; /** @@ -73,7 +73,7 @@ trait RedisTrait * * @return \Redis|\Predis\Client According to the "class" option */ - public static function createConnection($dsn, array $options = array()) + public static function createConnection($dsn, array $options = []) { if (0 !== strpos($dsn, 'redis://')) { throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s does not start with "redis://"', $dsn)); @@ -100,11 +100,11 @@ trait RedisTrait } else { $scheme = 'unix'; } - $params += array( + $params += [ 'host' => isset($params['host']) ? $params['host'] : $params['path'], 'port' => isset($params['host']) ? 6379 : null, 'dbindex' => 0, - ); + ]; if (isset($params['query'])) { parse_str($params['query'], $query); $params += $query; @@ -172,7 +172,7 @@ trait RedisTrait if ($ids) { $values = $this->pipeline(function () use ($ids) { foreach ($ids as $id) { - yield 'get' => array($id); + yield 'get' => [$id]; } }); foreach ($values as $id => $v) { @@ -200,15 +200,15 @@ trait RedisTrait // This means old keys are not really removed until they expire and may need garbage collection. $cleared = true; - $hosts = array($this->redis); - $evalArgs = array(array($namespace), 0); + $hosts = [$this->redis]; + $evalArgs = [[$namespace], 0]; if ($this->redis instanceof \Predis\Client) { - $evalArgs = array(0, $namespace); + $evalArgs = [0, $namespace]; $connection = $this->redis->getConnection(); if ($connection instanceof PredisCluster) { - $hosts = array(); + $hosts = []; foreach ($connection as $c) { $hosts[] = new \Predis\Client($c); } @@ -216,7 +216,7 @@ trait RedisTrait return false; } } elseif ($this->redis instanceof \RedisArray) { - $hosts = array(); + $hosts = []; foreach ($this->redis->_hosts() as $host) { $hosts[] = $this->redis->_instance($host); } @@ -273,8 +273,8 @@ trait RedisTrait */ protected function doSave(array $values, $lifetime) { - $serialized = array(); - $failed = array(); + $serialized = []; + $failed = []; foreach ($values as $id => $value) { try { @@ -291,9 +291,9 @@ trait RedisTrait $results = $this->pipeline(function () use ($serialized, $lifetime) { foreach ($serialized as $id => $value) { if (0 >= $lifetime) { - yield 'set' => array($id, $value); + yield 'set' => [$id, $value]; } else { - yield 'setEx' => array($id, $lifetime, $value); + yield 'setEx' => [$id, $lifetime, $value]; } } }); @@ -308,24 +308,24 @@ trait RedisTrait private function pipeline(\Closure $generator) { - $ids = array(); + $ids = []; if ($this->redis instanceof \Predis\Client && !$this->redis->getConnection() instanceof ClusterInterface) { $results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) { foreach ($generator() as $command => $args) { - \call_user_func_array(array($redis, $command), $args); + \call_user_func_array([$redis, $command], $args); $ids[] = $args[0]; } }); } elseif ($this->redis instanceof \RedisArray) { - $connections = $results = $ids = array(); + $connections = $results = $ids = []; foreach ($generator() as $command => $args) { if (!isset($connections[$h = $this->redis->_target($args[0])])) { - $connections[$h] = array($this->redis->_instance($h), -1); + $connections[$h] = [$this->redis->_instance($h), -1]; $connections[$h][0]->multi(\Redis::PIPELINE); } - \call_user_func_array(array($connections[$h][0], $command), $args); - $results[] = array($h, ++$connections[$h][1]); + \call_user_func_array([$connections[$h][0], $command], $args); + $results[] = [$h, ++$connections[$h][1]]; $ids[] = $args[0]; } foreach ($connections as $h => $c) { @@ -338,15 +338,15 @@ trait RedisTrait // phpredis & predis don't support pipelining with RedisCluster // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining // see https://github.com/nrk/predis/issues/267#issuecomment-123781423 - $results = array(); + $results = []; foreach ($generator() as $command => $args) { - $results[] = \call_user_func_array(array($this->redis, $command), $args); + $results[] = \call_user_func_array([$this->redis, $command], $args); $ids[] = $args[0]; } } else { $this->redis->multi(\Redis::PIPELINE); foreach ($generator() as $command => $args) { - \call_user_func_array(array($this->redis, $command), $args); + \call_user_func_array([$this->redis, $command], $args); $ids[] = $args[0]; } $results = $this->redis->exec(); diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index 1c158c7d67..cf3d553d01 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -46,7 +46,7 @@ The edge case of defining just one value for nodes of type Enum is now allowed: $rootNode ->children() ->enumNode('variable') - ->values(array('value')) + ->values(['value']) ->end() ->end() ; diff --git a/src/Symfony/Component/Config/ConfigCache.php b/src/Symfony/Component/Config/ConfigCache.php index 1d00933c83..053059b8ab 100644 --- a/src/Symfony/Component/Config/ConfigCache.php +++ b/src/Symfony/Component/Config/ConfigCache.php @@ -35,9 +35,9 @@ class ConfigCache extends ResourceCheckerConfigCache { $this->debug = $debug; - $checkers = array(); + $checkers = []; if (true === $this->debug) { - $checkers = array(new SelfCheckingResourceChecker()); + $checkers = [new SelfCheckingResourceChecker()]; } parent::__construct($file, $checkers); diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 6ebb42e7c0..3ea4b1237d 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -22,8 +22,8 @@ use Symfony\Component\Config\Definition\Exception\UnsetKeyException; */ class ArrayNode extends BaseNode implements PrototypeNodeInterface { - protected $xmlRemappings = array(); - protected $children = array(); + protected $xmlRemappings = []; + protected $children = []; protected $allowFalse = false; protected $allowNewKeys = true; protected $addIfNotSet = false; @@ -56,7 +56,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface return $value; } - $normalized = array(); + $normalized = []; foreach ($value as $k => $v) { if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) { @@ -82,7 +82,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface /** * Sets the xml remappings that should be performed. * - * @param array $remappings An array of the form array(array(string, string)) + * @param array $remappings An array of the form [[string, string]] */ public function setXmlRemappings(array $remappings) { @@ -92,7 +92,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface /** * Gets the xml remappings that should be performed. * - * @return array an array of the form array(array(string, string)) + * @return array an array of the form [[string, string]] */ public function getXmlRemappings() { @@ -177,7 +177,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath())); } - $defaults = array(); + $defaults = []; foreach ($this->children as $name => $child) { if ($child->hasDefaultValue()) { $defaults[$name] = $child->getDefaultValue(); @@ -289,7 +289,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface $value = $this->remapXml($value); - $normalized = array(); + $normalized = []; foreach ($value as $name => $val) { if (isset($this->children[$name])) { try { diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index b82f1445c2..43c2b8b731 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -25,7 +25,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition protected $performDeepMerging = true; protected $ignoreExtraKeys = false; protected $removeExtraKeys = true; - protected $children = array(); + protected $children = []; protected $prototype; protected $atLeastOne = false; protected $allowNewKeys = true; @@ -43,8 +43,8 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition { parent::__construct($name, $parent); - $this->nullEquivalent = array(); - $this->trueEquivalent = array(); + $this->nullEquivalent = []; + $this->trueEquivalent = []; } /** @@ -214,15 +214,15 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition * to be the key of the particular item. For example, if "id" is the * "key", then: * - * array( - * array('id' => 'my_name', 'foo' => 'bar'), - * ); + * [ + * ['id' => 'my_name', 'foo' => 'bar'], + * ]; * * becomes * - * array( - * 'my_name' => array('foo' => 'bar'), - * ); + * [ + * 'my_name' => ['foo' => 'bar'], + * ]; * * If you'd like "'id' => 'my_name'" to still be present in the resulting * array, then you can set the second argument of this method to false. @@ -275,9 +275,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition { $this ->addDefaultsIfNotSet() - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => true]) ->beforeNormalization() ->ifArray() ->then(function ($v) { @@ -305,9 +305,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition { $this ->addDefaultsIfNotSet() - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => true]) ->children() ->booleanNode('enabled') ->defaultTrue() diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 7ba19515b8..05949d2b5a 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -144,7 +144,7 @@ class ExprBuilder public function castToArray() { $this->ifPart = function ($v) { return !\is_array($v); }; - $this->thenPart = function ($v) { return array($v); }; + $this->thenPart = function ($v) { return [$v]; }; return $this; } @@ -168,7 +168,7 @@ class ExprBuilder */ public function thenEmptyArray() { - $this->thenPart = function ($v) { return array(); }; + $this->thenPart = function ($v) { return []; }; return $this; } diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index 7d33404ad2..84ad86794c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -23,7 +23,7 @@ class NodeBuilder implements NodeParentInterface public function __construct() { - $this->nodeMapping = array( + $this->nodeMapping = [ 'variable' => __NAMESPACE__.'\\VariableNodeDefinition', 'scalar' => __NAMESPACE__.'\\ScalarNodeDefinition', 'boolean' => __NAMESPACE__.'\\BooleanNodeDefinition', @@ -31,7 +31,7 @@ class NodeBuilder implements NodeParentInterface 'float' => __NAMESPACE__.'\\FloatNodeDefinition', 'array' => __NAMESPACE__.'\\ArrayNodeDefinition', 'enum' => __NAMESPACE__.'\\EnumNodeDefinition', - ); + ]; } /** diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 2456ed9908..a771a43cd2 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -36,7 +36,7 @@ abstract class NodeDefinition implements NodeParentInterface protected $falseEquivalent = false; protected $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR; protected $parent; - protected $attributes = array(); + protected $attributes = []; public function __construct(?string $name, NodeParentInterface $parent = null) { diff --git a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php index 35e30487a6..d3cdca90df 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php @@ -19,8 +19,8 @@ namespace Symfony\Component\Config\Definition\Builder; class NormalizationBuilder { protected $node; - public $before = array(); - public $remappings = array(); + public $before = []; + public $remappings = []; public function __construct(NodeDefinition $node) { @@ -37,7 +37,7 @@ class NormalizationBuilder */ public function remap($key, $plural = null) { - $this->remappings[] = array($key, null === $plural ? $key.'s' : $plural); + $this->remappings[] = [$key, null === $plural ? $key.'s' : $plural]; return $this; } diff --git a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php index bb2b9eb339..4efc726c0c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php @@ -19,7 +19,7 @@ namespace Symfony\Component\Config\Definition\Builder; class ValidationBuilder { protected $node; - public $rules = array(); + public $rules = []; public function __construct(NodeDefinition $node) { diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index bea15e3ab9..7276b55a89 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -59,10 +59,10 @@ class XmlReferenceDumper } $rootName = str_replace('_', '-', $rootName); - $rootAttributes = array(); - $rootAttributeComments = array(); - $rootChildren = array(); - $rootComments = array(); + $rootAttributes = []; + $rootAttributeComments = []; + $rootChildren = []; + $rootComments = []; if ($node instanceof ArrayNode) { $children = $node->getChildren(); @@ -92,7 +92,7 @@ class XmlReferenceDumper if ($prototype instanceof PrototypedArrayNode) { $prototype->setName($key); - $children = array($key => $prototype); + $children = [$key => $prototype]; } elseif ($prototype instanceof ArrayNode) { $children = $prototype->getChildren(); } else { @@ -134,7 +134,7 @@ class XmlReferenceDumper $value = '%%%%not_defined%%%%'; // use a string which isn't used in the normal world // comments - $comments = array(); + $comments = []; if ($info = $child->getInfo()) { $comments[] = $info; } diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index b75a63d166..c97d23f198 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -71,7 +71,7 @@ class YamlReferenceDumper private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = false) { - $comments = array(); + $comments = []; $default = ''; $defaultArray = null; $children = null; @@ -237,6 +237,6 @@ class YamlReferenceDumper } $keyNode->setInfo($info); - return array($key => $keyNode); + return [$key => $keyNode]; } } diff --git a/src/Symfony/Component/Config/Definition/Processor.php b/src/Symfony/Component/Config/Definition/Processor.php index 4f4c66cadd..b6a3434113 100644 --- a/src/Symfony/Component/Config/Definition/Processor.php +++ b/src/Symfony/Component/Config/Definition/Processor.php @@ -30,7 +30,7 @@ class Processor */ public function process(NodeInterface $configTree, array $configs) { - $currentConfig = array(); + $currentConfig = []; foreach ($configs as $config) { $config = $configTree->normalize($config); $currentConfig = $configTree->merge($currentConfig, $config); @@ -88,12 +88,12 @@ class Processor if (isset($config[$key])) { if (\is_string($config[$key]) || !\is_int(key($config[$key]))) { // only one - return array($config[$key]); + return [$config[$key]]; } return $config[$key]; } - return array(); + return []; } } diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 4017b9d67c..4a3446f52f 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -27,12 +27,12 @@ class PrototypedArrayNode extends ArrayNode protected $keyAttribute; protected $removeKeyAttribute = false; protected $minNumberOfElements = 0; - protected $defaultValue = array(); + protected $defaultValue = []; protected $defaultChildren; /** * @var NodeInterface[] An array of the prototypes of the simplified value children */ - private $valuePrototypes = array(); + private $valuePrototypes = []; /** * Sets the minimum number of elements that a prototype based node must @@ -53,15 +53,15 @@ class PrototypedArrayNode extends ArrayNode * to be the key of the particular item. For example, if "id" is the * "key", then: * - * array( - * array('id' => 'my_name', 'foo' => 'bar'), - * ); + * [ + * ['id' => 'my_name', 'foo' => 'bar'], + * ]; * * becomes * - * array( - * 'my_name' => array('foo' => 'bar'), - * ); + * [ + * 'my_name' => ['foo' => 'bar'], + * ]; * * If you'd like "'id' => 'my_name'" to still be present in the resulting * array, then you can set the second argument of this method to false. @@ -114,10 +114,10 @@ class PrototypedArrayNode extends ArrayNode * * @param int|string|array|null $children The number of children|The child name|The children names to be added */ - public function setAddChildrenIfNoneSet($children = array('defaults')) + public function setAddChildrenIfNoneSet($children = ['defaults']) { if (null === $children) { - $this->defaultChildren = array('defaults'); + $this->defaultChildren = ['defaults']; } else { $this->defaultChildren = \is_int($children) && $children > 0 ? range(1, $children) : (array) $children; } @@ -132,8 +132,8 @@ class PrototypedArrayNode extends ArrayNode public function getDefaultValue() { if (null !== $this->defaultChildren) { - $default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : array(); - $defaults = array(); + $default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : []; + $defaults = []; foreach (array_values($this->defaultChildren) as $i => $name) { $defaults[null === $this->keyAttribute ? $i : $name] = $default; } @@ -226,7 +226,7 @@ class PrototypedArrayNode extends ArrayNode $value = $this->remapXml($value); $isAssoc = array_keys($value) !== range(0, \count($value) - 1); - $normalized = array(); + $normalized = []; foreach ($value as $k => $v) { if (null !== $this->keyAttribute && \is_array($v)) { if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) { @@ -243,7 +243,7 @@ class PrototypedArrayNode extends ArrayNode } // if only "value" is left - if (array_keys($v) === array('value')) { + if (array_keys($v) === ['value']) { $v = $v['value']; if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && array_key_exists('value', $children)) { $valuePrototype = current($this->valuePrototypes) ?: clone $children['value']; @@ -335,30 +335,30 @@ class PrototypedArrayNode extends ArrayNode * * For example, assume $this->keyAttribute is 'name' and the value array is as follows: * - * array( - * array( + * [ + * [ * 'name' => 'name001', * 'value' => 'value001' - * ) - * ) + * ] + * ] * * Now, the key is 0 and the child node is: * - * array( + * [ * 'name' => 'name001', * 'value' => 'value001' - * ) + * ] * * When normalizing the value array, the 'name' element will removed from the child node * and its value becomes the new key of the child node: * - * array( - * 'name001' => array('value' => 'value001') - * ) + * [ + * 'name001' => ['value' => 'value001'] + * ] * * Now only 'value' element is left in the child node which can be further simplified into a string: * - * array('name001' => 'value001') + * ['name001' => 'value001'] * * Now, the key becomes 'name001' and the child node becomes 'value001' and * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance. diff --git a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php b/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php index adebf160b8..633ec7e83f 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php @@ -80,7 +80,7 @@ class FileLoaderLoadException extends \Exception } if (\is_array($var)) { - $a = array(); + $a = []; foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); } diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 2b61db6d76..b80026ea07 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -25,7 +25,7 @@ class FileLocator implements FileLocatorInterface /** * @param string|string[] $paths A path or an array of paths where to look for resources */ - public function __construct($paths = array()) + public function __construct($paths = []) { $this->paths = (array) $paths; } @@ -41,7 +41,7 @@ class FileLocator implements FileLocatorInterface if ($this->isAbsolutePath($name)) { if (!file_exists($name)) { - throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name), 0, null, array($name)); + throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name), 0, null, [$name]); } return $name; @@ -54,7 +54,7 @@ class FileLocator implements FileLocatorInterface } $paths = array_unique($paths); - $filepaths = $notfound = array(); + $filepaths = $notfound = []; foreach ($paths as $path) { if (@file_exists($file = $path.\DIRECTORY_SEPARATOR.$name)) { diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index ab72e83a1e..3438277ce8 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -25,7 +25,7 @@ use Symfony\Component\Config\Resource\GlobResource; */ abstract class FileLoader extends Loader { - protected static $loading = array(); + protected static $loading = []; protected $locator; @@ -73,7 +73,7 @@ abstract class FileLoader extends Loader public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) { if (\is_string($resource) && \strlen($resource) !== $i = strcspn($resource, '*?{[')) { - $ret = array(); + $ret = []; $isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/'); foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath) as $path => $info) { if (null !== $res = $this->doImport($path, $type, $ignoreErrors, $sourceResource)) { @@ -113,7 +113,7 @@ abstract class FileLoader extends Loader throw $e; } - $resource = array(); + $resource = []; foreach ($e->getPaths() as $path) { $resource[] = new FileExistenceResource($path); } @@ -136,7 +136,7 @@ abstract class FileLoader extends Loader $resource = $loader->getLocator()->locate($resource, $this->currentDir, false); } - $resources = \is_array($resource) ? $resource : array($resource); + $resources = \is_array($resource) ? $resource : [$resource]; for ($i = 0; $i < $resourcesCount = \count($resources); ++$i) { if (isset(self::$loading[$resources[$i]])) { if ($i == $resourcesCount - 1) { diff --git a/src/Symfony/Component/Config/Loader/LoaderResolver.php b/src/Symfony/Component/Config/Loader/LoaderResolver.php index 9299bc000f..c99efda4fd 100644 --- a/src/Symfony/Component/Config/Loader/LoaderResolver.php +++ b/src/Symfony/Component/Config/Loader/LoaderResolver.php @@ -24,12 +24,12 @@ class LoaderResolver implements LoaderResolverInterface /** * @var LoaderInterface[] An array of LoaderInterface objects */ - private $loaders = array(); + private $loaders = []; /** * @param LoaderInterface[] $loaders An array of loaders */ - public function __construct(array $loaders = array()) + public function __construct(array $loaders = []) { foreach ($loaders as $loader) { $this->addLoader($loader); diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index 800e14c7ff..696c1de9b0 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -26,7 +26,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ private static $autoloadLevel = 0; private static $autoloadedClass; - private static $existsCache = array(); + private static $existsCache = []; /** * @param string $resource The fully-qualified class name @@ -103,7 +103,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ $this->isFresh(0); } - return serialize(array($this->resource, $this->exists)); + return serialize([$this->resource, $this->exists]); } /** @@ -124,10 +124,10 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ } $e = new \ReflectionException("Class $class not found"); $trace = $e->getTrace(); - $autoloadFrame = array( + $autoloadFrame = [ 'function' => 'spl_autoload_call', - 'args' => array($class), - ); + 'args' => [$class], + ]; $i = 1 + array_search($autoloadFrame, $trace, true); if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) { @@ -149,11 +149,11 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ return; } - $props = array( + $props = [ 'file' => $trace[$i]['file'], 'line' => $trace[$i]['line'], 'trace' => \array_slice($trace, 1 + $i), - ); + ]; foreach ($props as $p => $v) { $r = new \ReflectionProperty('Exception', $p); diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php index 9c170c0775..85ac555295 100644 --- a/src/Symfony/Component/Config/Resource/ComposerResource.php +++ b/src/Symfony/Component/Config/Resource/ComposerResource.php @@ -63,7 +63,7 @@ class ComposerResource implements SelfCheckingResourceInterface, \Serializable private static function refresh() { - self::$runtimeVendors = array(); + self::$runtimeVendors = []; foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index b6d1f9a24a..f8d5bff89e 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -42,7 +42,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable */ public function __toString() { - return md5(serialize(array($this->resource, $this->pattern))); + return md5(serialize([$this->resource, $this->pattern])); } /** @@ -106,7 +106,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable public function serialize() { - return serialize(array($this->resource, $this->pattern)); + return serialize([$this->resource, $this->pattern]); } public function unserialize($serialized) diff --git a/src/Symfony/Component/Config/Resource/FileExistenceResource.php b/src/Symfony/Component/Config/Resource/FileExistenceResource.php index a4eb8f3544..e1b7544505 100644 --- a/src/Symfony/Component/Config/Resource/FileExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/FileExistenceResource.php @@ -63,7 +63,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface, \Serializa */ public function serialize() { - return serialize(array($this->resource, $this->exists)); + return serialize([$this->resource, $this->exists]); } /** diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index a04cbf7be8..ac24a7f935 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -79,7 +79,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface, $this->hash = $this->computeHash(); } - return serialize(array($this->prefix, $this->pattern, $this->recursive, $this->hash)); + return serialize([$this->prefix, $this->pattern, $this->recursive, $this->hash]); } public function unserialize($serialized) diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php index bf8131d514..d0b70899b5 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheTest.php @@ -26,7 +26,7 @@ class ConfigCacheTest extends TestCase protected function tearDown() { - $files = array($this->cacheFile, $this->cacheFile.'.meta'); + $files = [$this->cacheFile, $this->cacheFile.'.meta']; foreach ($files as $file) { if (file_exists($file)) { @@ -52,7 +52,7 @@ class ConfigCacheTest extends TestCase $staleResource->setFresh(false); $cache = new ConfigCache($this->cacheFile, false); - $cache->write('', array($staleResource)); + $cache->write('', [$staleResource]); $this->assertTrue($cache->isFresh()); } @@ -63,7 +63,7 @@ class ConfigCacheTest extends TestCase public function testIsFreshWhenNoResourceProvided($debug) { $cache = new ConfigCache($this->cacheFile, $debug); - $cache->write('', array()); + $cache->write('', []); $this->assertTrue($cache->isFresh()); } @@ -73,7 +73,7 @@ class ConfigCacheTest extends TestCase $freshResource->setFresh(true); $cache = new ConfigCache($this->cacheFile, true); - $cache->write('', array($freshResource)); + $cache->write('', [$freshResource]); $this->assertTrue($cache->isFresh()); } @@ -84,16 +84,16 @@ class ConfigCacheTest extends TestCase $staleResource->setFresh(false); $cache = new ConfigCache($this->cacheFile, true); - $cache->write('', array($staleResource)); + $cache->write('', [$staleResource]); $this->assertFalse($cache->isFresh()); } public function debugModes() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 089cb56638..8f84cff388 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -34,19 +34,19 @@ class ArrayNodeTest extends TestCase public function testExceptionThrownOnUnrecognizedChild() { $node = new ArrayNode('root'); - $node->normalize(array('foo' => 'bar')); + $node->normalize(['foo' => 'bar']); } public function ignoreAndRemoveMatrixProvider() { $unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"'); - return array( - array(true, true, array(), 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'), - array(true, false, array('foo' => 'bar'), 'extra keys are not removed when ignoreExtraKeys second option is set to false'), - array(false, true, $unrecognizedOptionException), - array(false, false, $unrecognizedOptionException), - ); + return [ + [true, true, [], 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'], + [true, false, ['foo' => 'bar'], 'extra keys are not removed when ignoreExtraKeys second option is set to false'], + [false, true, $unrecognizedOptionException], + [false, false, $unrecognizedOptionException], + ]; } /** @@ -64,7 +64,7 @@ class ArrayNodeTest extends TestCase } $node = new ArrayNode('root'); $node->setIgnoreExtraKeys($ignore, $remove); - $result = $node->normalize(array('foo' => 'bar')); + $result = $node->normalize(['foo' => 'bar']); $this->assertSame($expected, $result, $message); } @@ -83,24 +83,24 @@ class ArrayNodeTest extends TestCase public function getPreNormalizationTests() { - return array( - array( - array('foo-bar' => 'foo'), - array('foo_bar' => 'foo'), - ), - array( - array('foo-bar_moo' => 'foo'), - array('foo-bar_moo' => 'foo'), - ), - array( - array('anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'), - array('anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'), - ), - array( - array('foo-bar' => null, 'foo_bar' => 'foo'), - array('foo-bar' => null, 'foo_bar' => 'foo'), - ), - ); + return [ + [ + ['foo-bar' => 'foo'], + ['foo_bar' => 'foo'], + ], + [ + ['foo-bar_moo' => 'foo'], + ['foo-bar_moo' => 'foo'], + ], + [ + ['anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'], + ['anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'], + ], + [ + ['foo-bar' => null, 'foo_bar' => 'foo'], + ['foo-bar' => null, 'foo_bar' => 'foo'], + ], + ]; } /** @@ -125,30 +125,30 @@ class ArrayNodeTest extends TestCase public function getZeroNamedNodeExamplesData() { - return array( - array( - array( - 0 => array( + return [ + [ + [ + 0 => [ 'name' => 'something', - ), - 5 => array( + ], + 5 => [ 0 => 'this won\'t work too', 'new_key' => 'some other value', - ), + ], 'string_key' => 'just value', - ), - array( - 0 => array( + ], + [ + 0 => [ 'name' => 'something', - ), - 5 => array( + ], + 5 => [ 0 => 'this won\'t work too', 'new_key' => 'some other value', - ), + ], 'string_key' => 'just value', - ), - ), - ); + ], + ], + ]; } /** @@ -172,12 +172,12 @@ class ArrayNodeTest extends TestCase public function getPreNormalizedNormalizedOrderedData() { - return array( - array( - array('2' => 'two', '1' => 'one', '3' => 'three'), - array('2' => 'two', '1' => 'one', '3' => 'three'), - ), - ); + return [ + [ + ['2' => 'two', '1' => 'one', '3' => 'three'], + ['2' => 'two', '1' => 'one', '3' => 'three'], + ], + ]; } /** @@ -238,13 +238,13 @@ class ArrayNodeTest extends TestCase }; $prevErrorHandler = set_error_handler($deprecationHandler); - $node->finalize(array()); + $node->finalize([]); restore_error_handler(); $this->assertFalse($deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); $prevErrorHandler = set_error_handler($deprecationHandler); - $node->finalize(array('foo' => array())); + $node->finalize(['foo' => []]); restore_error_handler(); $this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } diff --git a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php index ab1d316414..bfa2fd3e28 100644 --- a/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/BooleanNodeTest.php @@ -40,10 +40,10 @@ class BooleanNodeTest extends TestCase public function getValidValues() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } /** @@ -58,17 +58,17 @@ class BooleanNodeTest extends TestCase public function getInvalidValues() { - return array( - array(null), - array(''), - array('foo'), - array(0), - array(1), - array(0.0), - array(0.1), - array(array()), - array(array('foo' => 'bar')), - array(new \stdClass()), - ); + return [ + [null], + [''], + ['foo'], + [0], + [1], + [0.0], + [0.1], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php index 9c0aa0e11c..26f8586dcb 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php @@ -19,19 +19,19 @@ class EnumNodeDefinitionTest extends TestCase public function testWithOneValue() { $def = new EnumNodeDefinition('foo'); - $def->values(array('foo')); + $def->values(['foo']); $node = $def->getNode(); - $this->assertEquals(array('foo'), $node->getValues()); + $this->assertEquals(['foo'], $node->getValues()); } public function testWithOneDistinctValue() { $def = new EnumNodeDefinition('foo'); - $def->values(array('foo', 'foo')); + $def->values(['foo', 'foo']); $node = $def->getNode(); - $this->assertEquals(array('foo'), $node->getValues()); + $this->assertEquals(['foo'], $node->getValues()); } /** @@ -51,22 +51,22 @@ class EnumNodeDefinitionTest extends TestCase public function testWithNoValues() { $def = new EnumNodeDefinition('foo'); - $def->values(array()); + $def->values([]); } public function testGetNode() { $def = new EnumNodeDefinition('foo'); - $def->values(array('foo', 'bar')); + $def->values(['foo', 'bar']); $node = $def->getNode(); - $this->assertEquals(array('foo', 'bar'), $node->getValues()); + $this->assertEquals(['foo', 'bar'], $node->getValues()); } public function testSetDeprecated() { $def = new EnumNodeDefinition('foo'); - $def->values(array('foo', 'bar')); + $def->values(['foo', 'bar']); $def->setDeprecated('The "%path%" node is deprecated.'); $node = $def->getNode(); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index 99a1041376..191bf1c0b5 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -31,7 +31,7 @@ class ExprBuilderTest extends TestCase ->ifTrue() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key' => true)); + $this->assertFinalizedValueIs('new_value', $test, ['key' => true]); $test = $this->getTestBuilder() ->ifTrue(function ($v) { return true; }) @@ -58,7 +58,7 @@ class ExprBuilderTest extends TestCase ->ifString() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs(45, $test, array('key' => 45)); + $this->assertFinalizedValueIs(45, $test, ['key' => 45]); } public function testIfNullExpression() @@ -67,7 +67,7 @@ class ExprBuilderTest extends TestCase ->ifNull() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key' => null)); + $this->assertFinalizedValueIs('new_value', $test, ['key' => null]); $test = $this->getTestBuilder() ->ifNull() @@ -82,7 +82,7 @@ class ExprBuilderTest extends TestCase ->ifEmpty() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key' => array())); + $this->assertFinalizedValueIs('new_value', $test, ['key' => []]); $test = $this->getTestBuilder() ->ifEmpty() @@ -97,7 +97,7 @@ class ExprBuilderTest extends TestCase ->ifArray() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key' => array())); + $this->assertFinalizedValueIs('new_value', $test, ['key' => []]); $test = $this->getTestBuilder() ->ifArray() @@ -109,13 +109,13 @@ class ExprBuilderTest extends TestCase public function testIfInArrayExpression() { $test = $this->getTestBuilder() - ->ifInArray(array('foo', 'bar', 'value')) + ->ifInArray(['foo', 'bar', 'value']) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() - ->ifInArray(array('foo', 'bar')) + ->ifInArray(['foo', 'bar']) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('value', $test); @@ -124,13 +124,13 @@ class ExprBuilderTest extends TestCase public function testIfNotInArrayExpression() { $test = $this->getTestBuilder() - ->ifNotInArray(array('foo', 'bar')) + ->ifNotInArray(['foo', 'bar']) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); $test = $this->getTestBuilder() - ->ifNotInArray(array('foo', 'bar', 'value_from_config')) + ->ifNotInArray(['foo', 'bar', 'value_from_config']) ->then($this->returnClosure('new_value')) ->end(); $this->assertFinalizedValueIs('new_value', $test); @@ -142,7 +142,7 @@ class ExprBuilderTest extends TestCase ->ifString() ->thenEmptyArray() ->end(); - $this->assertFinalizedValueIs(array(), $test); + $this->assertFinalizedValueIs([], $test); } /** @@ -153,15 +153,15 @@ class ExprBuilderTest extends TestCase $test = $this->getTestBuilder() ->castToArray() ->end(); - $this->assertFinalizedValueIs($expectedValue, $test, array('key' => $configValue)); + $this->assertFinalizedValueIs($expectedValue, $test, ['key' => $configValue]); } public function castToArrayValues() { - yield array('value', array('value')); - yield array(-3.14, array(-3.14)); - yield array(null, array(null)); - yield array(array('value'), array('value')); + yield ['value', ['value']]; + yield [-3.14, [-3.14]]; + yield [null, [null]]; + yield [['value'], ['value']]; } /** @@ -182,7 +182,7 @@ class ExprBuilderTest extends TestCase ->ifString() ->thenUnset() ->end(); - $this->assertEquals(array(), $this->finalizeTestBuilder($test)); + $this->assertEquals([], $this->finalizeTestBuilder($test)); } /** @@ -227,7 +227,7 @@ class ExprBuilderTest extends TestCase * * @param TreeBuilder $testBuilder The tree builder to finalize * @param array $config The config you want to use for the finalization, if nothing provided - * a simple array('key'=>'value') will be used + * a simple ['key'=>'value'] will be used * * @return array The finalized config values */ @@ -238,7 +238,7 @@ class ExprBuilderTest extends TestCase ->end() ->end() ->buildTree() - ->finalize(null === $config ? array('key' => 'value') : $config) + ->finalize(null === $config ? ['key' => 'value'] : $config) ; } @@ -265,6 +265,6 @@ class ExprBuilderTest extends TestCase */ protected function assertFinalizedValueIs($value, $treeBuilder, $config = null) { - $this->assertEquals(array('key' => $value), $this->finalizeTestBuilder($treeBuilder, $config)); + $this->assertEquals(['key' => $value], $this->finalizeTestBuilder($treeBuilder, $config)); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php index 4b81628887..f95250b865 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php @@ -119,7 +119,7 @@ class TreeBuilderTest extends TestCase $builder = new TreeBuilder(); $builder->root('test') - ->example(array('key' => 'value')) + ->example(['key' => 'value']) ->children() ->node('child', 'variable')->info('child info')->defaultValue('default')->example('example') ->end() diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php index bf4db95f41..3cb9121ba6 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php @@ -28,12 +28,12 @@ class YamlReferenceDumperTest extends TestCase public function provideDumpAtPath() { - return array( - 'Regular node' => array('scalar_true', << ['scalar_true', << array('array', << ['array', << array('array.child2', << ['array.child2', << array('cms_pages.page', << ['cms_pages.page', << array('cms_pages.page.locale', << ['cms_pages.page.locale', <<assertSame('foo', $node->finalize('foo')); } @@ -28,18 +28,18 @@ class EnumNodeTest extends TestCase */ public function testConstructionWithNoValues() { - new EnumNode('foo', null, array()); + new EnumNode('foo', null, []); } public function testConstructionWithOneValue() { - $node = new EnumNode('foo', null, array('foo')); + $node = new EnumNode('foo', null, ['foo']); $this->assertSame('foo', $node->finalize('foo')); } public function testConstructionWithOneDistinctValue() { - $node = new EnumNode('foo', null, array('foo', 'foo')); + $node = new EnumNode('foo', null, ['foo', 'foo']); $this->assertSame('foo', $node->finalize('foo')); } @@ -55,7 +55,7 @@ class EnumNodeTest extends TestCase */ public function testFinalizeWithInvalidValue() { - $node = new EnumNode('foo', null, array('foo', 'bar')); + $node = new EnumNode('foo', null, ['foo', 'bar']); $node->finalize('foobar'); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/FinalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/FinalizationTest.php index d19fbd69ae..be68a27c69 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FinalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FinalizationTest.php @@ -42,27 +42,27 @@ class FinalizationTest extends TestCase ->buildTree() ; - $a = array( - 'level1' => array( - 'level2' => array( + $a = [ + 'level1' => [ + 'level2' => [ 'somevalue' => 'foo', 'anothervalue' => 'bar', - ), + ], 'level1_scalar' => 'foo', - ), - ); + ], + ]; - $b = array( - 'level1' => array( + $b = [ + 'level1' => [ 'level2' => false, - ), - ); + ], + ]; - $this->assertEquals(array( - 'level1' => array( + $this->assertEquals([ + 'level1' => [ 'level1_scalar' => 'foo', - ), - ), $this->process($tree, array($a, $b))); + ], + ], $this->process($tree, [$a, $b])); } protected function process(NodeInterface $tree, array $configs) diff --git a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index b7ec12fa73..8268fe83ba 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -40,16 +40,16 @@ class FloatNodeTest extends TestCase public function getValidValues() { - return array( - array(1798.0), - array(-678.987), - array(12.56E45), - array(0.0), + return [ + [1798.0], + [-678.987], + [12.56E45], + [0.0], // Integer are accepted too, they will be cast - array(17), - array(-10), - array(0), - ); + [17], + [-10], + [0], + ]; } /** @@ -64,15 +64,15 @@ class FloatNodeTest extends TestCase public function getInvalidValues() { - return array( - array(null), - array(''), - array('foo'), - array(true), - array(false), - array(array()), - array(array('foo' => 'bar')), - array(new \stdClass()), - ); + return [ + [null], + [''], + ['foo'], + [true], + [false], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php index 55e8a137b6..b4c17e1cb9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/IntegerNodeTest.php @@ -40,11 +40,11 @@ class IntegerNodeTest extends TestCase public function getValidValues() { - return array( - array(1798), - array(-678), - array(0), - ); + return [ + [1798], + [-678], + [0], + ]; } /** @@ -59,17 +59,17 @@ class IntegerNodeTest extends TestCase public function getInvalidValues() { - return array( - array(null), - array(''), - array('foo'), - array(true), - array(false), - array(0.0), - array(0.1), - array(array()), - array(array('foo' => 'bar')), - array(new \stdClass()), - ); + return [ + [null], + [''], + ['foo'], + [true], + [false], + [0.0], + [0.1], + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php index e539e25f3d..5d37e137bd 100644 --- a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php @@ -33,13 +33,13 @@ class MergeTest extends TestCase ->buildTree() ; - $a = array( + $a = [ 'foo' => 'bar', - ); + ]; - $b = array( + $b = [ 'foo' => 'moo', - ); + ]; $tree->merge($a, $b); } @@ -68,28 +68,28 @@ class MergeTest extends TestCase ->buildTree() ; - $a = array( + $a = [ 'foo' => 'bar', - 'unsettable' => array( + 'unsettable' => [ 'foo' => 'a', 'bar' => 'b', - ), + ], 'unsetted' => false, - ); + ]; - $b = array( + $b = [ 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, - 'unsetted' => array('a', 'b'), - ); + 'unsetted' => ['a', 'b'], + ]; - $this->assertEquals(array( + $this->assertEquals([ 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, - 'unsetted' => array('a', 'b'), - ), $tree->merge($a, $b)); + 'unsetted' => ['a', 'b'], + ], $tree->merge($a, $b)); } /** @@ -114,17 +114,17 @@ class MergeTest extends TestCase ->end() ->buildTree(); - $a = array( - 'test' => array( - 'a' => array('value' => 'foo'), - ), - ); + $a = [ + 'test' => [ + 'a' => ['value' => 'foo'], + ], + ]; - $b = array( - 'test' => array( - 'b' => array('value' => 'foo'), - ), - ); + $b = [ + 'test' => [ + 'b' => ['value' => 'foo'], + ], + ]; $tree->merge($a, $b); } @@ -148,24 +148,24 @@ class MergeTest extends TestCase ->buildTree() ; - $a = array( - 'no_deep_merging' => array( + $a = [ + 'no_deep_merging' => [ 'foo' => 'a', 'bar' => 'b', - ), - ); + ], + ]; - $b = array( - 'no_deep_merging' => array( + $b = [ + 'no_deep_merging' => [ 'c' => 'd', - ), - ); + ], + ]; - $this->assertEquals(array( - 'no_deep_merging' => array( + $this->assertEquals([ + 'no_deep_merging' => [ 'c' => 'd', - ), - ), $tree->merge($a, $b)); + ], + ], $tree->merge($a, $b)); } public function testPrototypeWithoutAKeyAttribute() @@ -183,14 +183,14 @@ class MergeTest extends TestCase ->buildTree() ; - $a = array( - 'append_elements' => array('a', 'b'), - ); + $a = [ + 'append_elements' => ['a', 'b'], + ]; - $b = array( - 'append_elements' => array('c', 'd'), - ); + $b = [ + 'append_elements' => ['c', 'd'], + ]; - $this->assertEquals(array('append_elements' => array('a', 'b', 'c', 'd')), $tree->merge($a, $b)); + $this->assertEquals(['append_elements' => ['a', 'b', 'c', 'd']], $tree->merge($a, $b)); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php index 3273c78668..d6544ccc81 100644 --- a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php @@ -30,7 +30,7 @@ class NormalizationTest extends TestCase ->node('encoders', 'array') ->useAttributeAsKey('class') ->prototype('array') - ->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return ['algorithm' => $v]; })->end() ->children() ->node('algorithm', 'scalar')->end() ->end() @@ -41,54 +41,54 @@ class NormalizationTest extends TestCase ->buildTree() ; - $normalized = array( - 'encoders' => array( - 'foo' => array('algorithm' => 'plaintext'), - ), - ); + $normalized = [ + 'encoders' => [ + 'foo' => ['algorithm' => 'plaintext'], + ], + ]; $this->assertNormalized($tree, $denormalized, $normalized); } public function getEncoderTests() { - $configs = array(); + $configs = []; // XML - $configs[] = array( - 'encoder' => array( - array('class' => 'foo', 'algorithm' => 'plaintext'), - ), - ); + $configs[] = [ + 'encoder' => [ + ['class' => 'foo', 'algorithm' => 'plaintext'], + ], + ]; // XML when only one element of this type - $configs[] = array( - 'encoder' => array('class' => 'foo', 'algorithm' => 'plaintext'), - ); + $configs[] = [ + 'encoder' => ['class' => 'foo', 'algorithm' => 'plaintext'], + ]; // YAML/PHP - $configs[] = array( - 'encoders' => array( - array('class' => 'foo', 'algorithm' => 'plaintext'), - ), - ); + $configs[] = [ + 'encoders' => [ + ['class' => 'foo', 'algorithm' => 'plaintext'], + ], + ]; // YAML/PHP - $configs[] = array( - 'encoders' => array( + $configs[] = [ + 'encoders' => [ 'foo' => 'plaintext', - ), - ); + ], + ]; // YAML/PHP - $configs[] = array( - 'encoders' => array( - 'foo' => array('algorithm' => 'plaintext'), - ), - ); + $configs[] = [ + 'encoders' => [ + 'foo' => ['algorithm' => 'plaintext'], + ], + ]; return array_map(function ($v) { - return array($v); + return [$v]; }, $configs); } @@ -114,28 +114,28 @@ class NormalizationTest extends TestCase ->buildTree() ; - $normalized = array('logout' => array('handlers' => array('a', 'b', 'c'))); + $normalized = ['logout' => ['handlers' => ['a', 'b', 'c']]]; $this->assertNormalized($tree, $denormalized, $normalized); } public function getAnonymousKeysTests() { - $configs = array(); + $configs = []; - $configs[] = array( - 'logout' => array( - 'handlers' => array('a', 'b', 'c'), - ), - ); + $configs[] = [ + 'logout' => [ + 'handlers' => ['a', 'b', 'c'], + ], + ]; - $configs[] = array( - 'logout' => array( - 'handler' => array('a', 'b', 'c'), - ), - ); + $configs[] = [ + 'logout' => [ + 'handler' => ['a', 'b', 'c'], + ], + ]; - return array_map(function ($v) { return array($v); }, $configs); + return array_map(function ($v) { return [$v]; }, $configs); } /** @@ -143,30 +143,30 @@ class NormalizationTest extends TestCase */ public function testNumericKeysAsAttributes($denormalized) { - $normalized = array( - 'thing' => array(42 => array('foo', 'bar'), 1337 => array('baz', 'qux')), - ); + $normalized = [ + 'thing' => [42 => ['foo', 'bar'], 1337 => ['baz', 'qux']], + ]; $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, $normalized); } public function getNumericKeysTests() { - $configs = array(); + $configs = []; - $configs[] = array( - 'thing' => array( - 42 => array('foo', 'bar'), 1337 => array('baz', 'qux'), - ), - ); + $configs[] = [ + 'thing' => [ + 42 => ['foo', 'bar'], 1337 => ['baz', 'qux'], + ], + ]; - $configs[] = array( - 'thing' => array( - array('foo', 'bar', 'id' => 42), array('baz', 'qux', 'id' => 1337), - ), - ); + $configs[] = [ + 'thing' => [ + ['foo', 'bar', 'id' => 42], ['baz', 'qux', 'id' => 1337], + ], + ]; - return array_map(function ($v) { return array($v); }, $configs); + return array_map(function ($v) { return [$v]; }, $configs); } /** @@ -175,13 +175,13 @@ class NormalizationTest extends TestCase */ public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet() { - $denormalized = array( - 'thing' => array( - array('foo', 'bar'), array('baz', 'qux'), - ), - ); + $denormalized = [ + 'thing' => [ + ['foo', 'bar'], ['baz', 'qux'], + ], + ]; - $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, array()); + $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, []); } public function testAssociativeArrayPreserveKeys() @@ -198,7 +198,7 @@ class NormalizationTest extends TestCase ->buildTree() ; - $data = array('first' => array('foo' => 'bar')); + $data = ['first' => ['foo' => 'bar']]; $this->assertNormalized($tree, $data, $data); } diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index 731d7af25f..6478bd12db 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -32,8 +32,8 @@ class PrototypedArrayNodeTest extends TestCase $node = new PrototypedArrayNode('root'); $prototype = new ArrayNode(null, $node); $node->setPrototype($prototype); - $node->setDefaultValue(array('test')); - $this->assertEquals(array('test'), $node->getDefaultValue()); + $node->setDefaultValue(['test']); + $this->assertEquals(['test'], $node->getDefaultValue()); } // a remapped key (e.g. "mapping" -> "mappings") should be unset after being used @@ -47,12 +47,12 @@ class PrototypedArrayNodeTest extends TestCase $prototype = new ScalarNode(null, $mappingsNode); $mappingsNode->setPrototype($prototype); - $remappings = array(); - $remappings[] = array('mapping', 'mappings'); + $remappings = []; + $remappings[] = ['mapping', 'mappings']; $node->setXmlRemappings($remappings); - $normalized = $node->normalize(array('mapping' => array('foo', 'bar'))); - $this->assertEquals(array('mappings' => array('foo', 'bar')), $normalized); + $normalized = $node->normalize(['mapping' => ['foo', 'bar']]); + $this->assertEquals(['mappings' => ['foo', 'bar']], $normalized); } /** @@ -66,12 +66,12 @@ class PrototypedArrayNodeTest extends TestCase * The above should finally be mapped to an array that looks like this * (because "id" is the key attribute). * - * array( - * 'things' => array( + * [ + * 'things' => [ * 'option1' => 'foo', * 'option2' => 'bar', - * ) - * ) + * ] + * ] */ public function testMappedAttributeKeyIsRemoved() { @@ -83,12 +83,12 @@ class PrototypedArrayNodeTest extends TestCase $prototype->addChild(new ScalarNode('foo')); $node->setPrototype($prototype); - $children = array(); - $children[] = array('id' => 'item_name', 'foo' => 'bar'); + $children = []; + $children[] = ['id' => 'item_name', 'foo' => 'bar']; $normalized = $node->normalize($children); - $expected = array(); - $expected['item_name'] = array('foo' => 'bar'); + $expected = []; + $expected['item_name'] = ['foo' => 'bar']; $this->assertEquals($expected, $normalized); } @@ -107,12 +107,12 @@ class PrototypedArrayNodeTest extends TestCase $prototype->addChild(new ScalarNode('id')); // the key attribute will remain $node->setPrototype($prototype); - $children = array(); - $children[] = array('id' => 'item_name', 'foo' => 'bar'); + $children = []; + $children[] = ['id' => 'item_name', 'foo' => 'bar']; $normalized = $node->normalize($children); - $expected = array(); - $expected['item_name'] = array('id' => 'item_name', 'foo' => 'bar'); + $expected = []; + $expected['item_name'] = ['id' => 'item_name', 'foo' => 'bar']; $this->assertEquals($expected, $normalized); } @@ -121,50 +121,50 @@ class PrototypedArrayNodeTest extends TestCase $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals([['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet(); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array('defaults' => array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals(['defaults' => ['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); $node->setAddChildrenIfNoneSet('defaultkey'); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals(['defaultkey' => ['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); - $node->setAddChildrenIfNoneSet(array('defaultkey')); + $node->setAddChildrenIfNoneSet(['defaultkey']); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array('defaultkey' => array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals(['defaultkey' => ['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setKeyAttribute('foobar'); - $node->setAddChildrenIfNoneSet(array('dk1', 'dk2')); + $node->setAddChildrenIfNoneSet(['dk1', 'dk2']); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array('dk1' => array('foo' => 'bar'), 'dk2' => array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals(['dk1' => ['foo' => 'bar'], 'dk2' => ['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); - $node->setAddChildrenIfNoneSet(array(5, 6)); + $node->setAddChildrenIfNoneSet([5, 6]); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array(0 => array('foo' => 'bar'), 1 => array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals([0 => ['foo' => 'bar'], 1 => ['foo' => 'bar']], $node->getDefaultValue()); $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(2); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array(array('foo' => 'bar'), array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals([['foo' => 'bar'], ['foo' => 'bar']], $node->getDefaultValue()); } public function testDefaultChildrenWinsOverDefaultValue() { $node = $this->getPrototypeNodeWithDefaultChildren(); $node->setAddChildrenIfNoneSet(); - $node->setDefaultValue(array('bar' => 'foo')); + $node->setDefaultValue(['bar' => 'foo']); $this->assertTrue($node->hasDefaultValue()); - $this->assertEquals(array(array('foo' => 'bar')), $node->getDefaultValue()); + $this->assertEquals([['foo' => 'bar']], $node->getDefaultValue()); } protected function getPrototypeNodeWithDefaultChildren() @@ -191,11 +191,11 @@ class PrototypedArrayNodeTest extends TestCase * The above should finally be mapped to an array that looks like this * (because "id" is the key attribute). * - * array( - * 'things' => array( + * [ + * 'things' => [ * 'option1' => 'value1' - * ) - * ) + * ] + * ] * * It's also possible to mix 'value-only' and 'non-value-only' elements in the array. * @@ -206,15 +206,15 @@ class PrototypedArrayNodeTest extends TestCase * * The above should finally be mapped to an array as follows * - * array( - * 'things' => array( + * [ + * 'things' => [ * 'option1' => 'value1', - * 'option2' => array( + * 'option2' => [ * 'value' => 'value2', * 'foo' => 'foo2' - * ) - * ) - * ) + * ] + * ] + * ] * * The 'value' element can also be ArrayNode: * @@ -229,14 +229,14 @@ class PrototypedArrayNodeTest extends TestCase * * The above should be finally be mapped to an array as follows * - * array( - * 'things' => array( - * 'option1' => array( + * [ + * 'things' => [ + * 'option1' => [ * 'foo' => 'foo1', * 'bar' => 'bar1' - * ) - * ) - * ) + * ] + * ] + * ] * * If using VariableNode for value node, it's also possible to mix different types of value nodes: * @@ -252,15 +252,15 @@ class PrototypedArrayNodeTest extends TestCase * * The above should be finally mapped to an array as follows * - * array( - * 'things' => array( - * 'option1' => array( + * [ + * 'things' => [ + * 'option1' => [ * 'foo' => 'foo1', * 'bar' => 'bar1' - * ), + * ], * 'option2' => 'value2' - * ) - * ) + * ] + * ] * * * @dataProvider getDataForKeyRemovedLeftValueOnly @@ -291,52 +291,52 @@ class PrototypedArrayNodeTest extends TestCase $variableValue = new VariableNode('value'); - return array( - array( + return [ + [ $scalarValue, - array( - array('id' => 'option1', 'value' => 'value1'), - ), - array('option1' => 'value1'), - ), + [ + ['id' => 'option1', 'value' => 'value1'], + ], + ['option1' => 'value1'], + ], - array( + [ $scalarValue, - array( - array('id' => 'option1', 'value' => 'value1'), - array('id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'), - ), - array( + [ + ['id' => 'option1', 'value' => 'value1'], + ['id' => 'option2', 'value' => 'value2', 'foo' => 'foo2'], + ], + [ 'option1' => 'value1', - 'option2' => array('value' => 'value2', 'foo' => 'foo2'), - ), - ), + 'option2' => ['value' => 'value2', 'foo' => 'foo2'], + ], + ], - array( + [ $arrayValue, - array( - array( + [ + [ 'id' => 'option1', - 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), - ), - ), - array( - 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), - ), - ), + 'value' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ], + [ + 'option1' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ], - array($variableValue, - array( - array( - 'id' => 'option1', 'value' => array('foo' => 'foo1', 'bar' => 'bar1'), - ), - array('id' => 'option2', 'value' => 'value2'), - ), - array( - 'option1' => array('foo' => 'foo1', 'bar' => 'bar1'), + [$variableValue, + [ + [ + 'id' => 'option1', 'value' => ['foo' => 'foo1', 'bar' => 'bar1'], + ], + ['id' => 'option2', 'value' => 'value2'], + ], + [ + 'option1' => ['foo' => 'foo1', 'bar' => 'bar1'], 'option2' => 'value2', - ), - ), - ); + ], + ], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php index 481ef3f496..ada5b04be9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ScalarNodeTest.php @@ -28,17 +28,17 @@ class ScalarNodeTest extends TestCase public function getValidValues() { - return array( - array(false), - array(true), - array(null), - array(''), - array('foo'), - array(0), - array(1), - array(0.0), - array(0.1), - ); + return [ + [false], + [true], + [null], + [''], + ['foo'], + [0], + [1], + [0.0], + [0.1], + ]; } public function testSetDeprecated() @@ -62,12 +62,12 @@ class ScalarNodeTest extends TestCase }; $prevErrorHandler = set_error_handler($deprecationHandler); - $node->finalize(array()); + $node->finalize([]); restore_error_handler(); $this->assertSame(0, $deprecationTriggered, '->finalize() should not trigger if the deprecated node is not set'); $prevErrorHandler = set_error_handler($deprecationHandler); - $node->finalize(array('foo' => '')); + $node->finalize(['foo' => '']); restore_error_handler(); $this->assertSame(1, $deprecationTriggered, '->finalize() should trigger if the deprecated node is set'); } @@ -84,11 +84,11 @@ class ScalarNodeTest extends TestCase public function getInvalidValues() { - return array( - array(array()), - array(array('foo' => 'bar')), - array(new \stdClass()), - ); + return [ + [[]], + [['foo' => 'bar']], + [new \stdClass()], + ]; } public function testNormalizeThrowsExceptionWithoutHint() @@ -102,7 +102,7 @@ class ScalarNodeTest extends TestCase $this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', 'Invalid type for path "test". Expected scalar, but got array.'); } - $node->normalize(array()); + $node->normalize([]); } public function testNormalizeThrowsExceptionWithErrorMessage() @@ -117,7 +117,7 @@ class ScalarNodeTest extends TestCase $this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', "Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\""); } - $node->normalize(array()); + $node->normalize([]); } /** @@ -135,15 +135,15 @@ class ScalarNodeTest extends TestCase public function getValidNonEmptyValues() { - return array( - array(false), - array(true), - array('foo'), - array(0), - array(1), - array(0.0), - array(0.1), - ); + return [ + [false], + [true], + ['foo'], + [0], + [1], + [0.0], + [0.1], + ]; } /** @@ -161,9 +161,9 @@ class ScalarNodeTest extends TestCase public function getEmptyValues() { - return array( - array(null), - array(''), - ); + return [ + [null], + [''], + ]; } } diff --git a/src/Symfony/Component/Config/Tests/FileLocatorTest.php b/src/Symfony/Component/Config/Tests/FileLocatorTest.php index 7120504131..0bd97f7d8a 100644 --- a/src/Symfony/Component/Config/Tests/FileLocatorTest.php +++ b/src/Symfony/Component/Config/Tests/FileLocatorTest.php @@ -21,7 +21,7 @@ class FileLocatorTest extends TestCase */ public function testIsAbsolutePath($path) { - $loader = new FileLocator(array()); + $loader = new FileLocator([]); $r = new \ReflectionObject($loader); $m = $r->getMethod('isAbsolutePath'); $m->setAccessible(true); @@ -31,14 +31,14 @@ class FileLocatorTest extends TestCase public function getIsAbsolutePathTests() { - return array( - array('/foo.xml'), - array('c:\\\\foo.xml'), - array('c:/foo.xml'), - array('\\server\\foo.xml'), - array('https://server/foo.xml'), - array('phar://server/foo.xml'), - ); + return [ + ['/foo.xml'], + ['c:\\\\foo.xml'], + ['c:/foo.xml'], + ['\\server\\foo.xml'], + ['https://server/foo.xml'], + ['phar://server/foo.xml'], + ]; } public function testLocate() @@ -63,16 +63,16 @@ class FileLocatorTest extends TestCase '->locate() returns the absolute filename if the file exists in one of the paths given in the constructor' ); - $loader = new FileLocator(array(__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again')); + $loader = new FileLocator([__DIR__.'/Fixtures', __DIR__.'/Fixtures/Again']); $this->assertEquals( - array(__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'), + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], $loader->locate('foo.xml', __DIR__, false), '->locate() returns an array of absolute filenames' ); $this->assertEquals( - array(__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'), + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); @@ -80,7 +80,7 @@ class FileLocatorTest extends TestCase $loader = new FileLocator(__DIR__.'/Fixtures/Again'); $this->assertEquals( - array(__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'), + [__DIR__.'/Fixtures'.\DIRECTORY_SEPARATOR.'foo.xml', __DIR__.'/Fixtures/Again'.\DIRECTORY_SEPARATOR.'foo.xml'], $loader->locate('foo.xml', __DIR__.'/Fixtures', false), '->locate() returns an array of absolute filenames' ); @@ -92,7 +92,7 @@ class FileLocatorTest extends TestCase */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExists() { - $loader = new FileLocator(array(__DIR__.'/Fixtures')); + $loader = new FileLocator([__DIR__.'/Fixtures']); $loader->locate('foobar.xml', __DIR__); } @@ -102,7 +102,7 @@ class FileLocatorTest extends TestCase */ public function testLocateThrowsAnExceptionIfTheFileDoesNotExistsInAbsolutePath() { - $loader = new FileLocator(array(__DIR__.'/Fixtures')); + $loader = new FileLocator([__DIR__.'/Fixtures']); $loader->locate(__DIR__.'/Fixtures/foobar.xml', __DIR__); } @@ -113,7 +113,7 @@ class FileLocatorTest extends TestCase */ public function testLocateEmpty() { - $loader = new FileLocator(array(__DIR__.'/Fixtures')); + $loader = new FileLocator([__DIR__.'/Fixtures']); $loader->locate(null, __DIR__); } diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php index d44b67cc19..3f02700a18 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php @@ -32,14 +32,14 @@ class ExampleConfiguration implements ConfigurationInterface ->scalarNode('scalar_true')->defaultTrue()->end() ->scalarNode('scalar_false')->defaultFalse()->end() ->scalarNode('scalar_default')->defaultValue('default')->end() - ->scalarNode('scalar_array_empty')->defaultValue(array())->end() - ->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end() + ->scalarNode('scalar_array_empty')->defaultValue([])->end() + ->scalarNode('scalar_array_defaults')->defaultValue(['elem1', 'elem2'])->end() ->scalarNode('scalar_required')->isRequired()->end() ->scalarNode('scalar_deprecated')->setDeprecated()->end() ->scalarNode('scalar_deprecated_with_message')->setDeprecated('Deprecation custom message for "%node%" at "%path%"')->end() ->scalarNode('node_with_a_looong_name')->end() - ->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end() - ->enumNode('enum')->values(array('this', 'that'))->end() + ->enumNode('enum_with_default')->values(['this', 'that'])->defaultValue('this')->end() + ->enumNode('enum')->values(['this', 'that'])->end() ->arrayNode('array') ->info('some info') ->canBeUnset() diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php index 3f4b21f34b..6e2a6ba222 100644 --- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php @@ -36,12 +36,12 @@ class DelegatingLoaderTest extends TestCase { $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); - $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); + $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); - $loader = new DelegatingLoader(new LoaderResolver(array($loader1))); + $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); } @@ -50,7 +50,7 @@ class DelegatingLoaderTest extends TestCase $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); $loader->expects($this->once())->method('load'); - $resolver = new LoaderResolver(array($loader)); + $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); $loader->load('foo'); @@ -63,7 +63,7 @@ class DelegatingLoaderTest extends TestCase { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(false)); - $resolver = new LoaderResolver(array($loader)); + $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); $loader->load('foo'); diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index f8409df9d7..b59ace46f9 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -24,11 +24,11 @@ class FileLoaderTest extends TestCase $locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls( - array('path/to/file1'), // Default - array('path/to/file1', 'path/to/file2'), // First is imported - array('path/to/file1', 'path/to/file2'), // Second is imported - array('path/to/file1'), // Exception - array('path/to/file1', 'path/to/file2') // Exception + ['path/to/file1'], // Default + ['path/to/file1', 'path/to/file2'], // First is imported + ['path/to/file1', 'path/to/file2'], // Second is imported + ['path/to/file1'], // Exception + ['path/to/file1', 'path/to/file2'] // Exception )); $fileLoader = new TestFileLoader($locatorMock); @@ -38,7 +38,7 @@ class FileLoaderTest extends TestCase $additionalLoader = new TestFileLoader($locatorMockForAdditionalLoader); $additionalLoader->setCurrentDir('.'); - $fileLoader->setResolver($loaderResolver = new LoaderResolver(array($fileLoader, $additionalLoader))); + $fileLoader->setResolver($loaderResolver = new LoaderResolver([$fileLoader, $additionalLoader])); // Default case $this->assertSame('path/to/file1', $fileLoader->import('my_resource')); @@ -118,7 +118,7 @@ class TestFileLoader extends FileLoader public function clearLoading() { - self::$loading = array(); + self::$loading = []; } public function setSupports($supports) diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php index 0bf56b610e..487dc43adc 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php @@ -18,22 +18,22 @@ class LoaderResolverTest extends TestCase { public function testConstructor() { - $resolver = new LoaderResolver(array( + $resolver = new LoaderResolver([ $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(), - )); + ]); - $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); + $this->assertEquals([$loader], $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument'); } public function testResolve() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $resolver = new LoaderResolver(array($loader)); + $resolver = new LoaderResolver([$loader]); $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); - $resolver = new LoaderResolver(array($loader)); + $resolver = new LoaderResolver([$loader]); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); } @@ -42,6 +42,6 @@ class LoaderResolverTest extends TestCase $resolver = new LoaderResolver(); $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock()); - $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader'); + $this->assertEquals([$loader], $resolver->getLoaders(), 'addLoader() adds a loader'); } } diff --git a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php index cf20e43b50..85f6c02ee6 100644 --- a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php @@ -178,6 +178,6 @@ class DirectoryResourceTest extends TestCase $resourceA = new DirectoryResource($this->directory, '/.xml$/'); $resourceB = new DirectoryResource($this->directory, '/.yaml$/'); - $this->assertCount(2, array_unique(array($resourceA, $resourceB))); + $this->assertCount(2, array_unique([$resourceA, $resourceB])); } } diff --git a/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php index c66770c305..cfbfd2b455 100644 --- a/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php @@ -33,7 +33,7 @@ class GlobResourceTest extends TestCase $paths = iterator_to_array($resource); $file = $dir.'/Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; - $this->assertEquals(array($file => new \SplFileInfo($file)), $paths); + $this->assertEquals([$file => new \SplFileInfo($file)], $paths); $this->assertInstanceOf('SplFileInfo', current($paths)); $this->assertSame($dir, $resource->getPrefix()); @@ -42,7 +42,7 @@ class GlobResourceTest extends TestCase $paths = iterator_to_array($resource); $file = $dir.\DIRECTORY_SEPARATOR.'Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php'; - $this->assertEquals(array($file => $file), $paths); + $this->assertEquals([$file => $file], $paths); $this->assertInstanceOf('SplFileInfo', current($paths)); $this->assertSame($dir, $resource->getPrefix()); } diff --git a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php index bb29ac02a4..a2c2eeb811 100644 --- a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php +++ b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php @@ -27,7 +27,7 @@ class ResourceCheckerConfigCacheTest extends TestCase protected function tearDown() { - $files = array($this->cacheFile, "{$this->cacheFile}.meta"); + $files = [$this->cacheFile, "{$this->cacheFile}.meta"]; foreach ($files as $file) { if (file_exists($file)) { @@ -52,7 +52,7 @@ class ResourceCheckerConfigCacheTest extends TestCase It does not matter if you provide checkers or not. */ unlink($this->cacheFile); // remove tempnam() side effect - $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); $this->assertFalse($cache->isFresh()); } @@ -67,7 +67,7 @@ class ResourceCheckerConfigCacheTest extends TestCase public function testCacheIsFreshIfEmptyCheckerIteratorProvided() { - $cache = new ResourceCheckerConfigCache($this->cacheFile, new \ArrayIterator(array())); + $cache = new ResourceCheckerConfigCache($this->cacheFile, new \ArrayIterator([])); $this->assertTrue($cache->isFresh()); } @@ -75,7 +75,7 @@ class ResourceCheckerConfigCacheTest extends TestCase { /* As in the previous test, but this time we have a resource. */ $cache = new ResourceCheckerConfigCache($this->cacheFile); - $cache->write('', array(new ResourceStub())); + $cache->write('', [new ResourceStub()]); $this->assertTrue($cache->isFresh()); // no (matching) ResourceChecker passed } @@ -92,8 +92,8 @@ class ResourceCheckerConfigCacheTest extends TestCase ->method('isFresh') ->willReturn(true); - $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); - $cache->write('', array(new ResourceStub())); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('', [new ResourceStub()]); $this->assertTrue($cache->isFresh()); } @@ -110,8 +110,8 @@ class ResourceCheckerConfigCacheTest extends TestCase ->method('isFresh') ->willReturn(false); - $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); - $cache->write('', array(new ResourceStub())); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('', [new ResourceStub()]); $this->assertFalse($cache->isFresh()); } @@ -119,8 +119,8 @@ class ResourceCheckerConfigCacheTest extends TestCase public function testCacheIsNotFreshWhenUnserializeFails() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); - $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); - $cache->write('foo', array(new FileResource(__FILE__))); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('foo', [new FileResource(__FILE__)]); $metaFile = "{$this->cacheFile}.meta"; file_put_contents($metaFile, str_replace('FileResource', 'ClassNotHere', file_get_contents($metaFile))); @@ -139,8 +139,8 @@ class ResourceCheckerConfigCacheTest extends TestCase public function testCacheIsNotFreshIfNotExistsMetaFile() { $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock(); - $cache = new ResourceCheckerConfigCache($this->cacheFile, array($checker)); - $cache->write('foo', array(new FileResource(__FILE__))); + $cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]); + $cache->write('foo', [new FileResource(__FILE__)]); $metaFile = "{$this->cacheFile}.meta"; unlink($metaFile); diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 10b4a7a9b4..0a6637f785 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -52,14 +52,14 @@ class XmlUtilsTest extends TestCase $mock->expects($this->exactly(2))->method('validate')->will($this->onConsecutiveCalls(false, true)); try { - XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate')); + XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate']); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertRegExp('/The XML file ".+" is not valid\./', $e->getMessage()); } - $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate'))); - $this->assertSame(array(), libxml_get_errors()); + $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', [$mock, 'validate'])); + $this->assertSame([], libxml_get_errors()); } /** @@ -73,16 +73,16 @@ class XmlUtilsTest extends TestCase $mock = $this->getMockBuilder(__NAMESPACE__.'\Validator')->getMock(); $mock->expects($this->once())->method('validate')->willReturn(false); - XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), array($mock, 'validate')); + XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), [$mock, 'validate']); } public function testLoadFileWithInternalErrorsEnabled() { $internalErrors = libxml_use_internal_errors(true); - $this->assertSame(array(), libxml_get_errors()); + $this->assertSame([], libxml_get_errors()); $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); - $this->assertSame(array(), libxml_get_errors()); + $this->assertSame([], libxml_get_errors()); libxml_clear_errors(); libxml_use_internal_errors($internalErrors); @@ -101,25 +101,25 @@ class XmlUtilsTest extends TestCase public function getDataForConvertDomToArray() { - return array( - array(null, ''), - array('bar', 'bar'), - array(array('bar' => 'foobar'), '', true), - array(array('foo' => null), ''), - array(array('foo' => 'bar'), 'bar'), - array(array('foo' => array('foo' => 'bar')), ''), - array(array('foo' => array('foo' => 0)), '0'), - array(array('foo' => array('foo' => 'bar')), 'bar'), - array(array('foo' => array('foo' => 'bar', 'value' => 'text')), 'text'), - array(array('foo' => array('attr' => 'bar', 'foo' => 'text')), 'text'), - array(array('foo' => array('bar', 'text')), 'bartext'), - array(array('foo' => array(array('foo' => 'bar'), array('foo' => 'text'))), ''), - array(array('foo' => array('foo' => array('bar', 'text'))), 'text'), - array(array('foo' => 'bar'), 'bar'), - array(array('foo' => 'text'), 'text'), - array(array('foo' => array('bar' => 'bar', 'value' => 'text')), 'text', false, false), - array(array('attr' => 1, 'b' => 'hello'), 'hello2', true), - ); + return [ + [null, ''], + ['bar', 'bar'], + [['bar' => 'foobar'], '', true], + [['foo' => null], ''], + [['foo' => 'bar'], 'bar'], + [['foo' => ['foo' => 'bar']], ''], + [['foo' => ['foo' => 0]], '0'], + [['foo' => ['foo' => 'bar']], 'bar'], + [['foo' => ['foo' => 'bar', 'value' => 'text']], 'text'], + [['foo' => ['attr' => 'bar', 'foo' => 'text']], 'text'], + [['foo' => ['bar', 'text']], 'bartext'], + [['foo' => [['foo' => 'bar'], ['foo' => 'text']]], ''], + [['foo' => ['foo' => ['bar', 'text']]], 'text'], + [['foo' => 'bar'], 'bar'], + [['foo' => 'text'], 'text'], + [['foo' => ['bar' => 'bar', 'value' => 'text']], 'text', false, false], + [['attr' => 1, 'b' => 'hello'], 'hello2', true], + ]; } /** @@ -132,34 +132,34 @@ class XmlUtilsTest extends TestCase public function getDataForPhpize() { - return array( - array('', ''), - array(null, 'null'), - array(true, 'true'), - array(false, 'false'), - array(null, 'Null'), - array(true, 'True'), - array(false, 'False'), - array(0, '0'), - array(1, '1'), - array(-1, '-1'), - array(0777, '0777'), - array(255, '0xFF'), - array(100.0, '1e2'), - array(-120.0, '-1.2E2'), - array(-10100.1, '-10100.1'), - array('-10,100.1', '-10,100.1'), - array('1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'), - array('1,2,3,4', '1,2,3,4'), - array('11,22,33,44', '11,22,33,44'), - array('11,222,333,4', '11,222,333,4'), - array('1,222,333,444', '1,222,333,444'), - array('11,222,333,444', '11,222,333,444'), - array('111,222,333,444', '111,222,333,444'), - array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'), - array('foo', 'foo'), - array(6, '0b0110'), - ); + return [ + ['', ''], + [null, 'null'], + [true, 'true'], + [false, 'false'], + [null, 'Null'], + [true, 'True'], + [false, 'False'], + [0, '0'], + [1, '1'], + [-1, '-1'], + [0777, '0777'], + [255, '0xFF'], + [100.0, '1e2'], + [-120.0, '-1.2E2'], + [-10100.1, '-10100.1'], + ['-10,100.1', '-10,100.1'], + ['1234 5678 9101 1121 3141', '1234 5678 9101 1121 3141'], + ['1,2,3,4', '1,2,3,4'], + ['11,22,33,44', '11,22,33,44'], + ['11,222,333,4', '11,222,333,4'], + ['1,222,333,444', '1,222,333,444'], + ['11,222,333,444', '11,222,333,444'], + ['111,222,333,444', '111,222,333,444'], + ['1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'], + ['foo', 'foo'], + [6, '0b0110'], + ]; } public function testLoadEmptyXmlFile() diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 3cc3279867..ee8ced0cce 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -158,9 +158,9 @@ class XmlUtils { $prefix = (string) $element->prefix; $empty = true; - $config = array(); + $config = []; foreach ($element->attributes as $name => $node) { - if ($checkPrefix && !\in_array((string) $node->prefix, array('', $prefix), true)) { + if ($checkPrefix && !\in_array((string) $node->prefix, ['', $prefix], true)) { continue; } $config[$name] = static::phpize($node->value); @@ -182,7 +182,7 @@ class XmlUtils $key = $node->localName; if (isset($config[$key])) { if (!\is_array($config[$key]) || !\is_int(key($config[$key]))) { - $config[$key] = array($config[$key]); + $config[$key] = [$config[$key]]; } $config[$key][] = $value; } else { @@ -249,7 +249,7 @@ class XmlUtils protected static function getXmlErrors($internalErrors) { - $errors = array(); + $errors = []; foreach (libxml_get_errors() as $error) { $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index f58ae2337f..18d683de93 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -37,7 +37,7 @@ class Command private $application; private $name; private $processTitle; - private $aliases = array(); + private $aliases = []; private $definition; private $hidden = false; private $help; @@ -46,8 +46,8 @@ class Command private $applicationDefinitionMerged = false; private $applicationDefinitionMergedWithArgs = false; private $code; - private $synopsis = array(); - private $usages = array(); + private $synopsis = []; + private $usages = []; private $helperSet; /** @@ -527,14 +527,14 @@ class Command $name = $this->name; $isSingleCommand = $this->application && $this->application->isSingleCommand(); - $placeholders = array( + $placeholders = [ '%command.name%', '%command.full_name%', - ); - $replacements = array( + ]; + $replacements = [ $name, $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name, - ); + ]; return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription()); } diff --git a/src/Symfony/Component/Console/Command/HelpCommand.php b/src/Symfony/Component/Console/Command/HelpCommand.php index 1e20b008aa..23847766b6 100644 --- a/src/Symfony/Component/Console/Command/HelpCommand.php +++ b/src/Symfony/Component/Console/Command/HelpCommand.php @@ -35,11 +35,11 @@ class HelpCommand extends Command $this ->setName('help') - ->setDefinition(array( + ->setDefinition([ new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), - )) + ]) ->setDescription('Displays help for a command') ->setHelp(<<<'EOF' The %command.name% command displays help for a given command: @@ -71,10 +71,10 @@ EOF } $helper = new DescriptorHelper(); - $helper->describe($output, $this->command, array( + $helper->describe($output, $this->command, [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), - )); + ]); $this->command = null; } diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index 5d932338c6..7259b1263b 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -69,11 +69,11 @@ EOF protected function execute(InputInterface $input, OutputInterface $output) { $helper = new DescriptorHelper(); - $helper->describe($output, $this->getApplication(), array( + $helper->describe($output, $this->getApplication(), [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'namespace' => $input->getArgument('namespace'), - )); + ]); } /** @@ -81,10 +81,10 @@ EOF */ private function createDefinition() { - return new InputDefinition(array( + return new InputDefinition([ new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'), - )); + ]); } } diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 5d34778621..03bfcfcda4 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -92,12 +92,12 @@ class ApplicationDescription private function inspectApplication() { - $this->commands = array(); - $this->namespaces = array(); + $this->commands = []; + $this->namespaces = []; $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); foreach ($this->sortCommands($all) as $namespace => $commands) { - $names = array(); + $names = []; /** @var Command $command */ foreach ($commands as $name => $command) { @@ -114,14 +114,14 @@ class ApplicationDescription $names[] = $name; } - $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names); + $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names]; } } private function sortCommands(array $commands): array { - $namespacedCommands = array(); - $globalCommands = array(); + $namespacedCommands = []; + $globalCommands = []; foreach ($commands as $name => $command) { $key = $this->application->extractNamespace($name, 1); if (!$key) { diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php index 151d84f72a..d25a708e47 100644 --- a/src/Symfony/Component/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php @@ -34,7 +34,7 @@ abstract class Descriptor implements DescriptorInterface /** * {@inheritdoc} */ - public function describe(OutputInterface $output, $object, array $options = array()) + public function describe(OutputInterface $output, $object, array $options = []) { $this->output = $output; @@ -75,33 +75,33 @@ abstract class Descriptor implements DescriptorInterface * * @return string|mixed */ - abstract protected function describeInputArgument(InputArgument $argument, array $options = array()); + abstract protected function describeInputArgument(InputArgument $argument, array $options = []); /** * Describes an InputOption instance. * * @return string|mixed */ - abstract protected function describeInputOption(InputOption $option, array $options = array()); + abstract protected function describeInputOption(InputOption $option, array $options = []); /** * Describes an InputDefinition instance. * * @return string|mixed */ - abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array()); + abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []); /** * Describes a Command instance. * * @return string|mixed */ - abstract protected function describeCommand(Command $command, array $options = array()); + abstract protected function describeCommand(Command $command, array $options = []); /** * Describes an Application instance. * * @return string|mixed */ - abstract protected function describeApplication(Application $application, array $options = array()); + abstract protected function describeApplication(Application $application, array $options = []); } diff --git a/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php b/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php index 5d3339a9e6..fbc07df879 100644 --- a/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php +++ b/src/Symfony/Component/Console/Descriptor/DescriptorInterface.php @@ -27,5 +27,5 @@ interface DescriptorInterface * @param object $object * @param array $options */ - public function describe(OutputInterface $output, $object, array $options = array()); + public function describe(OutputInterface $output, $object, array $options = []); } diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index f60323becd..197b843d4b 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -29,7 +29,7 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeData($this->getInputArgumentData($argument), $options); } @@ -37,7 +37,7 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputOption(InputOption $option, array $options = array()) + protected function describeInputOption(InputOption $option, array $options = []) { $this->writeData($this->getInputOptionData($option), $options); } @@ -45,7 +45,7 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeData($this->getInputDefinitionData($definition), $options); } @@ -53,7 +53,7 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeCommand(Command $command, array $options = array()) + protected function describeCommand(Command $command, array $options = []) { $this->writeData($this->getCommandData($command), $options); } @@ -61,17 +61,17 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeApplication(Application $application, array $options = array()) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace, true); - $commands = array(); + $commands = []; foreach ($description->getCommands() as $command) { $commands[] = $this->getCommandData($command); } - $data = array(); + $data = []; if ('UNKNOWN' !== $application->getName()) { $data['application']['name'] = $application->getName(); if ('UNKNOWN' !== $application->getVersion()) { @@ -105,13 +105,13 @@ class JsonDescriptor extends Descriptor */ private function getInputArgumentData(InputArgument $argument) { - return array( + return [ 'name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), - ); + ]; } /** @@ -119,7 +119,7 @@ class JsonDescriptor extends Descriptor */ private function getInputOptionData(InputOption $option) { - return array( + return [ 'name' => '--'.$option->getName(), 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', 'accept_value' => $option->acceptValue(), @@ -127,7 +127,7 @@ class JsonDescriptor extends Descriptor 'is_multiple' => $option->isArray(), 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), - ); + ]; } /** @@ -135,17 +135,17 @@ class JsonDescriptor extends Descriptor */ private function getInputDefinitionData(InputDefinition $definition) { - $inputArguments = array(); + $inputArguments = []; foreach ($definition->getArguments() as $name => $argument) { $inputArguments[$name] = $this->getInputArgumentData($argument); } - $inputOptions = array(); + $inputOptions = []; foreach ($definition->getOptions() as $name => $option) { $inputOptions[$name] = $this->getInputOptionData($option); } - return array('arguments' => $inputArguments, 'options' => $inputOptions); + return ['arguments' => $inputArguments, 'options' => $inputOptions]; } /** @@ -156,13 +156,13 @@ class JsonDescriptor extends Descriptor $command->getSynopsis(); $command->mergeApplicationDefinition(false); - return array( + return [ 'name' => $command->getName(), - 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), + 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), 'hidden' => $command->isHidden(), - ); + ]; } } diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index 6d8399f922..e6245778f5 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -31,7 +31,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - public function describe(OutputInterface $output, $object, array $options = array()) + public function describe(OutputInterface $output, $object, array $options = []) { $decorated = $output->isDecorated(); $output->setDecorated(false); @@ -52,7 +52,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->write( '#### `'.($argument->getName() ?: '')."`\n\n" @@ -66,7 +66,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputOption(InputOption $option, array $options = array()) + protected function describeInputOption(InputOption $option, array $options = []) { $name = '--'.$option->getName(); if ($option->getShortcut()) { @@ -86,7 +86,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { if ($showArguments = \count($definition->getArguments()) > 0) { $this->write('### Arguments'); @@ -112,7 +112,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeCommand(Command $command, array $options = array()) + protected function describeCommand(Command $command, array $options = []) { $command->getSynopsis(); $command->mergeApplicationDefinition(false); @@ -122,7 +122,7 @@ class MarkdownDescriptor extends Descriptor .str_repeat('-', Helper::strlen($command->getName()) + 2)."\n\n" .($command->getDescription() ? $command->getDescription()."\n\n" : '') .'### Usage'."\n\n" - .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) { + .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) { return $carry.'* `'.$usage.'`'."\n"; }) ); @@ -141,7 +141,7 @@ class MarkdownDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeApplication(Application $application, array $options = array()) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace); diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 9361b10986..24fcf00a18 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -31,7 +31,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) + protected function describeInputArgument(InputArgument $argument, array $options = []) { if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) { $default = sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault())); @@ -54,7 +54,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputOption(InputOption $option, array $options = array()) + protected function describeInputOption(InputOption $option, array $options = []) { if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) { $default = sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault())); @@ -71,7 +71,7 @@ class TextDescriptor extends Descriptor } } - $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option)); + $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions([$option]); $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value) @@ -92,7 +92,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions()); foreach ($definition->getArguments() as $argument) { @@ -103,7 +103,7 @@ class TextDescriptor extends Descriptor $this->writeText('Arguments:', $options); $this->writeText("\n"); foreach ($definition->getArguments() as $argument) { - $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth))); + $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth])); $this->writeText("\n"); } } @@ -113,7 +113,7 @@ class TextDescriptor extends Descriptor } if ($definition->getOptions()) { - $laterOptions = array(); + $laterOptions = []; $this->writeText('Options:', $options); foreach ($definition->getOptions() as $option) { @@ -122,11 +122,11 @@ class TextDescriptor extends Descriptor continue; } $this->writeText("\n"); - $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth))); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); } foreach ($laterOptions as $option) { $this->writeText("\n"); - $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth))); + $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth])); } } } @@ -134,7 +134,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeCommand(Command $command, array $options = array()) + protected function describeCommand(Command $command, array $options = []) { $command->getSynopsis(true); $command->getSynopsis(false); @@ -148,7 +148,7 @@ class TextDescriptor extends Descriptor } $this->writeText('Usage:', $options); - foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) { + foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) { $this->writeText("\n"); $this->writeText(' '.OutputFormatter::escape($usage), $options); } @@ -174,7 +174,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeApplication(Application $application, array $options = array()) + protected function describeApplication(Application $application, array $options = []) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; $description = new ApplicationDescription($application, $describedNamespace); @@ -250,7 +250,7 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - private function writeText($content, array $options = array()) + private function writeText($content, array $options = []) { $this->write( isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, @@ -302,7 +302,7 @@ class TextDescriptor extends Descriptor */ private function getColumnWidth(array $commands): int { - $widths = array(); + $widths = []; foreach ($commands as $command) { if ($command instanceof Command) { diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php index d0c6abddb4..f5202a330b 100644 --- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -64,7 +64,7 @@ class XmlDescriptor extends Descriptor $commandXML->appendChild($usagesXML = $dom->createElement('usages')); - foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) { + foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) { $usagesXML->appendChild($dom->createElement('usage', $usage)); } @@ -130,7 +130,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) + protected function describeInputArgument(InputArgument $argument, array $options = []) { $this->writeDocument($this->getInputArgumentDocument($argument)); } @@ -138,7 +138,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputOption(InputOption $option, array $options = array()) + protected function describeInputOption(InputOption $option, array $options = []) { $this->writeDocument($this->getInputOptionDocument($option)); } @@ -146,7 +146,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { $this->writeDocument($this->getInputDefinitionDocument($definition)); } @@ -154,7 +154,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeCommand(Command $command, array $options = array()) + protected function describeCommand(Command $command, array $options = []) { $this->writeDocument($this->getCommandDocument($command)); } @@ -162,7 +162,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeApplication(Application $application, array $options = array()) + protected function describeApplication(Application $application, array $options = []) { $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null)); } @@ -200,7 +200,7 @@ class XmlDescriptor extends Descriptor $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); - $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); + $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? [var_export($argument->getDefault(), true)] : ($argument->getDefault() ? [$argument->getDefault()] : [])); foreach ($defaults as $default) { $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); $defaultXML->appendChild($dom->createTextNode($default)); @@ -229,7 +229,7 @@ class XmlDescriptor extends Descriptor $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); if ($option->acceptValue()) { - $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); + $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? [var_export($option->getDefault(), true)] : ($option->getDefault() ? [$option->getDefault()] : [])); $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); if (!empty($defaults)) { diff --git a/src/Symfony/Component/Console/EventListener/ErrorListener.php b/src/Symfony/Component/Console/EventListener/ErrorListener.php index 909d6ea3a1..212ad1d96f 100644 --- a/src/Symfony/Component/Console/EventListener/ErrorListener.php +++ b/src/Symfony/Component/Console/EventListener/ErrorListener.php @@ -40,10 +40,10 @@ class ErrorListener implements EventSubscriberInterface $error = $event->getError(); if (!$inputString = $this->getInputString($event)) { - return $this->logger->error('An error occurred while using the console. Message: "{message}"', array('exception' => $error, 'message' => $error->getMessage())); + return $this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]); } - $this->logger->error('Error thrown while running command "{command}". Message: "{message}"', array('exception' => $error, 'command' => $inputString, 'message' => $error->getMessage())); + $this->logger->error('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]); } public function onConsoleTerminate(ConsoleTerminateEvent $event) @@ -59,18 +59,18 @@ class ErrorListener implements EventSubscriberInterface } if (!$inputString = $this->getInputString($event)) { - return $this->logger->debug('The console exited with code "{code}"', array('code' => $exitCode)); + return $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]); } - $this->logger->debug('Command "{command}" exited with code "{code}"', array('command' => $inputString, 'code' => $exitCode)); + $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]); } public static function getSubscribedEvents() { - return array( - ConsoleEvents::ERROR => array('onConsoleError', -128), - ConsoleEvents::TERMINATE => array('onConsoleTerminate', -128), - ); + return [ + ConsoleEvents::ERROR => ['onConsoleError', -128], + ConsoleEvents::TERMINATE => ['onConsoleTerminate', -128], + ]; } private static function getInputString(ConsoleEvent $event) @@ -80,7 +80,7 @@ class ErrorListener implements EventSubscriberInterface if (method_exists($input, '__toString')) { if ($commandName) { - return str_replace(array("'$commandName'", "\"$commandName\""), $commandName, (string) $input); + return str_replace(["'$commandName'", "\"$commandName\""], $commandName, (string) $input); } return (string) $input; diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php index 9e7283c2f8..5066649912 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php @@ -36,7 +36,7 @@ class OutputFormatterStyleStack */ public function reset() { - $this->styles = array(); + $this->styles = []; } /** diff --git a/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php b/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php index f5393edee3..16d117553a 100644 --- a/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php +++ b/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php @@ -20,8 +20,8 @@ namespace Symfony\Component\Console\Helper; */ class DebugFormatterHelper extends Helper { - private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'); - private $started = array(); + private $colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default']; + private $started = []; private $count = -1; /** @@ -35,7 +35,7 @@ class DebugFormatterHelper extends Helper */ public function start($id, $message, $prefix = 'RUN') { - $this->started[$id] = array('border' => ++$this->count % \count($this->colors)); + $this->started[$id] = ['border' => ++$this->count % \count($this->colors)]; return sprintf("%s %s %s\n", $this->getBorder($id), $prefix, $message); } diff --git a/src/Symfony/Component/Console/Helper/DescriptorHelper.php b/src/Symfony/Component/Console/Helper/DescriptorHelper.php index 54d3b1afc1..f8a3847b49 100644 --- a/src/Symfony/Component/Console/Helper/DescriptorHelper.php +++ b/src/Symfony/Component/Console/Helper/DescriptorHelper.php @@ -29,7 +29,7 @@ class DescriptorHelper extends Helper /** * @var DescriptorInterface[] */ - private $descriptors = array(); + private $descriptors = []; public function __construct() { @@ -54,12 +54,12 @@ class DescriptorHelper extends Helper * * @throws InvalidArgumentException when the given format is not supported */ - public function describe(OutputInterface $output, $object, array $options = array()) + public function describe(OutputInterface $output, $object, array $options = []) { - $options = array_merge(array( + $options = array_merge([ 'raw_text' => false, 'format' => 'txt', - ), $options); + ], $options); if (!isset($this->descriptors[$options['format']])) { throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); diff --git a/src/Symfony/Component/Console/Helper/FormatterHelper.php b/src/Symfony/Component/Console/Helper/FormatterHelper.php index 79ab2849e5..4ad63856dc 100644 --- a/src/Symfony/Component/Console/Helper/FormatterHelper.php +++ b/src/Symfony/Component/Console/Helper/FormatterHelper.php @@ -46,18 +46,18 @@ class FormatterHelper extends Helper public function formatBlock($messages, $style, $large = false) { if (!\is_array($messages)) { - $messages = array($messages); + $messages = [$messages]; } $len = 0; - $lines = array(); + $lines = []; foreach ($messages as $message) { $message = OutputFormatter::escape($message); $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); $len = max($this->strlen($message) + ($large ? 4 : 2), $len); } - $messages = $large ? array(str_repeat(' ', $len)) : array(); + $messages = $large ? [str_repeat(' ', $len)] : []; for ($i = 0; isset($lines[$i]); ++$i) { $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i])); } diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php index 5090185526..0ddddf6bc5 100644 --- a/src/Symfony/Component/Console/Helper/Helper.php +++ b/src/Symfony/Component/Console/Helper/Helper.php @@ -74,17 +74,17 @@ abstract class Helper implements HelperInterface public static function formatTime($secs) { - static $timeFormats = array( - array(0, '< 1 sec'), - array(1, '1 sec'), - array(2, 'secs', 1), - array(60, '1 min'), - array(120, 'mins', 60), - array(3600, '1 hr'), - array(7200, 'hrs', 3600), - array(86400, '1 day'), - array(172800, 'days', 86400), - ); + static $timeFormats = [ + [0, '< 1 sec'], + [1, '1 sec'], + [2, 'secs', 1], + [60, '1 min'], + [120, 'mins', 60], + [3600, '1 hr'], + [7200, 'hrs', 3600], + [86400, '1 day'], + [172800, 'days', 86400], + ]; foreach ($timeFormats as $index => $format) { if ($secs >= $format[0]) { diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php index 4c44b05f56..c73fecd475 100644 --- a/src/Symfony/Component/Console/Helper/HelperSet.php +++ b/src/Symfony/Component/Console/Helper/HelperSet.php @@ -24,13 +24,13 @@ class HelperSet implements \IteratorAggregate /** * @var Helper[] */ - private $helpers = array(); + private $helpers = []; private $command; /** * @param Helper[] $helpers An array of helper */ - public function __construct(array $helpers = array()) + public function __construct(array $helpers = []) { foreach ($helpers as $alias => $helper) { $this->set($helper, \is_int($alias) ? null : $alias); diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index bef87d2b6a..b68d9fe389 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -39,7 +39,7 @@ final class ProgressBar private $stepWidth; private $percent = 0.0; private $formatLineCount; - private $messages = array(); + private $messages = []; private $overwrite = true; private $terminal; private $firstRun = true; @@ -419,8 +419,8 @@ final class ProgressBar private static function initPlaceholderFormatters(): array { - return array( - 'bar' => function (ProgressBar $bar, OutputInterface $output) { + return [ + 'bar' => function (self $bar, OutputInterface $output) { $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth()); $display = str_repeat($bar->getBarCharacter(), $completeBars); if ($completeBars < $bar->getBarWidth()) { @@ -430,10 +430,10 @@ final class ProgressBar return $display; }, - 'elapsed' => function (ProgressBar $bar) { + 'elapsed' => function (self $bar) { return Helper::formatTime(time() - $bar->getStartTime()); }, - 'remaining' => function (ProgressBar $bar) { + 'remaining' => function (self $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); } @@ -446,7 +446,7 @@ final class ProgressBar return Helper::formatTime($remaining); }, - 'estimated' => function (ProgressBar $bar) { + 'estimated' => function (self $bar) { if (!$bar->getMaxSteps()) { throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); } @@ -459,24 +459,24 @@ final class ProgressBar return Helper::formatTime($estimated); }, - 'memory' => function (ProgressBar $bar) { + 'memory' => function (self $bar) { return Helper::formatMemory(memory_get_usage(true)); }, - 'current' => function (ProgressBar $bar) { + 'current' => function (self $bar) { return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); }, - 'max' => function (ProgressBar $bar) { + 'max' => function (self $bar) { return $bar->getMaxSteps(); }, - 'percent' => function (ProgressBar $bar) { + 'percent' => function (self $bar) { return floor($bar->getProgressPercent() * 100); }, - ); + ]; } private static function initFormats(): array { - return array( + return [ 'normal' => ' %current%/%max% [%bar%] %percent:3s%%', 'normal_nomax' => ' %current% [%bar%]', @@ -488,7 +488,7 @@ final class ProgressBar 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%', 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%', - ); + ]; } private function buildLine(): string diff --git a/src/Symfony/Component/Console/Helper/ProgressIndicator.php b/src/Symfony/Component/Console/Helper/ProgressIndicator.php index 4c12c326cb..301be27ea4 100644 --- a/src/Symfony/Component/Console/Helper/ProgressIndicator.php +++ b/src/Symfony/Component/Console/Helper/ProgressIndicator.php @@ -48,7 +48,7 @@ class ProgressIndicator } if (null === $indicatorValues) { - $indicatorValues = array('-', '\\', '|', '/'); + $indicatorValues = ['-', '\\', '|', '/']; } $indicatorValues = array_values($indicatorValues); @@ -237,25 +237,25 @@ class ProgressIndicator private static function initPlaceholderFormatters() { - return array( - 'indicator' => function (ProgressIndicator $indicator) { + return [ + 'indicator' => function (self $indicator) { return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)]; }, - 'message' => function (ProgressIndicator $indicator) { + 'message' => function (self $indicator) { return $indicator->message; }, - 'elapsed' => function (ProgressIndicator $indicator) { + 'elapsed' => function (self $indicator) { return Helper::formatTime(time() - $indicator->startTime); }, 'memory' => function () { return Helper::formatMemory(memory_get_usage(true)); }, - ); + ]; } private static function initFormats() { - return array( + return [ 'normal' => ' %indicator% %message%', 'normal_no_ansi' => ' %message%', @@ -264,6 +264,6 @@ class ProgressIndicator 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)', 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)', - ); + ]; } } diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 59d3dab536..575c53458d 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -155,7 +155,7 @@ class QuestionHelper extends Helper $message = $question->getQuestion(); if ($question instanceof ChoiceQuestion) { - $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices()))); + $maxWidth = max(array_map([$this, 'strlen'], array_keys($question->getChoices()))); $messages = (array) $question->getQuestion(); foreach ($question->getChoices() as $key => $value) { @@ -407,7 +407,7 @@ class QuestionHelper extends Helper if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; - foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { + foreach (['bash', 'zsh', 'ksh', 'csh'] as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; diff --git a/src/Symfony/Component/Console/Helper/TableSeparator.php b/src/Symfony/Component/Console/Helper/TableSeparator.php index c7b8dc9c22..e541c53156 100644 --- a/src/Symfony/Component/Console/Helper/TableSeparator.php +++ b/src/Symfony/Component/Console/Helper/TableSeparator.php @@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Helper; */ class TableSeparator extends TableCell { - public function __construct(array $options = array()) + public function __construct(array $options = []) { parent::__construct('', $options); } diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index e0ad2acae4..7612060f0f 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -411,7 +411,7 @@ class TableStyle */ public function setPadType($padType) { - if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) { + if (!\in_array($padType, [STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH], true)) { throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); } diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index b459ae4749..85ff6f91d8 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -169,7 +169,7 @@ class ArgvInput extends Input // if input is expecting another argument, add it if ($this->definition->hasArgument($c)) { $arg = $this->definition->getArgument($c); - $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token; + $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token; // if last argument isArray(), append token to last argument } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { @@ -224,11 +224,11 @@ class ArgvInput extends Input throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name)); } - if (\in_array($value, array('', null), true) && $option->acceptValue() && \count($this->parsed)) { + if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) { // if option accepts an optional or mandatory argument // let's see if there is one provided $next = array_shift($this->parsed); - if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, array('', null), true)) { + if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) { $value = $next; } else { array_unshift($this->parsed, $next); diff --git a/src/Symfony/Component/Console/Input/ArrayInput.php b/src/Symfony/Component/Console/Input/ArrayInput.php index 8b6917fc7c..cf09ff45ec 100644 --- a/src/Symfony/Component/Console/Input/ArrayInput.php +++ b/src/Symfony/Component/Console/Input/ArrayInput.php @@ -19,7 +19,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException; * * Usage: * - * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); + * $input = new ArrayInput(['name' => 'foo', '--bar' => 'foobar']); * * @author Fabien Potencier */ @@ -103,7 +103,7 @@ class ArrayInput extends Input */ public function __toString() { - $params = array(); + $params = []; foreach ($this->parameters as $param => $val) { if ($param && '-' === $param[0]) { if (\is_array($val)) { @@ -114,7 +114,7 @@ class ArrayInput extends Input $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); } } else { - $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val); + $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); } } diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index fa5644d1fd..7a16e0ee4b 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -29,8 +29,8 @@ abstract class Input implements InputInterface, StreamableInputInterface { protected $definition; protected $stream; - protected $options = array(); - protected $arguments = array(); + protected $options = []; + protected $arguments = []; protected $interactive = true; public function __construct(InputDefinition $definition = null) @@ -48,8 +48,8 @@ abstract class Input implements InputInterface, StreamableInputInterface */ public function bind(InputDefinition $definition) { - $this->arguments = array(); - $this->options = array(); + $this->arguments = []; + $this->options = []; $this->definition = $definition; $this->parse(); diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index 94e82f0b86..b6aa6452a0 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -98,7 +98,7 @@ class InputArgument if ($this->isArray()) { if (null === $default) { - $default = array(); + $default = []; } elseif (!\is_array($default)) { throw new LogicException('A default value for an array argument must be an array.'); } diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index 21fc67df2f..c7e5c987e5 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -19,10 +19,10 @@ use Symfony\Component\Console\Exception\LogicException; * * Usage: * - * $definition = new InputDefinition(array( + * $definition = new InputDefinition([ * new InputArgument('name', InputArgument::REQUIRED), * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), - * )); + * ]); * * @author Fabien Potencier */ @@ -38,7 +38,7 @@ class InputDefinition /** * @param array $definition An array of InputArgument and InputOption instance */ - public function __construct(array $definition = array()) + public function __construct(array $definition = []) { $this->setDefinition($definition); } @@ -48,8 +48,8 @@ class InputDefinition */ public function setDefinition(array $definition) { - $arguments = array(); - $options = array(); + $arguments = []; + $options = []; foreach ($definition as $item) { if ($item instanceof InputOption) { $options[] = $item; @@ -67,9 +67,9 @@ class InputDefinition * * @param InputArgument[] $arguments An array of InputArgument objects */ - public function setArguments($arguments = array()) + public function setArguments($arguments = []) { - $this->arguments = array(); + $this->arguments = []; $this->requiredCount = 0; $this->hasOptional = false; $this->hasAnArrayArgument = false; @@ -81,7 +81,7 @@ class InputDefinition * * @param InputArgument[] $arguments An array of InputArgument objects */ - public function addArguments($arguments = array()) + public function addArguments($arguments = []) { if (null !== $arguments) { foreach ($arguments as $argument) { @@ -191,7 +191,7 @@ class InputDefinition */ public function getArgumentDefaults() { - $values = array(); + $values = []; foreach ($this->arguments as $argument) { $values[$argument->getName()] = $argument->getDefault(); } @@ -204,10 +204,10 @@ class InputDefinition * * @param InputOption[] $options An array of InputOption objects */ - public function setOptions($options = array()) + public function setOptions($options = []) { - $this->options = array(); - $this->shortcuts = array(); + $this->options = []; + $this->shortcuts = []; $this->addOptions($options); } @@ -216,7 +216,7 @@ class InputDefinition * * @param InputOption[] $options An array of InputOption objects */ - public function addOptions($options = array()) + public function addOptions($options = []) { foreach ($options as $option) { $this->addOption($option); @@ -322,7 +322,7 @@ class InputDefinition */ public function getOptionDefaults() { - $values = array(); + $values = []; foreach ($this->options as $option) { $values[$option->getName()] = $option->getDefault(); } @@ -357,7 +357,7 @@ class InputDefinition */ public function getSynopsis($short = false) { - $elements = array(); + $elements = []; if ($short && $this->getOptions()) { $elements[] = '[options]'; diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 67825cb11e..d62e0aea02 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -161,7 +161,7 @@ class InputOption if ($this->isArray()) { if (null === $default) { - $default = array(); + $default = []; } elseif (!\is_array($default)) { throw new LogicException('A default value for an array option must be an array.'); } diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index 61e29481a4..0c63ed0e0e 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -32,7 +32,7 @@ class StringInput extends ArgvInput */ public function __construct(string $input) { - parent::__construct(array()); + parent::__construct([]); $this->setTokens($this->tokenize($input)); } @@ -48,13 +48,13 @@ class StringInput extends ArgvInput */ private function tokenize($input) { - $tokens = array(); + $tokens = []; $length = \strlen($input); $cursor = 0; while ($cursor < $length) { if (preg_match('/\s+/A', $input, $match, null, $cursor)) { } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { - $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2))); + $tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, \strlen($match[3]) - 2))); } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2)); } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index 0f7d551a62..36f3b99fa7 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -30,7 +30,7 @@ class ConsoleLogger extends AbstractLogger const ERROR = 'error'; private $output; - private $verbosityLevelMap = array( + private $verbosityLevelMap = [ LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL, LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL, @@ -39,8 +39,8 @@ class ConsoleLogger extends AbstractLogger LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE, LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE, LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG, - ); - private $formatLevelMap = array( + ]; + private $formatLevelMap = [ LogLevel::EMERGENCY => self::ERROR, LogLevel::ALERT => self::ERROR, LogLevel::CRITICAL => self::ERROR, @@ -49,10 +49,10 @@ class ConsoleLogger extends AbstractLogger LogLevel::NOTICE => self::INFO, LogLevel::INFO => self::INFO, LogLevel::DEBUG => self::INFO, - ); + ]; private $errored = false; - public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array()) + public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = []) { $this->output = $output; $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap; @@ -62,7 +62,7 @@ class ConsoleLogger extends AbstractLogger /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = []) { if (!isset($this->verbosityLevelMap[$level])) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); @@ -106,7 +106,7 @@ class ConsoleLogger extends AbstractLogger return $message; } - $replacements = array(); + $replacements = []; foreach ($context as $key => $val) { if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index e106d4f244..1d00ba050c 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -130,11 +130,11 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface */ private function isRunningOS400() { - $checks = array( + $checks = [ \function_exists('php_uname') ? php_uname('s') : '', getenv('OSTYPE'), PHP_OS, - ); + ]; return false !== stripos(implode(';', $checks), 'OS400'); } diff --git a/src/Symfony/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php index 4aa6f67266..612e406a8e 100644 --- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php +++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php @@ -139,12 +139,12 @@ class ChoiceQuestion extends Question } $selectedChoices = explode(',', $selectedChoices); } else { - $selectedChoices = array($selected); + $selectedChoices = [$selected]; } - $multiselectChoices = array(); + $multiselectChoices = []; foreach ($selectedChoices as $value) { - $results = array(); + $results = []; foreach ($choices as $key => $choice) { if ($choice === $value) { $results[] = $key; diff --git a/src/Symfony/Component/Console/Terminal.php b/src/Symfony/Component/Console/Terminal.php index 3930ca0cdc..456cca11ca 100644 --- a/src/Symfony/Component/Console/Terminal.php +++ b/src/Symfony/Component/Console/Terminal.php @@ -91,11 +91,11 @@ class Terminal return; } - $descriptorspec = array( - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w'), - ); - $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); + $descriptorspec = [ + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (\is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); @@ -103,7 +103,7 @@ class Terminal proc_close($process); if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { - return array((int) $matches[2], (int) $matches[1]); + return [(int) $matches[2], (int) $matches[1]]; } } } @@ -119,12 +119,12 @@ class Terminal return; } - $descriptorspec = array( - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w'), - ); + $descriptorspec = [ + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; - $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); + $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (\is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); diff --git a/src/Symfony/Component/Console/Tester/ApplicationTester.php b/src/Symfony/Component/Console/Tester/ApplicationTester.php index 3ae3115250..77032e1bb9 100644 --- a/src/Symfony/Component/Console/Tester/ApplicationTester.php +++ b/src/Symfony/Component/Console/Tester/ApplicationTester.php @@ -55,7 +55,7 @@ class ApplicationTester * * @return int The command exit code */ - public function run(array $input, $options = array()) + public function run(array $input, $options = []) { $this->input = new ArrayInput($input); if (isset($options['interactive'])) { diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 41df51b3e1..512feca706 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -71,7 +71,7 @@ class CommandTest extends TestCase $ret = $command->setDefinition($definition = new InputDefinition()); $this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface'); $this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance'); - $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); + $command->setDefinition([new InputArgument('foo'), new InputOption('bar')]); $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); $command->setDefinition(new InputDefinition()); @@ -130,10 +130,10 @@ class CommandTest extends TestCase public function provideInvalidCommandNames() { - return array( - array(''), - array('foo:'), - ); + return [ + [''], + ['foo:'], + ]; } public function testGetSetDescription() @@ -179,10 +179,10 @@ class CommandTest extends TestCase public function testGetSetAliases() { $command = new \TestCommand(); - $this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases'); - $ret = $command->setAliases(array('name1')); + $this->assertEquals(['name'], $command->getAliases(), '->getAliases() returns the aliases'); + $ret = $command->setAliases(['name1']); $this->assertEquals($command, $ret, '->setAliases() implements a fluent interface'); - $this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases'); + $this->assertEquals(['name1'], $command->getAliases(), '->setAliases() sets the aliases'); } public function testSetAliasesNull() @@ -231,11 +231,11 @@ class CommandTest extends TestCase public function testMergeApplicationDefinition() { $application1 = new Application(); - $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); - $application1->getDefinition()->addOptions(array(new InputOption('bar'))); + $application1->getDefinition()->addArguments([new InputArgument('foo')]); + $application1->getDefinition()->addOptions([new InputOption('bar')]); $command = new \TestCommand(); $command->setApplication($application1); - $command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo')))); + $command->setDefinition($definition = new InputDefinition([new InputArgument('bar'), new InputOption('foo')])); $r = new \ReflectionObject($command); $m = $r->getMethod('mergeApplicationDefinition'); @@ -253,11 +253,11 @@ class CommandTest extends TestCase public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs() { $application1 = new Application(); - $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); - $application1->getDefinition()->addOptions(array(new InputOption('bar'))); + $application1->getDefinition()->addArguments([new InputArgument('foo')]); + $application1->getDefinition()->addOptions([new InputOption('bar')]); $command = new \TestCommand(); $command->setApplication($application1); - $command->setDefinition($definition = new InputDefinition(array())); + $command->setDefinition($definition = new InputDefinition([])); $r = new \ReflectionObject($command); $m = $r->getMethod('mergeApplicationDefinition'); @@ -277,7 +277,7 @@ class CommandTest extends TestCase { $tester = new CommandTester(new \TestCommand()); - $tester->execute(array(), array('interactive' => true)); + $tester->execute([], ['interactive' => true]); $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); } @@ -286,7 +286,7 @@ class CommandTest extends TestCase { $tester = new CommandTester(new \TestCommand()); - $tester->execute(array(), array('interactive' => false)); + $tester->execute([], ['interactive' => false]); $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); } @@ -309,7 +309,7 @@ class CommandTest extends TestCase { $command = new \TestCommand(); $tester = new CommandTester($command); - $tester->execute(array('--bar' => true)); + $tester->execute(['--bar' => true]); } public function testRunReturnsIntegerExitCode() @@ -318,7 +318,7 @@ class CommandTest extends TestCase $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); - $command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock(); + $command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock(); $command->expects($this->once()) ->method('execute') ->will($this->returnValue('2.3')); @@ -364,16 +364,16 @@ class CommandTest extends TestCase }); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); - $tester->execute(array()); + $tester->execute([]); $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); } public function getSetCodeBindToClosureTests() { - return array( - array(true, 'not bound to the command'), - array(false, 'bound to the command'), - ); + return [ + [true, 'not bound to the command'], + [false, 'bound to the command'], + ]; } /** @@ -389,7 +389,7 @@ class CommandTest extends TestCase $command = new \TestCommand(); $command->setCode($code); $tester = new CommandTester($command); - $tester->execute(array()); + $tester->execute([]); $this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay()); } @@ -398,7 +398,7 @@ class CommandTest extends TestCase $command = new \TestCommand(); $command->setCode(self::createClosure()); $tester = new CommandTester($command); - $tester->execute(array()); + $tester->execute([]); $this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay()); } @@ -413,10 +413,10 @@ class CommandTest extends TestCase public function testSetCodeWithNonClosureCallable() { $command = new \TestCommand(); - $ret = $command->setCode(array($this, 'callableMethodCommand')); + $ret = $command->setCode([$this, 'callableMethodCommand']); $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); $tester = new CommandTester($command); - $tester->execute(array()); + $tester->execute([]); $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); } diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php index 30fe2b6e7f..ce9d8d4fe4 100644 --- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -24,7 +24,7 @@ class HelpCommandTest extends TestCase $command = new HelpCommand(); $command->setApplication(new Application()); $commandTester = new CommandTester($command); - $commandTester->execute(array('command_name' => 'li'), array('decorated' => false)); + $commandTester->execute(['command_name' => 'li'], ['decorated' => false]); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); @@ -35,7 +35,7 @@ class HelpCommandTest extends TestCase $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); - $commandTester->execute(array(), array('decorated' => false)); + $commandTester->execute([], ['decorated' => false]); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); @@ -46,7 +46,7 @@ class HelpCommandTest extends TestCase $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); - $commandTester->execute(array('--format' => 'xml')); + $commandTester->execute(['--format' => 'xml']); $this->assertContains('getDisplay(), '->execute() returns an XML help text if --xml is passed'); } @@ -54,7 +54,7 @@ class HelpCommandTest extends TestCase { $application = new Application(); $commandTester = new CommandTester($application->get('help')); - $commandTester->execute(array('command_name' => 'list')); + $commandTester->execute(['command_name' => 'list']); $this->assertContains('list [options] [--] []', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); @@ -64,7 +64,7 @@ class HelpCommandTest extends TestCase { $application = new Application(); $commandTester = new CommandTester($application->get('help')); - $commandTester->execute(array('command_name' => 'list', '--format' => 'xml')); + $commandTester->execute(['command_name' => 'list', '--format' => 'xml']); $this->assertContains('list [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $this->assertContains('getDisplay(), '->execute() returns an XML help text if --format=xml is passed'); } diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index b39f7ec545..57687d4c60 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -21,7 +21,7 @@ class ListCommandTest extends TestCase { $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); - $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); + $commandTester->execute(['command' => $command->getName()], ['decorated' => false]); $this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); } @@ -30,7 +30,7 @@ class ListCommandTest extends TestCase { $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); - $commandTester->execute(array('command' => $command->getName(), '--format' => 'xml')); + $commandTester->execute(['command' => $command->getName(), '--format' => 'xml']); $this->assertRegExp('/