From ce7ef306e9c14f4c6fb442bb7f7fae3aa00afba6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 16 Jan 2019 10:39:14 +0100 Subject: [PATCH] switched array() to [] --- CacheWarmer/AbstractPhpFileCacheWarmer.php | 4 +- CacheWarmer/RouterCacheWarmer.php | 4 +- CacheWarmer/SerializerCacheWarmer.php | 2 +- CacheWarmer/TemplateFinder.php | 4 +- CacheWarmer/TemplatePathsCacheWarmer.php | 2 +- CacheWarmer/TranslationsCacheWarmer.php | 4 +- CacheWarmer/ValidatorCacheWarmer.php | 2 +- Client.php | 2 +- Command/AboutCommand.php | 58 ++-- Command/AbstractConfigCommand.php | 6 +- Command/AssetsInstallCommand.php | 16 +- Command/CacheClearCommand.php | 8 +- Command/CachePoolClearCommand.php | 8 +- Command/CacheWarmupCommand.php | 4 +- Command/ConfigDebugCommand.php | 6 +- Command/ConfigDumpReferenceCommand.php | 10 +- Command/ContainerDebugCommand.php | 28 +- Command/DebugAutowiringCommand.php | 14 +- Command/EventDispatcherDebugCommand.php | 8 +- Command/RouterDebugCommand.php | 12 +- Command/RouterMatchCommand.php | 6 +- Command/TranslationDebugCommand.php | 30 +- Command/TranslationUpdateCommand.php | 20 +- Command/WorkflowDumpCommand.php | 4 +- Console/Application.php | 6 +- Console/Descriptor/Descriptor.php | 28 +- Console/Descriptor/JsonDescriptor.php | 66 ++-- Console/Descriptor/MarkdownDescriptor.php | 36 +-- Console/Descriptor/TextDescriptor.php | 156 +++++----- Console/Descriptor/XmlDescriptor.php | 26 +- Controller/AbstractController.php | 4 +- Controller/ControllerNameParser.php | 4 +- Controller/ControllerTrait.php | 22 +- Controller/RedirectController.php | 2 +- DataCollector/RequestDataCollector.php | 4 +- .../Compiler/AddCacheClearerPass.php | 2 +- .../Compiler/AddDebugLogProcessorPass.php | 2 +- .../AddExpressionLanguageProvidersPass.php | 4 +- .../Compiler/CacheCollectorPass.php | 8 +- .../Compiler/CachePoolClearerPass.php | 2 +- .../Compiler/CachePoolPass.php | 14 +- .../Compiler/CachePoolPrunerPass.php | 2 +- DependencyInjection/Compiler/FormPass.php | 4 +- .../Compiler/LoggingTranslatorPass.php | 2 +- DependencyInjection/Compiler/ProfilerPass.php | 8 +- .../Compiler/TemplatingPass.php | 6 +- .../Compiler/UnusedTagsPass.php | 6 +- .../Compiler/WorkflowGuardListenerPass.php | 4 +- DependencyInjection/Configuration.php | 76 ++--- DependencyInjection/FrameworkExtension.php | 196 ++++++------ .../ResolveControllerNameSubscriber.php | 6 +- FrameworkBundle.php | 4 +- HttpCache/HttpCache.php | 4 +- Kernel/MicroKernelTrait.php | 8 +- Routing/AnnotatedRouteControllerLoader.php | 6 +- Routing/RedirectableUrlMatcher.php | 4 +- Routing/Router.php | 12 +- Templating/DelegatingEngine.php | 2 +- Templating/EngineInterface.php | 2 +- Templating/Helper/ActionsHelper.php | 4 +- Templating/Helper/CodeHelper.php | 8 +- Templating/Helper/FormHelper.php | 18 +- Templating/Helper/RouterHelper.php | 4 +- Templating/Helper/SessionHelper.php | 2 +- Templating/Helper/StopwatchHelper.php | 4 +- Templating/Helper/TranslatorHelper.php | 4 +- Templating/Loader/TemplateLocator.php | 2 +- Templating/PhpEngine.php | 2 +- Templating/TemplateNameParser.php | 2 +- Templating/TemplateReference.php | 4 +- Templating/TimedPhpEngine.php | 2 +- Test/KernelTestCase.php | 4 +- Test/WebTestCase.php | 2 +- .../AnnotationsCacheWarmerTest.php | 4 +- .../CacheWarmer/ClassCacheCacheWarmerTest.php | 4 +- .../CacheWarmer/SerializerCacheWarmerTest.php | 6 +- Tests/CacheWarmer/TemplateFinderTest.php | 2 +- .../TemplatePathsCacheWarmerTest.php | 10 +- Tests/ClientTest.php | 2 +- .../CacheClearCommandTest.php | 2 +- .../Fixture/TestAppKernel.php | 4 +- Tests/Command/CachePruneCommandTest.php | 8 +- Tests/Command/RouterDebugCommandTest.php | 10 +- Tests/Command/RouterMatchCommandTest.php | 8 +- Tests/Command/TranslationDebugCommandTest.php | 68 ++-- .../Command/TranslationUpdateCommandTest.php | 70 ++--- Tests/Command/YamlLintCommandTest.php | 14 +- Tests/Console/ApplicationTest.php | 66 ++-- .../Descriptor/AbstractDescriptorTest.php | 52 ++-- Tests/Console/Descriptor/ObjectsProvider.php | 88 +++--- Tests/Controller/ControllerNameParserTest.php | 34 +- Tests/Controller/ControllerResolverTest.php | 10 +- Tests/Controller/ControllerTraitTest.php | 14 +- Tests/Controller/RedirectControllerTest.php | 80 ++--- .../Compiler/AddCacheWarmerPassTest.php | 14 +- .../Compiler/AddConsoleCommandPassTest.php | 10 +- .../AddConstraintValidatorsPassTest.php | 10 +- .../Compiler/CacheCollectorPassTest.php | 8 +- .../Compiler/CachePoolClearerPassTest.php | 12 +- .../Compiler/CachePoolPassTest.php | 6 +- .../Compiler/CachePoolPrunerPassTest.php | 8 +- .../Compiler/ConfigCachePassTest.php | 8 +- ...ontrollerArgumentValueResolverPassTest.php | 20 +- .../DataCollectorTranslatorPassTest.php | 24 +- .../Compiler/FormPassTest.php | 124 ++++---- .../Compiler/LoggingTranslatorPassTest.php | 12 +- .../Compiler/ProfilerPassTest.php | 6 +- .../Compiler/PropertyInfoPassTest.php | 32 +- .../Compiler/SerializerPassTest.php | 14 +- .../Compiler/TranslatorPassTest.php | 14 +- .../Compiler/UnusedTagsPassTest.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 290 +++++++++--------- .../Fixtures/php/assets.php | 42 +-- .../Fixtures/php/assets_disabled.php | 8 +- .../assets_version_strategy_as_service.php | 8 +- .../Fixtures/php/cache.php | 32 +- .../Fixtures/php/cache_env_var.php | 8 +- .../DependencyInjection/Fixtures/php/csrf.php | 8 +- .../Fixtures/php/csrf_needs_session.php | 8 +- .../Fixtures/php/default_config.php | 2 +- .../php/esi_and_ssi_without_fragments.php | 16 +- .../Fixtures/php/esi_disabled.php | 8 +- .../Fixtures/php/form_no_csrf.php | 12 +- .../DependencyInjection/Fixtures/php/full.php | 80 ++--- .../Fixtures/php/php_errors_disabled.php | 8 +- .../Fixtures/php/php_errors_enabled.php | 8 +- .../Fixtures/php/profiler.php | 8 +- .../Fixtures/php/property_accessor.php | 8 +- .../Fixtures/php/property_info.php | 8 +- .../Fixtures/php/request.php | 10 +- .../Fixtures/php/serializer_disabled.php | 8 +- .../Fixtures/php/serializer_enabled.php | 8 +- .../Fixtures/php/serializer_legacy_cache.php | 8 +- .../Fixtures/php/serializer_mapping.php | 18 +- .../Fixtures/php/session.php | 8 +- .../Fixtures/php/ssi_disabled.php | 8 +- .../Fixtures/php/templating_disabled.php | 4 +- .../Fixtures/php/templating_no_assets.php | 10 +- .../php/templating_php_assets_disabled.php | 10 +- .../templating_php_translator_disabled.php | 10 +- .../php/templating_php_translator_enabled.php | 10 +- .../Fixtures/php/translator_fallbacks.php | 10 +- .../Fixtures/php/validation_annotations.php | 8 +- .../Fixtures/php/validation_mapping.php | 16 +- .../validation_multiple_static_methods.php | 10 +- .../php/validation_no_static_method.php | 8 +- .../Fixtures/php/validation_strict_email.php | 8 +- .../php/validation_translation_domain.php | 8 +- .../Fixtures/php/web_link.php | 6 +- .../workflow_with_arguments_and_service.php | 42 +-- .../php/workflow_with_guard_expression.php | 52 ++-- ...th_multiple_transitions_with_same_name.php | 52 ++-- ...flow_with_support_and_support_strategy.php | 40 +-- .../php/workflow_with_type_and_service.php | 40 +-- ...w_without_support_and_support_strategy.php | 36 +-- .../Fixtures/php/workflows.php | 122 ++++---- .../Fixtures/php/workflows_enabled.php | 4 +- .../php/workflows_explicitly_enabled.php | 28 +- ...ows_explicitly_enabled_named_workflows.php | 28 +- .../Fixtures/php/workflows_without_type.php | 32 +- .../FrameworkExtensionTest.php | 228 +++++++------- .../PhpFrameworkExtensionTest.php | 24 +- .../ResolveControllerNameSubscriberTest.php | 4 +- Tests/Fixtures/templates.php | 4 +- Tests/Functional/AnnotatedControllerTest.php | 18 +- Tests/Functional/AutowiringTypesTest.php | 10 +- .../Controller/FragmentController.php | 2 +- .../Controller/SubRequestController.php | 8 +- .../SubRequestServiceResolutionController.php | 2 +- .../DependencyInjection/TestExtension.php | 2 +- .../Functional/CachePoolClearCommandTest.php | 14 +- Tests/Functional/CachePoolsTest.php | 10 +- Tests/Functional/ConfigDebugCommandTest.php | 12 +- .../ConfigDumpReferenceCommandTest.php | 14 +- .../Functional/ContainerDebugCommandTest.php | 14 +- Tests/Functional/ContainerDumpTest.php | 4 +- .../Functional/DebugAutowiringCommandTest.php | 12 +- Tests/Functional/FragmentTest.php | 10 +- Tests/Functional/ProfilerTest.php | 10 +- Tests/Functional/PropertyInfoTest.php | 4 +- Tests/Functional/SerializerTest.php | 4 +- Tests/Functional/SessionTest.php | 18 +- Tests/Functional/SubRequestsTest.php | 4 +- Tests/Functional/WebTestCase.php | 2 +- .../app/AnnotatedController/bundles.php | 4 +- Tests/Functional/app/AppKernel.php | 2 +- .../app/AutowiringTypes/bundles.php | 4 +- .../Functional/app/CachePoolClear/bundles.php | 4 +- Tests/Functional/app/CachePools/bundles.php | 4 +- Tests/Functional/app/ConfigDump/bundles.php | 4 +- .../Functional/app/ContainerDebug/bundles.php | 4 +- .../Functional/app/ContainerDump/bundles.php | 4 +- .../ControllerServiceResolution/bundles.php | 4 +- Tests/Functional/app/Fragment/bundles.php | 4 +- Tests/Functional/app/Profiler/bundles.php | 4 +- .../app/Resources/views/fragment.html.php | 12 +- Tests/Functional/app/Serializer/bundles.php | 4 +- Tests/Functional/app/Session/bundles.php | 4 +- Tests/Kernel/ConcreteMicroKernel.php | 12 +- Tests/Routing/RedirectableUrlMatcherTest.php | 10 +- Tests/Routing/RouterTest.php | 52 ++-- Tests/Templating/DelegatingEngineTest.php | 32 +- Tests/Templating/GlobalVariablesTest.php | 18 +- Tests/Templating/Helper/AssetsHelperTest.php | 2 +- .../Helper/Fixtures/StubTranslator.php | 4 +- .../Helper/FormHelperDivLayoutTest.php | 48 +-- .../Helper/FormHelperTableLayoutTest.php | 36 +-- Tests/Templating/Helper/RequestHelperTest.php | 2 +- Tests/Templating/Helper/SessionHelperTest.php | 4 +- .../Templating/Loader/TemplateLocatorTest.php | 4 +- .../Templating/TemplateFilenameParserTest.php | 14 +- Tests/Templating/TemplateNameParserTest.php | 48 +-- Tests/Templating/TemplateTest.php | 12 +- Tests/Translation/PhpExtractorTest.php | 30 +- Tests/Translation/TranslatorTest.php | 138 ++++----- .../ConstraintValidatorFactoryTest.php | 2 +- Translation/Translator.php | 16 +- Validator/ConstraintValidatorFactory.php | 2 +- 218 files changed, 2074 insertions(+), 2074 deletions(-) diff --git a/CacheWarmer/AbstractPhpFileCacheWarmer.php b/CacheWarmer/AbstractPhpFileCacheWarmer.php index 25801a782..43cbb7968 100644 --- a/CacheWarmer/AbstractPhpFileCacheWarmer.php +++ b/CacheWarmer/AbstractPhpFileCacheWarmer.php @@ -54,13 +54,13 @@ public function warmUp($cacheDir) { $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/CacheWarmer/RouterCacheWarmer.php b/CacheWarmer/RouterCacheWarmer.php index 795fdbfc5..e3ef1f055 100644 --- a/CacheWarmer/RouterCacheWarmer.php +++ b/CacheWarmer/RouterCacheWarmer.php @@ -71,8 +71,8 @@ public function isOptional() */ public static function getSubscribedServices() { - return array( + return [ 'router' => RouterInterface::class, - ); + ]; } } diff --git a/CacheWarmer/SerializerCacheWarmer.php b/CacheWarmer/SerializerCacheWarmer.php index 22d2bcfe9..917ea4723 100644 --- a/CacheWarmer/SerializerCacheWarmer.php +++ b/CacheWarmer/SerializerCacheWarmer.php @@ -74,7 +74,7 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter) */ private function extractSupportedLoaders(array $loaders) { - $supportedLoaders = array(); + $supportedLoaders = []; foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { diff --git a/CacheWarmer/TemplateFinder.php b/CacheWarmer/TemplateFinder.php index 4ceca5c6b..e3eea295e 100644 --- a/CacheWarmer/TemplateFinder.php +++ b/CacheWarmer/TemplateFinder.php @@ -52,7 +52,7 @@ public function findAllTemplates() return $this->templates; } - $templates = array(); + $templates = []; foreach ($this->kernel->getBundles() as $bundle) { $templates = array_merge($templates, $this->findTemplatesInBundle($bundle)); @@ -72,7 +72,7 @@ public function findAllTemplates() */ private function findTemplatesInFolder($dir) { - $templates = array(); + $templates = []; if (is_dir($dir)) { $finder = new Finder(); diff --git a/CacheWarmer/TemplatePathsCacheWarmer.php b/CacheWarmer/TemplatePathsCacheWarmer.php index 523d7ecce..6662a1808 100644 --- a/CacheWarmer/TemplatePathsCacheWarmer.php +++ b/CacheWarmer/TemplatePathsCacheWarmer.php @@ -39,7 +39,7 @@ public function __construct(TemplateFinderInterface $finder, TemplateLocator $lo 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/CacheWarmer/TranslationsCacheWarmer.php b/CacheWarmer/TranslationsCacheWarmer.php index 7d9ec9f9d..b4439eff4 100644 --- a/CacheWarmer/TranslationsCacheWarmer.php +++ b/CacheWarmer/TranslationsCacheWarmer.php @@ -72,8 +72,8 @@ public function isOptional() */ public static function getSubscribedServices() { - return array( + return [ 'translator' => TranslatorInterface::class, - ); + ]; } } diff --git a/CacheWarmer/ValidatorCacheWarmer.php b/CacheWarmer/ValidatorCacheWarmer.php index 2fb4ace86..8ac38133c 100644 --- a/CacheWarmer/ValidatorCacheWarmer.php +++ b/CacheWarmer/ValidatorCacheWarmer.php @@ -85,7 +85,7 @@ protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array */ private function extractSupportedLoaders(array $loaders) { - $supportedLoaders = array(); + $supportedLoaders = []; foreach ($loaders as $loader) { if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) { diff --git a/Client.php b/Client.php index c86a2772e..6473f9758 100644 --- a/Client.php +++ b/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/Command/AboutCommand.php b/Command/AboutCommand.php index c7016c4ba..ad1590edf 100644 --- a/Command/AboutCommand.php +++ b/Command/AboutCommand.php @@ -60,46 +60,46 @@ protected function execute(InputInterface $input, OutputInterface $output) /** @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($path, $baseDir = null) @@ -130,7 +130,7 @@ private static function isExpired($date) private static function getDotenvVars() { - $vars = array(); + $vars = []; foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) { if ('' !== $name && false !== $value = getenv($name)) { $vars[$name] = $value; diff --git a/Command/AbstractConfigCommand.php b/Command/AbstractConfigCommand.php index 6d8960cd0..cc1b858ab 100644 --- a/Command/AbstractConfigCommand.php +++ b/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 @@ protected function listBundles($output) 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/Command/AssetsInstallCommand.php b/Command/AssetsInstallCommand.php index 3e5800f9d..aee869f8f 100644 --- a/Command/AssetsInstallCommand.php +++ b/Command/AssetsInstallCommand.php @@ -65,9 +65,9 @@ public function __construct($filesystem = null) 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') ->setDescription('Installs bundles web assets under a public directory') @@ -144,10 +144,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $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')) { @@ -180,13 +180,13 @@ protected function execute(InputInterface $input, OutputInterface $output) } 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 @@ -196,7 +196,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($rows) { - $io->table(array('', 'Bundle', 'Method / Error'), $rows); + $io->table(['', 'Bundle', 'Method / Error'], $rows); } if (0 !== $exitCode) { diff --git a/Command/CacheClearCommand.php b/Command/CacheClearCommand.php index 6c5f0e129..9f3c47197 100644 --- a/Command/CacheClearCommand.php +++ b/Command/CacheClearCommand.php @@ -66,10 +66,10 @@ public function __construct($cacheClearer = null, Filesystem $filesystem = null) protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'), new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), - )) + ]) ->setDescription('Clears the cache') ->setHelp(<<<'EOF' The %command.name% command clears the application cache for a given environment @@ -148,7 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) { foreach ($mounts as $mount) { $mount = \array_slice(explode(' ', $mount), 1, -3); - if (!\in_array(array_pop($mount), array('vboxsf', 'nfs'))) { + if (!\in_array(array_pop($mount), ['vboxsf', 'nfs'])) { continue; } $mount = implode(' ', $mount).'/'; @@ -222,7 +222,7 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr $warmer->warmUp($warmupDir); // fix references to cached files with the real cache directory name - $search = array($warmupDir, str_replace('\\', '\\\\', $warmupDir)); + $search = [$warmupDir, str_replace('\\', '\\\\', $warmupDir)]; $replace = str_replace('\\', '/', $realCacheDir); foreach (Finder::create()->files()->in($warmupDir) as $file) { $content = str_replace($search, $replace, file_get_contents($file), $count); diff --git a/Command/CachePoolClearCommand.php b/Command/CachePoolClearCommand.php index 43b27e673..dfb4df194 100644 --- a/Command/CachePoolClearCommand.php +++ b/Command/CachePoolClearCommand.php @@ -54,9 +54,9 @@ public function __construct($poolClearer = null) 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. @@ -80,8 +80,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $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/Command/CacheWarmupCommand.php b/Command/CacheWarmupCommand.php index 593b93475..0893f2db5 100644 --- a/Command/CacheWarmupCommand.php +++ b/Command/CacheWarmupCommand.php @@ -54,9 +54,9 @@ public function __construct($cacheWarmer = null) 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/Command/ConfigDebugCommand.php b/Command/ConfigDebugCommand.php index 658f1f9e0..758c605ec 100644 --- a/Command/ConfigDebugCommand.php +++ b/Command/ConfigDebugCommand.php @@ -36,10 +36,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 @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 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/Command/ConfigDumpReferenceCommand.php b/Command/ConfigDumpReferenceCommand.php index bdcf13e8d..37b179899 100644 --- a/Command/ConfigDumpReferenceCommand.php +++ b/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 @@ protected function execute(InputInterface $input, OutputInterface $output) 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/Command/ContainerDebugCommand.php b/Command/ContainerDebugCommand.php index ad7affab8..62adea0e5 100644 --- a/Command/ContainerDebugCommand.php +++ b/Command/ContainerDebugCommand.php @@ -46,7 +46,7 @@ class ContainerDebugCommand extends ContainerAwareCommand protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'), new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services'), new InputOption('show-arguments', null, InputOption::VALUE_NONE, 'Used to show arguments in services'), @@ -57,7 +57,7 @@ protected function configure() new InputOption('types', null, InputOption::VALUE_NONE, 'Displays types (classes/interfaces) available in the container'), 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 current services for an application') ->setHelp(<<<'EOF' The %command.name% command displays all configured public services: @@ -110,26 +110,26 @@ protected function execute(InputInterface $input, OutputInterface $output) $object = $this->getContainerBuilder(); if ($input->getOption('types')) { - $options = array('show_private' => true); - $options['filter'] = array($this, 'filterToServiceTypes'); + $options = ['show_private' => true]; + $options['filter'] = [$this, 'filterToServiceTypes']; } elseif ($input->getOption('parameters')) { - $parameters = array(); + $parameters = []; foreach ($object->getParameterBag()->all() as $k => $v) { $parameters[$k] = $object->resolveEnvPlaceholders($v); } $object = new ParameterBag($parameters); - $options = array(); + $options = []; } elseif ($parameter = $input->getOption('parameter')) { - $options = array('parameter' => $parameter); + $options = ['parameter' => $parameter]; } elseif ($input->getOption('tags')) { - $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private')); + $options = ['group_by' => 'tags', 'show_private' => $input->getOption('show-private')]; } elseif ($tag = $input->getOption('tag')) { - $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private')); + $options = ['tag' => $tag, 'show_private' => $input->getOption('show-private')]; } elseif ($name = $input->getArgument('name')) { $name = $this->findProperServiceName($input, $errorIo, $object, $name); - $options = array('id' => $name); + $options = ['id' => $name]; } else { - $options = array('show_private' => $input->getOption('show-private')); + $options = ['show_private' => $input->getOption('show-private')]; } $helper = new DescriptorHelper(); @@ -157,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output) */ protected function validateInput(InputInterface $input) { - $options = array('tags', 'tag', 'parameters', 'parameter'); + $options = ['tags', 'tag', 'parameters', 'parameter']; $optionsCount = 0; foreach ($options as $option) { @@ -192,7 +192,7 @@ protected function getContainerBuilder() if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) { $buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel)); $container = $buildContainer(); - $container->getCompilerPassConfig()->setRemovingPasses(array()); + $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); } else { (new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump')); @@ -220,7 +220,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io, private function findServiceIdsContaining(ContainerBuilder $builder, $name) { $serviceIds = $builder->getServiceIds(); - $foundServiceIds = array(); + $foundServiceIds = []; foreach ($serviceIds as $serviceId) { if (false === stripos($serviceId, $name)) { continue; diff --git a/Command/DebugAutowiringCommand.php b/Command/DebugAutowiringCommand.php index 23d688495..72ac54856 100644 --- a/Command/DebugAutowiringCommand.php +++ b/Command/DebugAutowiringCommand.php @@ -33,9 +33,9 @@ class DebugAutowiringCommand extends ContainerDebugCommand protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'), - )) + ]) ->setDescription('Lists classes/interfaces you can use for autowiring') ->setHelp(<<<'EOF' The %command.name% command displays all classes and interfaces that @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $builder = $this->getContainerBuilder(); $serviceIds = $builder->getServiceIds(); - $serviceIds = array_filter($serviceIds, array($this, 'filterToServiceTypes')); + $serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']); if ($search = $input->getArgument('search')) { $serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) { @@ -84,14 +84,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->text(sprintf('(only showing classes/interfaces matching %s)', $search)); } $io->newLine(); - $tableRows = array(); + $tableRows = []; foreach ($serviceIds as $serviceId) { - $tableRows[] = array(sprintf('%s', $serviceId)); + $tableRows[] = [sprintf('%s', $serviceId)]; if ($builder->hasAlias($serviceId)) { - $tableRows[] = array(sprintf(' alias to %s', $builder->getAlias($serviceId))); + $tableRows[] = [sprintf(' alias to %s', $builder->getAlias($serviceId))]; } } - $io->table(array(), $tableRows); + $io->table([], $tableRows); } } diff --git a/Command/EventDispatcherDebugCommand.php b/Command/EventDispatcherDebugCommand.php index 9f7a916fd..846895323 100644 --- a/Command/EventDispatcherDebugCommand.php +++ b/Command/EventDispatcherDebugCommand.php @@ -55,11 +55,11 @@ public function __construct($dispatcher = null) 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: @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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)); @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return; } - $options = array('event' => $event); + $options = ['event' => $event]; } $helper = new DescriptorHelper(); diff --git a/Command/RouterDebugCommand.php b/Command/RouterDebugCommand.php index fbf7ba9d8..b428b9e45 100644 --- a/Command/RouterDebugCommand.php +++ b/Command/RouterDebugCommand.php @@ -81,12 +81,12 @@ public function isEnabled() protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('name', InputArgument::OPTIONAL, 'A route name'), new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'), 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 route(s)'), - )) + ]) ->setDescription('Displays current routes for an application') ->setHelp(<<<'EOF' The %command.name% displays the configured routes: @@ -122,24 +122,24 @@ protected function execute(InputInterface $input, OutputInterface $output) $callable = $this->extractCallable($route); - $helper->describe($io, $route, array( + $helper->describe($io, $route, [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'name' => $name, 'output' => $io, 'callable' => $callable, - )); + ]); } else { foreach ($routes as $route) { $this->convertController($route); } - $helper->describe($io, $routes, array( + $helper->describe($io, $routes, [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'show_controllers' => $input->getOption('show-controllers'), 'output' => $io, - )); + ]); } } diff --git a/Command/RouterMatchCommand.php b/Command/RouterMatchCommand.php index 7ea1af66d..972c055bd 100644 --- a/Command/RouterMatchCommand.php +++ b/Command/RouterMatchCommand.php @@ -78,12 +78,12 @@ public function isEnabled() 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: @@ -136,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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/Command/TranslationDebugCommand.php b/Command/TranslationDebugCommand.php index cd737e88f..33b984663 100644 --- a/Command/TranslationDebugCommand.php +++ b/Command/TranslationDebugCommand.php @@ -74,14 +74,14 @@ public function __construct($translator = null, TranslationReaderInterface $read 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 @@ -156,11 +156,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $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; } @@ -169,20 +169,20 @@ protected function execute(InputInterface $input, OutputInterface $output) 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])); @@ -213,7 +213,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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 @@ -233,16 +233,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $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)) { @@ -265,7 +265,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - $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)); } @@ -296,7 +296,7 @@ private function formatState($state) private function formatStates(array $states) { - $result = array(); + $result = []; foreach ($states as $state) { $result[] = $this->formatState($state); } @@ -368,7 +368,7 @@ private function loadCurrentMessages($locale, $transPaths) */ private function loadFallbackCatalogues($locale, $transPaths) { - $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/Command/TranslationUpdateCommand.php b/Command/TranslationUpdateCommand.php index 092650130..72e410d2c 100644 --- a/Command/TranslationUpdateCommand.php +++ b/Command/TranslationUpdateCommand.php @@ -78,7 +78,7 @@ public function __construct($writer = null, TranslationReaderInterface $reader = 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', '__'), @@ -89,7 +89,7 @@ protected function configure() 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 @@ -155,7 +155,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // 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; } @@ -163,11 +163,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $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; } @@ -177,12 +177,12 @@ protected function execute(InputInterface $input, OutputInterface $output) 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(); } @@ -190,8 +190,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $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])) { @@ -299,7 +299,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $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/Command/WorkflowDumpCommand.php b/Command/WorkflowDumpCommand.php index bdc5690d7..fa11f792d 100644 --- a/Command/WorkflowDumpCommand.php +++ b/Command/WorkflowDumpCommand.php @@ -34,10 +34,10 @@ class WorkflowDumpCommand extends ContainerAwareCommand protected function configure() { $this - ->setDefinition(array( + ->setDefinition([ new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'), new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'), - )) + ]) ->setDescription('Dump a workflow') ->setHelp(<<<'EOF' The %command.name% command dumps the graphical representation of a diff --git a/Console/Application.php b/Console/Application.php index 10255a488..513c6eb66 100644 --- a/Console/Application.php +++ b/Console/Application.php @@ -31,7 +31,7 @@ class Application extends BaseApplication { private $kernel; private $commandsRegistered = false; - private $registrationErrors = array(); + private $registrationErrors = []; public function __construct(KernelInterface $kernel) { @@ -166,7 +166,7 @@ protected function registerCommands() } if ($container->hasParameter('console.command.ids')) { - $lazyCommandIds = $container->hasParameter('console.lazy_command.ids') ? $container->getParameter('console.lazy_command.ids') : array(); + $lazyCommandIds = $container->hasParameter('console.lazy_command.ids') ? $container->getParameter('console.lazy_command.ids') : []; foreach ($container->getParameter('console.command.ids') as $id) { if (!isset($lazyCommandIds[$id])) { try { @@ -193,6 +193,6 @@ private function renderRegistrationErrors(InputInterface $input, OutputInterface $this->doRenderException($error, $output); } - $this->registrationErrors = array(); + $this->registrationErrors = []; } } diff --git a/Console/Descriptor/Descriptor.php b/Console/Descriptor/Descriptor.php index be1ef79d2..fda0fb28d 100644 --- a/Console/Descriptor/Descriptor.php +++ b/Console/Descriptor/Descriptor.php @@ -36,7 +36,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; @@ -103,22 +103,22 @@ protected function write($content, $decorated = false) /** * 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. @@ -130,7 +130,7 @@ abstract protected function describeContainerTags(ContainerBuilder $builder, arr * @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. @@ -138,22 +138,22 @@ abstract protected function describeContainerService($service, array $options = * 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. @@ -161,7 +161,7 @@ abstract protected function describeContainerParameter($parameter, array $option * 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. @@ -169,7 +169,7 @@ abstract protected function describeEventDispatcherListeners(EventDispatcherInte * @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. @@ -242,7 +242,7 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI */ protected function findDefinitionsByTag(ContainerBuilder $builder, $showPrivate) { - $definitions = array(); + $definitions = []; $tags = $builder->findTags(); asort($tags); @@ -255,7 +255,7 @@ protected function findDefinitionsByTag(ContainerBuilder $builder, $showPrivate) } if (!isset($definitions[$tag])) { - $definitions[$tag] = array(); + $definitions[$tag] = []; } $definitions[$tag][$serviceId] = $definition; diff --git a/Console/Descriptor/JsonDescriptor.php b/Console/Descriptor/JsonDescriptor.php index 05238f372..83f607cc3 100644 --- a/Console/Descriptor/JsonDescriptor.php +++ b/Console/Descriptor/JsonDescriptor.php @@ -32,9 +32,9 @@ class JsonDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeRouteCollection(RouteCollection $routes, array $options = array()) + protected function describeRouteCollection(RouteCollection $routes, array $options = []) { - $data = array(); + $data = []; foreach ($routes->all() as $name => $route) { $data[$name] = $this->getRouteData($route); } @@ -45,7 +45,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio /** * {@inheritdoc} */ - protected function describeRoute(Route $route, array $options = array()) + protected function describeRoute(Route $route, array $options = []) { $this->writeData($this->getRouteData($route), $options); } @@ -53,7 +53,7 @@ protected function describeRoute(Route $route, array $options = array()) /** * {@inheritdoc} */ - protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) + protected function describeContainerParameters(ParameterBag $parameters, array $options = []) { $this->writeData($this->sortParameters($parameters), $options); } @@ -61,13 +61,13 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ /** * {@inheritdoc} */ - protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) + protected function describeContainerTags(ContainerBuilder $builder, array $options = []) { $showPrivate = isset($options['show_private']) && $options['show_private']; - $data = array(); + $data = []; foreach ($this->findDefinitionsByTag($builder, $showPrivate) as $tag => $definitions) { - $data[$tag] = array(); + $data[$tag] = []; foreach ($definitions as $definition) { $data[$tag][] = $this->getContainerDefinitionData($definition, true); } @@ -79,7 +79,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio /** * {@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.'); @@ -97,13 +97,13 @@ protected function describeContainerService($service, array $options = array(), /** * {@inheritdoc} */ - protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) + protected function describeContainerServices(ContainerBuilder $builder, array $options = []) { $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); $showPrivate = isset($options['show_private']) && $options['show_private']; $omitTags = isset($options['omit_tags']) && $options['omit_tags']; $showArguments = isset($options['show_arguments']) && $options['show_arguments']; - $data = array('definitions' => array(), 'aliases' => array(), 'services' => array()); + $data = ['definitions' => [], 'aliases' => [], 'services' => []]; if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); @@ -131,7 +131,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o /** * {@inheritdoc} */ - protected function describeContainerDefinition(Definition $definition, array $options = array()) + protected function describeContainerDefinition(Definition $definition, array $options = []) { $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options); } @@ -139,22 +139,22 @@ protected function describeContainerDefinition(Definition $definition, array $op /** * {@inheritdoc} */ - protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) { if (!$builder) { return $this->writeData($this->getContainerAliasData($alias), $options); } $this->writeData( - array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])), - array_merge($options, array('id' => (string) $alias)) + [$this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])], + array_merge($options, ['id' => (string) $alias]) ); } /** * {@inheritdoc} */ - protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) + protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { $this->writeData($this->getEventDispatcherListenersData($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null), $options); } @@ -162,7 +162,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev /** * {@inheritdoc} */ - protected function describeCallable($callable, array $options = array()) + protected function describeCallable($callable, array $options = []) { $this->writeData($this->getCallableData($callable, $options), $options); } @@ -170,11 +170,11 @@ protected function describeCallable($callable, array $options = array()) /** * {@inheritdoc} */ - protected function describeContainerParameter($parameter, array $options = array()) + protected function describeContainerParameter($parameter, array $options = []) { $key = isset($options['parameter']) ? $options['parameter'] : ''; - $this->writeData(array($key => $parameter), $options); + $this->writeData([$key => $parameter], $options); } /** @@ -193,7 +193,7 @@ private function writeData(array $data, array $options) */ protected function getRouteData(Route $route) { - return array( + return [ 'path' => $route->getPath(), 'pathRegex' => $route->compile()->getRegex(), 'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY', @@ -204,7 +204,7 @@ protected function getRouteData(Route $route) 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions(), - ); + ]; } /** @@ -215,7 +215,7 @@ protected function getRouteData(Route $route) */ private function getContainerDefinitionData(Definition $definition, $omitTags = false, $showArguments = false) { - $data = array( + $data = [ 'class' => (string) $definition->getClass(), 'public' => $definition->isPublic() && !$definition->isPrivate(), 'synthetic' => $definition->isSynthetic(), @@ -224,7 +224,7 @@ private function getContainerDefinitionData(Definition $definition, $omitTags = 'abstract' => $definition->isAbstract(), 'autowire' => $definition->isAutowired(), 'autoconfigure' => $definition->isAutoconfigured(), - ); + ]; // forward compatibility with DependencyInjection component in version 4.0 if (method_exists($definition, 'getAutowiringTypes')) { @@ -256,17 +256,17 @@ private function getContainerDefinitionData(Definition $definition, $omitTags = $calls = $definition->getMethodCalls(); if (\count($calls) > 0) { - $data['calls'] = array(); + $data['calls'] = []; foreach ($calls as $callData) { $data['calls'][] = $callData[0]; } } if (!$omitTags) { - $data['tags'] = array(); + $data['tags'] = []; foreach ($definition->getTags() as $tagName => $tagData) { foreach ($tagData as $parameters) { - $data['tags'][] = array('name' => $tagName, 'parameters' => $parameters); + $data['tags'][] = ['name' => $tagName, 'parameters' => $parameters]; } } } @@ -279,10 +279,10 @@ private function getContainerDefinitionData(Definition $definition, $omitTags = */ private function getContainerAliasData(Alias $alias) { - return array( + return [ 'service' => (string) $alias, 'public' => $alias->isPublic() && !$alias->isPrivate(), - ); + ]; } /** @@ -293,7 +293,7 @@ private function getContainerAliasData(Alias $alias) */ private function getEventDispatcherListenersData(EventDispatcherInterface $eventDispatcher, $event = null) { - $data = array(); + $data = []; $registeredListeners = $eventDispatcher->getListeners($event); if (null !== $event) { @@ -323,9 +323,9 @@ private function getEventDispatcherListenersData(EventDispatcherInterface $event * * @return array */ - private function getCallableData($callable, array $options = array()) + private function getCallableData($callable, array $options = []) { - $data = array(); + $data = []; if (\is_array($callable)) { $data['type'] = 'function'; @@ -397,7 +397,7 @@ private function getCallableData($callable, array $options = array()) private function describeValue($value, $omitTags, $showArguments) { if (\is_array($value)) { - $data = array(); + $data = []; foreach ($value as $k => $v) { $data[$k] = $this->describeValue($v, $omitTags, $showArguments); } @@ -410,10 +410,10 @@ private function describeValue($value, $omitTags, $showArguments) } if ($value instanceof Reference) { - return array( + return [ 'type' => 'service', 'id' => (string) $value, - ); + ]; } if ($value instanceof ArgumentInterface) { diff --git a/Console/Descriptor/MarkdownDescriptor.php b/Console/Descriptor/MarkdownDescriptor.php index 9249ca5ba..a0a0dc851 100644 --- a/Console/Descriptor/MarkdownDescriptor.php +++ b/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 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio } else { $this->write("\n\n"); } - $this->describeRoute($route, array('name' => $name)); + $this->describeRoute($route, ['name' => $name]); } $this->write("\n"); } @@ -47,7 +47,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio /** * {@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 @@ protected function describeRoute(Route $route, array $options = array()) /** * {@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 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ /** * {@inheritdoc} */ - protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) + protected function describeContainerTags(ContainerBuilder $builder, array $options = []) { $showPrivate = isset($options['show_private']) && $options['show_private']; $this->write("Container tags\n=============="); @@ -89,7 +89,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio $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 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio /** * {@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 @@ protected function describeContainerService($service, array $options = array(), /** * {@inheritdoc} */ - protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) + protected function describeContainerServices(ContainerBuilder $builder, array $options = []) { $showPrivate = isset($options['show_private']) && $options['show_private']; @@ -129,7 +129,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $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 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $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 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $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 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o /** * {@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') @@ -243,7 +243,7 @@ protected function describeContainerDefinition(Definition $definition, array $op /** * {@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'); @@ -259,13 +259,13 @@ protected function describeContainerAlias(Alias $alias, array $options = array() } $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); } @@ -273,7 +273,7 @@ protected function describeContainerParameter($parameter, array $options = array /** * {@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; @@ -309,7 +309,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev /** * {@inheritdoc} */ - protected function describeCallable($callable, array $options = array()) + protected function describeCallable($callable, array $options = []) { $string = ''; diff --git a/Console/Descriptor/TextDescriptor.php b/Console/Descriptor/TextDescriptor.php index d91743e5c..7aed45bd4 100644 --- a/Console/Descriptor/TextDescriptor.php +++ b/Console/Descriptor/TextDescriptor.php @@ -35,24 +35,24 @@ class TextDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeRouteCollection(RouteCollection $routes, array $options = array()) + protected function describeRouteCollection(RouteCollection $routes, array $options = []) { $showControllers = isset($options['show_controllers']) && $options['show_controllers']; - $tableHeaders = array('Name', 'Method', 'Scheme', 'Host', 'Path'); + $tableHeaders = ['Name', 'Method', 'Scheme', 'Host', 'Path']; if ($showControllers) { $tableHeaders[] = 'Controller'; } - $tableRows = array(); + $tableRows = []; foreach ($routes->all() as $name => $route) { - $row = array( + $row = [ $name, $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', '' !== $route->getHost() ? $route->getHost() : 'ANY', $route->getPath(), - ); + ]; if ($showControllers) { $controller = $route->getDefault('_controller'); @@ -74,24 +74,24 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio /** * {@inheritdoc} */ - protected function describeRoute(Route $route, array $options = array()) + protected function describeRoute(Route $route, array $options = []) { - $tableHeaders = array('Property', 'Value'); - $tableRows = array( - array('Route Name', isset($options['name']) ? $options['name'] : ''), - array('Path', $route->getPath()), - array('Path Regex', $route->compile()->getRegex()), - array('Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')), - array('Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')), - array('Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')), - array('Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')), - array('Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')), - array('Class', \get_class($route)), - array('Defaults', $this->formatRouterConfig($route->getDefaults())), - array('Options', $this->formatRouterConfig($route->getOptions())), - ); + $tableHeaders = ['Property', 'Value']; + $tableRows = [ + ['Route Name', isset($options['name']) ? $options['name'] : ''], + ['Path', $route->getPath()], + ['Path Regex', $route->compile()->getRegex()], + ['Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')], + ['Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')], + ['Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')], + ['Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')], + ['Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')], + ['Class', \get_class($route)], + ['Defaults', $this->formatRouterConfig($route->getDefaults())], + ['Options', $this->formatRouterConfig($route->getOptions())], + ]; if (isset($options['callable'])) { - $tableRows[] = array('Callable', $options['callable']); + $tableRows[] = ['Callable', $options['callable']]; } $table = new Table($this->getOutput()); @@ -102,13 +102,13 @@ protected function describeRoute(Route $route, array $options = array()) /** * {@inheritdoc} */ - protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) + protected function describeContainerParameters(ParameterBag $parameters, array $options = []) { - $tableHeaders = array('Parameter', 'Value'); + $tableHeaders = ['Parameter', 'Value']; - $tableRows = array(); + $tableRows = []; foreach ($this->sortParameters($parameters) as $parameter => $value) { - $tableRows[] = array($parameter, $this->formatParameter($value)); + $tableRows[] = [$parameter, $this->formatParameter($value)]; } $options['output']->title('Symfony Container Parameters'); @@ -118,7 +118,7 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ /** * {@inheritdoc} */ - protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) + protected function describeContainerTags(ContainerBuilder $builder, array $options = []) { $showPrivate = isset($options['show_private']) && $options['show_private']; @@ -137,7 +137,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio /** * {@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.'); @@ -150,10 +150,10 @@ protected function describeContainerService($service, array $options = array(), } else { $options['output']->title(sprintf('Information for Service "%s"', $options['id'])); $options['output']->table( - array('Service ID', 'Class'), - array( - array(isset($options['id']) ? $options['id'] : '-', \get_class($service)), - ) + ['Service ID', 'Class'], + [ + [isset($options['id']) ? $options['id'] : '-', \get_class($service)], + ] ); } } @@ -161,7 +161,7 @@ protected function describeContainerService($service, array $options = array(), /** * {@inheritdoc} */ - protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) + protected function describeContainerServices(ContainerBuilder $builder, array $options = []) { $showPrivate = isset($options['show_private']) && $options['show_private']; $showTag = isset($options['tag']) ? $options['tag'] : null; @@ -179,7 +179,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $options['output']->title($title); $serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds(); - $maxTags = array(); + $maxTags = []; if (isset($options['filter'])) { $serviceIds = array_filter($serviceIds, $options['filter']); @@ -217,8 +217,8 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $tagsCount = \count($maxTags); $tagsNames = array_keys($maxTags); - $tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name')); - $tableRows = array(); + $tableHeaders = array_merge(['Service ID'], $tagsNames, ['Class name']); + $tableRows = []; $rawOutput = isset($options['raw_text']) && $options['raw_text']; foreach ($this->sortServiceIds($serviceIds) as $serviceId) { $definition = $this->resolveServiceDefinition($builder, $serviceId); @@ -227,24 +227,24 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o if ($definition instanceof Definition) { if ($showTag) { foreach ($definition->getTag($showTag) as $key => $tag) { - $tagValues = array(); + $tagValues = []; foreach ($tagsNames as $tagName) { $tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : ''; } if (0 === $key) { - $tableRows[] = array_merge(array($serviceId), $tagValues, array($definition->getClass())); + $tableRows[] = array_merge([$serviceId], $tagValues, [$definition->getClass()]); } else { - $tableRows[] = array_merge(array(' "'), $tagValues, array('')); + $tableRows[] = array_merge([' "'], $tagValues, ['']); } } } else { - $tableRows[] = array($styledServiceId, $definition->getClass()); + $tableRows[] = [$styledServiceId, $definition->getClass()]; } } elseif ($definition instanceof Alias) { $alias = $definition; - $tableRows[] = array_merge(array($styledServiceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array()); + $tableRows[] = array_merge([$styledServiceId, sprintf('alias for "%s"', $alias)], $tagsCount ? array_fill(0, $tagsCount, '') : []); } else { - $tableRows[] = array_merge(array($styledServiceId, \get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array()); + $tableRows[] = array_merge([$styledServiceId, \get_class($definition)], $tagsCount ? array_fill(0, $tagsCount, '') : []); } } @@ -254,20 +254,20 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o /** * {@inheritdoc} */ - protected function describeContainerDefinition(Definition $definition, array $options = array()) + protected function describeContainerDefinition(Definition $definition, array $options = []) { if (isset($options['id'])) { $options['output']->title(sprintf('Information for Service "%s"', $options['id'])); } - $tableHeaders = array('Option', 'Value'); + $tableHeaders = ['Option', 'Value']; - $tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-'); - $tableRows[] = array('Class', $definition->getClass() ?: '-'); + $tableRows[] = ['Service ID', isset($options['id']) ? $options['id'] : '-']; + $tableRows[] = ['Class', $definition->getClass() ?: '-']; $omitTags = isset($options['omit_tags']) && $options['omit_tags']; if (!$omitTags && ($tags = $definition->getTags())) { - $tagInformation = array(); + $tagInformation = []; foreach ($tags as $tagName => $tagData) { foreach ($tagData as $tagParameters) { $parameters = array_map(function ($key, $value) { @@ -286,51 +286,51 @@ protected function describeContainerDefinition(Definition $definition, array $op } else { $tagInformation = '-'; } - $tableRows[] = array('Tags', $tagInformation); + $tableRows[] = ['Tags', $tagInformation]; $calls = $definition->getMethodCalls(); if (\count($calls) > 0) { - $callInformation = array(); + $callInformation = []; foreach ($calls as $call) { $callInformation[] = $call[0]; } - $tableRows[] = array('Calls', implode(', ', $callInformation)); + $tableRows[] = ['Calls', implode(', ', $callInformation)]; } - $tableRows[] = array('Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no'); - $tableRows[] = array('Synthetic', $definition->isSynthetic() ? 'yes' : 'no'); - $tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no'); - $tableRows[] = array('Shared', $definition->isShared() ? 'yes' : 'no'); - $tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no'); - $tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no'); - $tableRows[] = array('Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'); + $tableRows[] = ['Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no']; + $tableRows[] = ['Synthetic', $definition->isSynthetic() ? 'yes' : 'no']; + $tableRows[] = ['Lazy', $definition->isLazy() ? 'yes' : 'no']; + $tableRows[] = ['Shared', $definition->isShared() ? 'yes' : 'no']; + $tableRows[] = ['Abstract', $definition->isAbstract() ? 'yes' : 'no']; + $tableRows[] = ['Autowired', $definition->isAutowired() ? 'yes' : 'no']; + $tableRows[] = ['Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no']; // forward compatibility with DependencyInjection component in version 4.0 if (method_exists($definition, 'getAutowiringTypes') && $autowiringTypes = $definition->getAutowiringTypes(false)) { - $tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes)); + $tableRows[] = ['Autowiring Types', implode(', ', $autowiringTypes)]; } if ($definition->getFile()) { - $tableRows[] = array('Required File', $definition->getFile() ?: '-'); + $tableRows[] = ['Required File', $definition->getFile() ?: '-']; } if ($factory = $definition->getFactory()) { if (\is_array($factory)) { if ($factory[0] instanceof Reference) { - $tableRows[] = array('Factory Service', $factory[0]); + $tableRows[] = ['Factory Service', $factory[0]]; } elseif ($factory[0] instanceof Definition) { throw new \InvalidArgumentException('Factory is not describable.'); } else { - $tableRows[] = array('Factory Class', $factory[0]); + $tableRows[] = ['Factory Class', $factory[0]]; } - $tableRows[] = array('Factory Method', $factory[1]); + $tableRows[] = ['Factory Method', $factory[1]]; } else { - $tableRows[] = array('Factory Function', $factory); + $tableRows[] = ['Factory Function', $factory]; } } $showArguments = isset($options['show_arguments']) && $options['show_arguments']; - $argumentsInformation = array(); + $argumentsInformation = []; if ($showArguments && ($arguments = $definition->getArguments())) { foreach ($arguments as $argument) { if ($argument instanceof ServiceClosureArgument) { @@ -347,7 +347,7 @@ protected function describeContainerDefinition(Definition $definition, array $op } } - $tableRows[] = array('Arguments', implode("\n", $argumentsInformation)); + $tableRows[] = ['Arguments', implode("\n", $argumentsInformation)]; } $options['output']->table($tableHeaders, $tableRows); @@ -356,7 +356,7 @@ protected function describeContainerDefinition(Definition $definition, array $op /** * {@inheritdoc} */ - protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) { $options['output']->comment(sprintf('This service is an alias for the service %s', (string) $alias)); @@ -364,26 +364,26 @@ protected function describeContainerAlias(Alias $alias, array $options = array() return; } - return $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, array('id' => (string) $alias))); + return $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 = []) { $options['output']->table( - array('Parameter', 'Value'), - array( - array($options['parameter'], $this->formatParameter($parameter), - ), - )); + ['Parameter', 'Value'], + [ + [$options['parameter'], $this->formatParameter($parameter), + ], + ]); } /** * {@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; @@ -410,19 +410,19 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev /** * {@inheritdoc} */ - protected function describeCallable($callable, array $options = array()) + protected function describeCallable($callable, array $options = []) { $this->writeText($this->formatCallable($callable), $options); } private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io) { - $tableHeaders = array('Order', 'Callable', 'Priority'); - $tableRows = array(); + $tableHeaders = ['Order', 'Callable', 'Priority']; + $tableRows = []; $order = 1; foreach ($eventListeners as $order => $listener) { - $tableRows[] = array(sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)); + $tableRows[] = [sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)]; } $io->table($tableHeaders, $tableRows); @@ -491,7 +491,7 @@ private function formatCallable($callable) * @param string $content * @param array $options */ - 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, diff --git a/Console/Descriptor/XmlDescriptor.php b/Console/Descriptor/XmlDescriptor.php index b663e7622..38efe8575 100644 --- a/Console/Descriptor/XmlDescriptor.php +++ b/Console/Descriptor/XmlDescriptor.php @@ -32,7 +32,7 @@ class XmlDescriptor extends Descriptor /** * {@inheritdoc} */ - protected function describeRouteCollection(RouteCollection $routes, array $options = array()) + protected function describeRouteCollection(RouteCollection $routes, array $options = []) { $this->writeDocument($this->getRouteCollectionDocument($routes)); } @@ -40,7 +40,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio /** * {@inheritdoc} */ - protected function describeRoute(Route $route, array $options = array()) + protected function describeRoute(Route $route, array $options = []) { $this->writeDocument($this->getRouteDocument($route, isset($options['name']) ? $options['name'] : null)); } @@ -48,7 +48,7 @@ protected function describeRoute(Route $route, array $options = array()) /** * {@inheritdoc} */ - protected function describeContainerParameters(ParameterBag $parameters, array $options = array()) + protected function describeContainerParameters(ParameterBag $parameters, array $options = []) { $this->writeDocument($this->getContainerParametersDocument($parameters)); } @@ -56,7 +56,7 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ /** * {@inheritdoc} */ - protected function describeContainerTags(ContainerBuilder $builder, array $options = array()) + protected function describeContainerTags(ContainerBuilder $builder, array $options = []) { $this->writeDocument($this->getContainerTagsDocument($builder, isset($options['show_private']) && $options['show_private'])); } @@ -64,7 +64,7 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio /** * {@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.'); @@ -76,7 +76,7 @@ protected function describeContainerService($service, array $options = array(), /** * {@inheritdoc} */ - protected function describeContainerServices(ContainerBuilder $builder, array $options = array()) + protected function describeContainerServices(ContainerBuilder $builder, array $options = []) { $this->writeDocument($this->getContainerServicesDocument($builder, isset($options['tag']) ? $options['tag'] : null, isset($options['show_private']) && $options['show_private'], isset($options['show_arguments']) && $options['show_arguments'], isset($options['filter']) ? $options['filter'] : null)); } @@ -84,7 +84,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o /** * {@inheritdoc} */ - protected function describeContainerDefinition(Definition $definition, array $options = array()) + protected function describeContainerDefinition(Definition $definition, array $options = []) { $this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])); } @@ -92,7 +92,7 @@ protected function describeContainerDefinition(Definition $definition, array $op /** * {@inheritdoc} */ - protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null) + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, isset($options['id']) ? $options['id'] : null)->childNodes->item(0), true)); @@ -109,7 +109,7 @@ protected function describeContainerAlias(Alias $alias, array $options = array() /** * {@inheritdoc} */ - protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array()) + protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []) { $this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null)); } @@ -117,7 +117,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev /** * {@inheritdoc} */ - protected function describeCallable($callable, array $options = array()) + protected function describeCallable($callable, array $options = []) { $this->writeDocument($this->getCallableDocument($callable)); } @@ -125,7 +125,7 @@ protected function describeCallable($callable, array $options = array()) /** * {@inheritdoc} */ - protected function describeContainerParameter($parameter, array $options = array()) + protected function describeContainerParameter($parameter, array $options = []) { $this->writeDocument($this->getContainerParameterDocument($parameter, $options)); } @@ -413,7 +413,7 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu */ private function getArgumentNodes(array $arguments, \DOMDocument $dom) { - $nodes = array(); + $nodes = []; foreach ($arguments as $argumentKey => $argument) { $argumentXML = $dom->createElement('argument'); @@ -477,7 +477,7 @@ private function getContainerAliasDocument(Alias $alias, $id = null) /** * @return \DOMDocument */ - private function getContainerParameterDocument($parameter, $options = array()) + private function getContainerParameterDocument($parameter, $options = []) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($parameterXML = $dom->createElement('parameter')); diff --git a/Controller/AbstractController.php b/Controller/AbstractController.php index b2c72fa6f..2d0944e19 100644 --- a/Controller/AbstractController.php +++ b/Controller/AbstractController.php @@ -54,7 +54,7 @@ public function setContainer(ContainerInterface $container) public static function getSubscribedServices() { - return array( + return [ 'router' => '?'.RouterInterface::class, 'request_stack' => '?'.RequestStack::class, 'http_kernel' => '?'.HttpKernelInterface::class, @@ -67,6 +67,6 @@ public static function getSubscribedServices() 'form.factory' => '?'.FormFactoryInterface::class, 'security.token_storage' => '?'.TokenStorageInterface::class, 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, - ); + ]; } } diff --git a/Controller/ControllerNameParser.php b/Controller/ControllerNameParser.php index cc988ba43..3a758ee20 100644 --- a/Controller/ControllerNameParser.php +++ b/Controller/ControllerNameParser.php @@ -49,7 +49,7 @@ public function parse($controller) $originalController = $controller; list($bundle, $controller, $action) = $parts; $controller = str_replace('/', '\\', $controller); - $bundles = array(); + $bundles = []; try { // this throws an exception if there is no such bundle @@ -70,7 +70,7 @@ public function parse($controller) if (!\is_array($allBundles)) { // happens when HttpKernel is version 4+ - $allBundles = array($allBundles); + $allBundles = [$allBundles]; } foreach ($allBundles as $b) { diff --git a/Controller/ControllerTrait.php b/Controller/ControllerTrait.php index e9454f608..78e2bd600 100644 --- a/Controller/ControllerTrait.php +++ b/Controller/ControllerTrait.php @@ -80,7 +80,7 @@ protected function get($id) * * @final since version 3.4 */ - protected function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) + protected function generateUrl($route, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { return $this->container->get('router')->generate($route, $parameters, $referenceType); } @@ -96,7 +96,7 @@ protected function generateUrl($route, $parameters = array(), $referenceType = U * * @final since version 3.4 */ - protected function forward($controller, array $path = array(), array $query = array()) + protected function forward($controller, array $path = [], array $query = []) { $request = $this->container->get('request_stack')->getCurrentRequest(); $path['_forwarded'] = $request->attributes; @@ -132,7 +132,7 @@ protected function redirect($url, $status = 302) * * @final since version 3.4 */ - protected function redirectToRoute($route, array $parameters = array(), $status = 302) + protected function redirectToRoute($route, array $parameters = [], $status = 302) { return $this->redirect($this->generateUrl($route, $parameters), $status); } @@ -149,12 +149,12 @@ protected function redirectToRoute($route, array $parameters = array(), $status * * @final since version 3.4 */ - protected function json($data, $status = 200, $headers = array(), $context = array()) + protected function json($data, $status = 200, $headers = [], $context = []) { if ($this->container->has('serializer')) { - $json = $this->container->get('serializer')->serialize($data, 'json', array_merge(array( + $json = $this->container->get('serializer')->serialize($data, 'json', array_merge([ 'json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS, - ), $context)); + ], $context)); return new JsonResponse($json, $status, $headers, true); } @@ -254,7 +254,7 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, $messag * * @final since version 3.4 */ - protected function renderView($view, array $parameters = array()) + protected function renderView($view, array $parameters = []) { if ($this->container->has('templating')) { return $this->container->get('templating')->render($view, $parameters); @@ -278,7 +278,7 @@ protected function renderView($view, array $parameters = array()) * * @final since version 3.4 */ - protected function render($view, array $parameters = array(), Response $response = null) + protected function render($view, array $parameters = [], Response $response = null) { if ($this->container->has('templating')) { $content = $this->container->get('templating')->render($view, $parameters); @@ -308,7 +308,7 @@ protected function render($view, array $parameters = array(), Response $response * * @final since version 3.4 */ - protected function stream($view, array $parameters = array(), StreamedResponse $response = null) + protected function stream($view, array $parameters = [], StreamedResponse $response = null) { if ($this->container->has('templating')) { $templating = $this->container->get('templating'); @@ -390,7 +390,7 @@ protected function createAccessDeniedException($message = 'Access Denied.', \Exc * * @final since version 3.4 */ - protected function createForm($type, $data = null, array $options = array()) + protected function createForm($type, $data = null, array $options = []) { return $this->container->get('form.factory')->create($type, $data, $options); } @@ -405,7 +405,7 @@ protected function createForm($type, $data = null, array $options = array()) * * @final since version 3.4 */ - protected function createFormBuilder($data = null, array $options = array()) + protected function createFormBuilder($data = null, array $options = []) { return $this->container->get('form.factory')->createBuilder(FormType::class, $data, $options); } diff --git a/Controller/RedirectController.php b/Controller/RedirectController.php index ae6b6d741..244e8a0f3 100644 --- a/Controller/RedirectController.php +++ b/Controller/RedirectController.php @@ -79,7 +79,7 @@ public function redirectAction(Request $request, $route, $permanent = false, $ig throw new HttpException($permanent ? 410 : 404); } - $attributes = array(); + $attributes = []; if (false === $ignoreAttributes || \is_array($ignoreAttributes)) { $attributes = $request->attributes->get('_route_params'); unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes']); diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index f71fc8394..3beb8b7e9 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -38,10 +38,10 @@ public function collect(Request $request, Response $response, \Exception $except } } if ($request->attributes->has('_forward_controller')) { - $this->data['forward'] = array( + $this->data['forward'] = [ 'token' => $request->attributes->get('_forward_token'), 'controller' => $this->parseController($request->attributes->get('_forward_controller')), - ); + ]; } } diff --git a/DependencyInjection/Compiler/AddCacheClearerPass.php b/DependencyInjection/Compiler/AddCacheClearerPass.php index deaa6f427..4e0570b79 100644 --- a/DependencyInjection/Compiler/AddCacheClearerPass.php +++ b/DependencyInjection/Compiler/AddCacheClearerPass.php @@ -35,7 +35,7 @@ public function process(ContainerBuilder $container) return; } - $clearers = array(); + $clearers = []; foreach ($container->findTaggedServiceIds('kernel.cache_clearer', true) as $id => $attributes) { $clearers[] = new Reference($id); } diff --git a/DependencyInjection/Compiler/AddDebugLogProcessorPass.php b/DependencyInjection/Compiler/AddDebugLogProcessorPass.php index 69038cf92..b4da14501 100644 --- a/DependencyInjection/Compiler/AddDebugLogProcessorPass.php +++ b/DependencyInjection/Compiler/AddDebugLogProcessorPass.php @@ -30,6 +30,6 @@ public function process(ContainerBuilder $container) } $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/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php b/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php index a5bdfd626..77c070059 100644 --- a/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php +++ b/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php @@ -31,7 +31,7 @@ public function process(ContainerBuilder $container) 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 @@ public function process(ContainerBuilder $container) 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/DependencyInjection/Compiler/CacheCollectorPass.php b/DependencyInjection/Compiler/CacheCollectorPass.php index 60cdadb49..7f8494d98 100644 --- a/DependencyInjection/Compiler/CacheCollectorPass.php +++ b/DependencyInjection/Compiler/CacheCollectorPass.php @@ -45,21 +45,21 @@ public function process(ContainerBuilder $container) $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class); $recorder->setTags($definition->getTags()); $recorder->setPublic($definition->isPublic()); - $recorder->setArguments(array(new Reference($innerId = $id.'.recorder_inner'))); + $recorder->setArguments([new Reference($innerId = $id.'.recorder_inner')]); - $definition->setTags(array()); + $definition->setTags([]); $definition->setPublic(false); if (method_exists($definition, 'getAutowiringTypes') && $types = $definition->getAutowiringTypes(false)) { $recorder->setAutowiringTypes($types); - $definition->setAutowiringTypes(array()); + $definition->setAutowiringTypes([]); } $container->setDefinition($innerId, $definition); $container->setDefinition($id, $recorder); // Tell the collector to add the new instance - $collectorDefinition->addMethodCall('addInstance', array($id, new Reference($id))); + $collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]); $collectorDefinition->setPublic(false); } } diff --git a/DependencyInjection/Compiler/CachePoolClearerPass.php b/DependencyInjection/Compiler/CachePoolClearerPass.php index bd6908b9c..9f9b907b2 100644 --- a/DependencyInjection/Compiler/CachePoolClearerPass.php +++ b/DependencyInjection/Compiler/CachePoolClearerPass.php @@ -29,7 +29,7 @@ public function process(ContainerBuilder $container) 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/DependencyInjection/Compiler/CachePoolPass.php b/DependencyInjection/Compiler/CachePoolPass.php index e4c55a904..04ceb7563 100644 --- a/DependencyInjection/Compiler/CachePoolPass.php +++ b/DependencyInjection/Compiler/CachePoolPass.php @@ -37,14 +37,14 @@ public function process(ContainerBuilder $container) } $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 @@ public function process(ContainerBuilder $container) // 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 @@ public static function getServiceProvider(ContainerBuilder $container, $name) 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/DependencyInjection/Compiler/CachePoolPrunerPass.php b/DependencyInjection/Compiler/CachePoolPrunerPass.php index 728a38247..597f7dc06 100644 --- a/DependencyInjection/Compiler/CachePoolPrunerPass.php +++ b/DependencyInjection/Compiler/CachePoolPrunerPass.php @@ -41,7 +41,7 @@ public function process(ContainerBuilder $container) return; } - $services = array(); + $services = []; foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $tags) { $class = $container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass()); diff --git a/DependencyInjection/Compiler/FormPass.php b/DependencyInjection/Compiler/FormPass.php index a63ece1f2..0b8a1fcd6 100644 --- a/DependencyInjection/Compiler/FormPass.php +++ b/DependencyInjection/Compiler/FormPass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) $definition = $container->getDefinition('form.extension'); // Builds an array with fully-qualified type class names as keys and service IDs as values - $types = array(); + $types = []; foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) { $serviceDefinition = $container->getDefinition($serviceId); @@ -53,7 +53,7 @@ public function process(ContainerBuilder $container) $definition->replaceArgument(1, $types); - $typeExtensions = array(); + $typeExtensions = []; foreach ($this->findAndSortTaggedServices('form.type_extension', $container) as $reference) { $serviceId = (string) $reference; diff --git a/DependencyInjection/Compiler/LoggingTranslatorPass.php b/DependencyInjection/Compiler/LoggingTranslatorPass.php index 4945e1c12..886603563 100644 --- a/DependencyInjection/Compiler/LoggingTranslatorPass.php +++ b/DependencyInjection/Compiler/LoggingTranslatorPass.php @@ -47,7 +47,7 @@ public function process(ContainerBuilder $container) $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/DependencyInjection/Compiler/ProfilerPass.php b/DependencyInjection/Compiler/ProfilerPass.php index 8e15979a9..357c079c4 100644 --- a/DependencyInjection/Compiler/ProfilerPass.php +++ b/DependencyInjection/Compiler/ProfilerPass.php @@ -41,15 +41,15 @@ public function process(ContainerBuilder $container) 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/DependencyInjection/Compiler/TemplatingPass.php b/DependencyInjection/Compiler/TemplatingPass.php index 8de51211d..4eff0b6c8 100644 --- a/DependencyInjection/Compiler/TemplatingPass.php +++ b/DependencyInjection/Compiler/TemplatingPass.php @@ -32,8 +32,8 @@ public function process(ContainerBuilder $container) } 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 @@ public function process(ContainerBuilder $container) 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/DependencyInjection/Compiler/UnusedTagsPass.php b/DependencyInjection/Compiler/UnusedTagsPass.php index 264bde056..606fbd045 100644 --- a/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/DependencyInjection/Compiler/UnusedTagsPass.php @@ -21,7 +21,7 @@ */ class UnusedTagsPass implements CompilerPassInterface { - private $whitelist = array( + private $whitelist = [ 'annotations.cached_reader', 'cache.pool.clearer', 'console.command', @@ -55,7 +55,7 @@ class UnusedTagsPass implements CompilerPassInterface 'twig.loader', 'validator.constraint_validator', 'validator.initializer', - ); + ]; public function process(ContainerBuilder $container) { @@ -68,7 +68,7 @@ public function process(ContainerBuilder $container) } // check for typos - $candidates = array(); + $candidates = []; foreach ($tags as $definedTag) { if ($definedTag === $tag) { continue; diff --git a/DependencyInjection/Compiler/WorkflowGuardListenerPass.php b/DependencyInjection/Compiler/WorkflowGuardListenerPass.php index c5498adc4..ad62e1938 100644 --- a/DependencyInjection/Compiler/WorkflowGuardListenerPass.php +++ b/DependencyInjection/Compiler/WorkflowGuardListenerPass.php @@ -32,12 +32,12 @@ public function process(ContainerBuilder $container) $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/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 29086735e..6a6441a39 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -60,7 +60,7 @@ public function getConfigTreeBuilder() ->beforeNormalization() ->ifTrue(function ($v) { return !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class); }) ->then(function ($v) { - $v['assets'] = array(); + $v['assets'] = []; return $v; }) @@ -77,7 +77,7 @@ public function getConfigTreeBuilder() ->ifTrue(function ($v) { return !\is_array($v) && null !== $v; }) - ->then(function ($v) { return \is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); }) + ->then(function ($v) { return \is_bool($v) ? [] : preg_split('/\s*,\s*/', $v); }) ->end() ->prototype('scalar') ->validate() @@ -108,7 +108,7 @@ public function getConfigTreeBuilder() ->booleanNode('test')->end() ->scalarNode('default_locale')->defaultValue('en')->end() ->arrayNode('trusted_hosts') - ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end() ->prototype('scalar')->end() ->end() ->end() @@ -145,9 +145,9 @@ private function addCsrfSection(ArrayNodeDefinition $rootNode) $rootNode ->children() ->arrayNode('csrf_protection') - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => true]) ->addDefaultsIfNotSet() ->children() // defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class) @@ -167,9 +167,9 @@ private function addFormSection(ArrayNodeDefinition $rootNode) ->{!class_exists(FullStack::class) && class_exists(Form::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->children() ->arrayNode('csrf_protection') - ->treatFalseLike(array('enabled' => false)) - ->treatTrueLike(array('enabled' => true)) - ->treatNullLike(array('enabled' => true)) + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => true]) ->addDefaultsIfNotSet() ->children() ->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled @@ -244,7 +244,7 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode) ->end() ->scalarNode('service')->end() ->arrayNode('ips') - ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end() ->prototype('scalar')->end() ->end() ->end() @@ -269,10 +269,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) unset($workflows['enabled']); if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) { - $workflows = array(); + $workflows = []; } - if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), array('audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_place', 'places', 'transitions')))) { + if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_place', 'places', 'transitions']))) { $workflows = $workflows['workflows']; } @@ -284,10 +284,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) unset($workflows[$key]['enabled']); } - $v = array( + $v = [ 'enabled' => true, 'workflows' => $workflows, - ); + ]; } return $v; @@ -305,18 +305,18 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->canBeEnabled() ->end() ->enumNode('type') - ->values(array('workflow', 'state_machine')) + ->values(['workflow', 'state_machine']) ->end() ->arrayNode('marking_store') ->fixXmlConfig('argument') ->children() ->enumNode('type') - ->values(array('multiple_state', 'single_state')) + ->values(['multiple_state', 'single_state']) ->end() ->arrayNode('arguments') ->beforeNormalization() ->ifString() - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') @@ -338,7 +338,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->arrayNode('supports') ->beforeNormalization() ->ifString() - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar') ->cannotBeEmpty() @@ -397,7 +397,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->arrayNode('from') ->beforeNormalization() ->ifString() - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') @@ -407,7 +407,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) ->arrayNode('to') ->beforeNormalization() ->ifString() - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->requiresAtLeastOneElement() ->prototype('scalar') @@ -527,7 +527,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return !\is_array($v); }) - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() @@ -547,7 +547,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->canBeEnabled() ->beforeNormalization() ->ifTrue(function ($v) { return false === $v || \is_array($v) && false === $v['enabled']; }) - ->then(function () { return array('enabled' => false, 'engines' => false); }) + ->then(function () { return ['enabled' => false, 'engines' => false]; }) ->end() ->children() ->scalarNode('hinclude_default_template')->defaultNull()->end() @@ -562,7 +562,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->validate() ->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form', $v); }) ->then(function ($v) { - return array_merge(array('FrameworkBundle:Form'), $v); + return array_merge(['FrameworkBundle:Form'], $v); }) ->end() ->end() @@ -572,13 +572,13 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('engine') ->children() ->arrayNode('engines') - ->example(array('twig')) + ->example(['twig']) ->isRequired() ->requiresAtLeastOneElement() ->canBeUnset() ->beforeNormalization() ->ifTrue(function ($v) { return !\is_array($v) && false !== $v; }) - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() @@ -588,7 +588,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->arrayNode('loaders') ->beforeNormalization() ->ifTrue(function ($v) { return !\is_array($v); }) - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() @@ -616,7 +616,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->requiresAtLeastOneElement() ->beforeNormalization() ->ifTrue(function ($v) { return !\is_array($v); }) - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() @@ -660,7 +660,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->requiresAtLeastOneElement() ->beforeNormalization() ->ifTrue(function ($v) { return !\is_array($v); }) - ->then(function ($v) { return array($v); }) + ->then(function ($v) { return [$v]; }) ->end() ->prototype('scalar')->end() ->end() @@ -702,9 +702,9 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('path') ->children() ->arrayNode('fallbacks') - ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end() ->prototype('scalar')->end() - ->defaultValue(array('en')) + ->defaultValue(['en']) ->end() ->booleanNode('logging')->defaultValue($this->debug)->end() ->scalarNode('formatter')->defaultValue('translator.formatter.default')->end() @@ -744,9 +744,9 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->end() ->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end() ->arrayNode('static_method') - ->defaultValue(array('loadValidatorMetadata')) + ->defaultValue(['loadValidatorMetadata']) ->prototype('scalar')->end() - ->treatFalseLike(array()) + ->treatFalseLike([]) ->validate() ->ifTrue(function ($v) { return !\is_array($v); }) ->then(function ($v) { return (array) $v; }) @@ -925,7 +925,7 @@ private function addLockSection(ArrayNodeDefinition $rootNode) ->info('Lock configuration') ->{!class_exists(FullStack::class) && class_exists(Lock::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->beforeNormalization() - ->ifString()->then(function ($v) { return array('enabled' => true, 'resources' => $v); }) + ->ifString()->then(function ($v) { return ['enabled' => true, 'resources' => $v]; }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']); }) @@ -933,7 +933,7 @@ private function addLockSection(ArrayNodeDefinition $rootNode) $e = $v['enabled']; unset($v['enabled']); - return array('enabled' => $e, 'resources' => $v); + return ['enabled' => $e, 'resources' => $v]; }) ->end() ->addDefaultsIfNotSet() @@ -941,16 +941,16 @@ private function addLockSection(ArrayNodeDefinition $rootNode) ->children() ->arrayNode('resources') ->requiresAtLeastOneElement() - ->defaultValue(array('default' => array(class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock'))) + ->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]) ->beforeNormalization() - ->ifString()->then(function ($v) { return array('default' => $v); }) + ->ifString()->then(function ($v) { return ['default' => $v]; }) ->end() ->beforeNormalization() ->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0, \count($v) - 1); }) - ->then(function ($v) { return array('default' => $v); }) + ->then(function ($v) { return ['default' => $v]; }) ->end() ->prototype('array') - ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end() ->prototype('scalar')->end() ->end() ->end() diff --git a/DependencyInjection/FrameworkExtension.php b/DependencyInjection/FrameworkExtension.php index a7b7beaa7..a46e552a2 100644 --- a/DependencyInjection/FrameworkExtension.php +++ b/DependencyInjection/FrameworkExtension.php @@ -131,7 +131,7 @@ public function load(array $configs, ContainerBuilder $container) if (!class_exists(ContainerAwareEventDispatcher::class)) { $definition = $container->getDefinition('event_dispatcher'); $definition->setClass(EventDispatcher::class); - $definition->setArguments(array()); + $definition->setArguments([]); } if (\PHP_VERSION_ID < 70000) { @@ -204,13 +204,13 @@ public function load(array $configs, ContainerBuilder $container) if (!$container->hasParameter('debug.file_link_format')) { if (!$container->hasParameter('templating.helper.code.file_link_format')) { - $links = array( + $links = [ 'textmate' => 'txmt://open?url=file://%%f&line=%%l', 'macvim' => 'mvim://open?url=file://%%f&line=%%l', 'emacs' => 'emacs://open?url=file://%%f&line=%%l', 'sublime' => 'subl://open?url=file://%%f&line=%%l', 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l', - ); + ]; $ide = $config['ide']; $container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide)); @@ -317,14 +317,14 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('web_link.xml'); } - $this->addAnnotatedClassesToCompile(array( + $this->addAnnotatedClassesToCompile([ '**\\Controller\\', '**\\Entity\\', // Added explicitly so that we don't rely on the class map being dumped to make it work 'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller', - )); + ]); $container->registerForAutoconfiguration(Command::class) ->addTag('console.command'); @@ -353,7 +353,7 @@ public function load(array $configs, ContainerBuilder $container) $container->registerForAutoconfiguration(EventSubscriberInterface::class) ->addTag('kernel.event_subscriber'); $container->registerForAutoconfiguration(ResettableInterface::class) - ->addTag('kernel.reset', array('method' => 'reset')); + ->addTag('kernel.reset', ['method' => 'reset']); $container->registerForAutoconfiguration(PropertyListExtractorInterface::class) ->addTag('property_info.list_extractor'); $container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class) @@ -377,11 +377,11 @@ public function load(array $configs, ContainerBuilder $container) if (!$container->getParameter('kernel.debug')) { // remove tagged iterator argument for resource checkers - $container->getDefinition('config_cache_factory')->setArguments(array()); + $container->getDefinition('config_cache_factory')->setArguments([]); } if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\\Component\\Config\\ConfigCache', 'Symfony\\Component\\Config\\FileLocator', @@ -418,7 +418,7 @@ public function load(array $configs, ContainerBuilder $container) // cannot be included as commands are discovered based on the path to this class via Reflection // 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle', - )); + ]); } } @@ -511,7 +511,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ { if (!$this->isConfigEnabled($container, $config)) { // this is needed for the WebProfiler to work even if the profiler is disabled - $container->setParameter('data_collector.templates', array()); + $container->setParameter('data_collector.templates', []); return; } @@ -563,22 +563,22 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ $definition->setPublic(false); if (isset($config['matcher']['ip'])) { - $definition->addMethodCall('matchIp', array($config['matcher']['ip'])); + $definition->addMethodCall('matchIp', [$config['matcher']['ip']]); } if (isset($config['matcher']['ips'])) { - $definition->addMethodCall('matchIps', array($config['matcher']['ips'])); + $definition->addMethodCall('matchIps', [$config['matcher']['ips']]); } if (isset($config['matcher']['path'])) { - $definition->addMethodCall('matchPath', array($config['matcher']['path'])); + $definition->addMethodCall('matchPath', [$config['matcher']['path']]); } } } $container->getDefinition('profiler') ->addArgument($config['collect']) - ->addTag('kernel.reset', array('method' => 'reset')); + ->addTag('kernel.reset', ['method' => 'reset']); } private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) @@ -610,13 +610,13 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $workflowId = sprintf('%s.%s', $type, $name); // Create transitions - $transitions = array(); - $guardsConfiguration = array(); + $transitions = []; + $guardsConfiguration = []; // Global transition counter per workflow $transitionCounter = 0; foreach ($workflow['transitions'] as $transition) { if ('workflow' === $type) { - $transitionDefinition = new Definition(Workflow\Transition::class, array($transition['name'], $transition['from'], $transition['to'])); + $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]); $transitionDefinition->setPublic(false); $transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++); $container->setDefinition($transitionId, $transitionDefinition); @@ -632,7 +632,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ } elseif ('state_machine' === $type) { foreach ($transition['from'] as $from) { foreach ($transition['to'] as $to) { - $transitionDefinition = new Definition(Workflow\Transition::class, array($transition['name'], $from, $to)); + $transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from, $to]); $transitionDefinition->setPublic(false); $transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++); $container->setDefinition($transitionId, $transitionDefinition); @@ -655,11 +655,11 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $definitionDefinition->setPublic(false); $definitionDefinition->addArgument($workflow['places']); $definitionDefinition->addArgument($transitions); - $definitionDefinition->addTag('workflow.definition', array( + $definitionDefinition->addTag('workflow.definition', [ 'name' => $name, 'type' => $type, 'marking_store' => isset($workflow['marking_store']['type']) ? $workflow['marking_store']['type'] : null, - )); + ]); if (isset($workflow['initial_place'])) { $definitionDefinition->addArgument($workflow['initial_place']); } @@ -689,22 +689,22 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ // Add workflow to Registry if ($workflow['supports']) { foreach ($workflow['supports'] as $supportedClassName) { - $strategyDefinition = new Definition(Workflow\SupportStrategy\ClassInstanceSupportStrategy::class, array($supportedClassName)); + $strategyDefinition = new Definition(Workflow\SupportStrategy\ClassInstanceSupportStrategy::class, [$supportedClassName]); $strategyDefinition->setPublic(false); - $registryDefinition->addMethodCall('add', array(new Reference($workflowId), $strategyDefinition)); + $registryDefinition->addMethodCall('add', [new Reference($workflowId), $strategyDefinition]); } } elseif (isset($workflow['support_strategy'])) { - $registryDefinition->addMethodCall('add', array(new Reference($workflowId), new Reference($workflow['support_strategy']))); + $registryDefinition->addMethodCall('add', [new Reference($workflowId), new Reference($workflow['support_strategy'])]); } // Enable the AuditTrail if ($workflow['audit_trail']['enabled']) { $listener = new Definition(Workflow\EventListener\AuditTrailListener::class); $listener->setPrivate(true); - $listener->addTag('monolog.logger', array('channel' => 'workflow')); - $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave')); - $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition')); - $listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter')); + $listener->addTag('monolog.logger', ['channel' => 'workflow']); + $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave']); + $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition']); + $listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter']); $listener->addArgument(new Reference('logger')); $container->setDefinition(sprintf('%s.listener.audit_trail', $workflowId), $listener); } @@ -722,7 +722,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ $guard = new Definition(Workflow\EventListener\GuardListener::class); $guard->setPrivate(true); - $guard->setArguments(array( + $guard->setArguments([ $guardsConfiguration, new Reference('workflow.security.expression_language'), new Reference('security.token_storage'), @@ -730,9 +730,9 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $ new Reference('security.authentication.trust_resolver'), new Reference('security.role_hierarchy'), new Reference('validator', ContainerInterface::NULL_ON_INVALID_REFERENCE), - )); + ]); foreach ($guardsConfiguration as $eventName => $config) { - $guard->addTag('kernel.event_listener', array('event' => $eventName, 'method' => 'onTransition')); + $guard->addTag('kernel.event_listener', ['event' => $eventName, 'method' => 'onTransition']); } $container->setDefinition(sprintf('%s.listener.guard', $workflowId), $guard); @@ -751,7 +751,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con $container->register('debug.stopwatch', Stopwatch::class) ->addArgument(true) ->setPrivate(true) - ->addTag('kernel.reset', array('method' => 'reset')); + ->addTag('kernel.reset', ['method' => 'reset']); $container->setAlias(Stopwatch::class, new Alias('debug.stopwatch', false)); } @@ -815,36 +815,36 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co $container->setParameter('request_listener.https_port', $config['https_port']); if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 'Symfony\\Component\\Routing\\RequestContext', 'Symfony\\Component\\Routing\\Router', 'Symfony\\Bundle\\FrameworkBundle\\Routing\\RedirectableUrlMatcher', $container->findDefinition('router.default')->getClass(), - )); + ]); } if ($this->annotationsConfigEnabled) { $container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class) ->setPublic(false) - ->addTag('routing.loader', array('priority' => -10)) + ->addTag('routing.loader', ['priority' => -10]) ->addArgument(new Reference('annotation_reader')); $container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class) ->setPublic(false) - ->addTag('routing.loader', array('priority' => -10)) - ->setArguments(array( + ->addTag('routing.loader', ['priority' => -10]) + ->setArguments([ new Reference('file_locator'), new Reference('routing.loader.annotation'), - )); + ]); $container->register('routing.loader.annotation.file', AnnotationFileLoader::class) ->setPublic(false) - ->addTag('routing.loader', array('priority' => -10)) - ->setArguments(array( + ->addTag('routing.loader', ['priority' => -10]) + ->setArguments([ new Reference('file_locator'), new Reference('routing.loader.annotation'), - )); + ]); } } @@ -860,8 +860,8 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c // session storage $container->setAlias('session.storage', $config['storage_id'])->setPrivate(true); - $options = array('cache_limiter' => '0'); - foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode') as $key) { + $options = ['cache_limiter' => '0']; + foreach (['name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode'] as $key) { if (isset($config[$key])) { $options[$key] = $config[$key]; } @@ -881,7 +881,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c $container->setParameter('session.save_path', $config['save_path']); if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\\Component\\HttpKernel\\EventListener\\SessionListener', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage', @@ -889,12 +889,12 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy', 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy', $container->getDefinition('session')->getClass(), - )); + ]); if ($container->hasDefinition($config['storage_id'])) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ $container->findDefinition('session.storage')->getClass(), - )); + ]); } } @@ -925,11 +925,11 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder $logger = new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE); $container->getDefinition('templating.loader.cache') - ->addTag('monolog.logger', array('channel' => 'templating')) - ->addMethodCall('setLogger', array($logger)); + ->addTag('monolog.logger', ['channel' => 'templating']) + ->addMethodCall('setLogger', [$logger]); $container->getDefinition('templating.loader.chain') - ->addTag('monolog.logger', array('channel' => 'templating')) - ->addMethodCall('setLogger', array($logger)); + ->addTag('monolog.logger', ['channel' => 'templating']) + ->addMethodCall('setLogger', [$logger]); } if (!empty($config['loaders'])) { @@ -955,12 +955,12 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder } if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateReference', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\TemplateNameParser', $container->findDefinition('templating.locator')->getClass(), - )); + ]); } $container->setParameter('templating.engines', $config['engines']); @@ -972,13 +972,13 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder } else { $templateEngineDefinition = $container->getDefinition('templating.engine.delegating'); foreach ($engines as $engine) { - $templateEngineDefinition->addMethodCall('addEngine', array($engine)); + $templateEngineDefinition->addMethodCall('addEngine', [$engine]); } $container->setAlias('templating', 'templating.engine.delegating')->setPublic(true); } $container->getDefinition('fragment.renderer.hinclude') - ->addTag('kernel.fragment_renderer', array('alias' => 'hinclude')) + ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude']) ->replaceArgument(0, new Reference('templating')) ; @@ -1008,11 +1008,11 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder } if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\\Component\\Templating\\Storage\\FileStorage', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine', 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader', - )); + ]); } if ($container->has('assets.packages')) { @@ -1048,7 +1048,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co $defaultPackage = $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion); $container->setDefinition('assets._default_package', $defaultPackage); - $namedPackages = array(); + $namedPackages = []; foreach ($config['packages'] as $name => $package) { if (null !== $package['version_strategy']) { $version = new Reference($package['version_strategy']); @@ -1160,13 +1160,13 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $container->setAlias('translator', 'translator.default')->setPublic(true); $container->setAlias('translator.formatter', new Alias($config['formatter'], false)); $translator = $container->findDefinition('translator.default'); - $translator->addMethodCall('setFallbackLocales', array($config['fallbacks'])); + $translator->addMethodCall('setFallbackLocales', [$config['fallbacks']]); $container->setParameter('translator.logging', $config['logging']); $container->setParameter('translator.default_path', $config['default_path']); // Discover translation directories - $dirs = array(); + $dirs = []; if (class_exists('Symfony\Component\Validator\Validation')) { $r = new \ReflectionClass('Symfony\Component\Validator\Validation'); @@ -1210,7 +1210,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder // Register translation resources if ($dirs) { - $files = array(); + $files = []; $finder = Finder::create() ->followLinks() ->files() @@ -1224,7 +1224,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder foreach ($finder as $file) { list(, $locale) = explode('.', $file->getBasename(), 3); if (!isset($files[$locale])) { - $files[$locale] = array(); + $files[$locale] = []; } $files[$locale][] = (string) $file; @@ -1232,7 +1232,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $options = array_merge( $translator->getArgument(4), - array('resource_files' => $files) + ['resource_files' => $files] ); $translator->replaceArgument(4, $options); @@ -1259,15 +1259,15 @@ private function registerValidationConfiguration(array $config, ContainerBuilder $container->setParameter('validator.translation_domain', $config['translation_domain']); - $files = array('xml' => array(), 'yml' => array()); + $files = ['xml' => [], 'yml' => []]; $this->registerValidatorMapping($container, $config, $files); if (!empty($files['xml'])) { - $validatorBuilder->addMethodCall('addXmlMappings', array($files['xml'])); + $validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]); } if (!empty($files['yml'])) { - $validatorBuilder->addMethodCall('addYamlMappings', array($files['yml'])); + $validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]); } $definition = $container->findDefinition('validator.email'); @@ -1278,12 +1278,12 @@ private function registerValidationConfiguration(array $config, ContainerBuilder throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.'); } - $validatorBuilder->addMethodCall('enableAnnotationMapping', array(new Reference('annotation_reader'))); + $validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]); } if (array_key_exists('static_method', $config) && $config['static_method']) { foreach ($config['static_method'] as $methodName) { - $validatorBuilder->addMethodCall('addMethodMapping', array($methodName)); + $validatorBuilder->addMethodCall('addMethodMapping', [$methodName]); } } @@ -1293,9 +1293,9 @@ private function registerValidationConfiguration(array $config, ContainerBuilder 'validator_'.$this->getKernelRootHash($container) ); - $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache']))); + $validatorBuilder->addMethodCall('setMetadataCache', [new Reference($config['cache'])]); } elseif (!$container->getParameter('kernel.debug')) { - $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference('validator.mapping.cache.symfony'))); + $validatorBuilder->addMethodCall('setMetadataCache', [new Reference('validator.mapping.cache.symfony')]); } } @@ -1377,7 +1377,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { $container->getDefinition('annotations.dummy_registry') - ->setMethodCalls(array(array('registerLoader', array('class_exists')))); + ->setMethodCalls([['registerLoader', ['class_exists']]]); } if ('none' !== $config['cache']) { @@ -1395,10 +1395,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde $definition->addTag('kernel.cache_warmer'); if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\Component\Cache\Adapter\PhpArrayAdapter', 'Symfony\Component\Cache\DoctrineProvider', - )); + ]); } } elseif ('file' === $config['cache']) { $cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']); @@ -1486,7 +1486,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder $container->removeDefinition('serializer.encoder.yaml'); } - $serializerLoaders = array(); + $serializerLoaders = []; if (isset($config['enable_annotations']) && $config['enable_annotations']) { if (!$this->annotationsConfigEnabled) { throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.'); @@ -1494,7 +1494,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder $annotationLoader = new Definition( 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', - array(new Reference('annotation_reader')) + [new Reference('annotation_reader')] ); $annotationLoader->setPublic(false); @@ -1502,7 +1502,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder } $fileRecorder = function ($extension, $path) use (&$serializerLoaders) { - $definition = new Definition(\in_array($extension, array('yaml', 'yml')) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($path)); + $definition = new Definition(\in_array($extension, ['yaml', 'yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]); $definition->setPublic(false); $serializerLoaders[] = $definition; }; @@ -1548,10 +1548,10 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder } elseif (!$container->getParameter('kernel.debug')) { $cacheMetadataFactory = new Definition( CacheClassMetadataFactory::class, - array( + [ new Reference('serializer.mapping.cache_class_metadata_factory.inner'), new Reference('serializer.mapping.cache.symfony'), - ) + ] ); $cacheMetadataFactory->setPublic(false); $cacheMetadataFactory->setDecoratedService('serializer.mapping.class_metadata_factory'); @@ -1564,7 +1564,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder } if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) { - $container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', array(new Reference($config['circular_reference_handler']))); + $container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', [new Reference($config['circular_reference_handler'])]); } } @@ -1581,8 +1581,8 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container, if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) { $definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor'); $definition->setPrivate(true); - $definition->addTag('property_info.description_extractor', array('priority' => -1000)); - $definition->addTag('property_info.type_extractor', array('priority' => -1001)); + $definition->addTag('property_info.description_extractor', ['priority' => -1000]); + $definition->addTag('property_info.type_extractor', ['priority' => -1001]); } } @@ -1596,7 +1596,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont } // Generate stores - $storeDefinitions = array(); + $storeDefinitions = []; foreach ($resourceStores as $storeDsn) { $storeDsn = $container->resolveEnvPlaceholders($storeDsn, null, $usedEnvs); switch (true) { @@ -1610,15 +1610,15 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont if (!$container->hasDefinition($connectionDefinitionId = $container->hash($storeDsn))) { $connectionDefinition = new Definition(\stdClass::class); $connectionDefinition->setPublic(false); - $connectionDefinition->setFactory(array(AbstractAdapter::class, 'createConnection')); - $connectionDefinition->setArguments(array($storeDsn, array('lazy' => true))); + $connectionDefinition->setFactory([AbstractAdapter::class, 'createConnection']); + $connectionDefinition->setArguments([$storeDsn, ['lazy' => true]]); $container->setDefinition($connectionDefinitionId, $connectionDefinition); } $storeDefinition = new Definition(StoreInterface::class); $storeDefinition->setPublic(false); - $storeDefinition->setFactory(array(StoreFactory::class, 'createStore')); - $storeDefinition->setArguments(array(new Reference($connectionDefinitionId))); + $storeDefinition->setFactory([StoreFactory::class, 'createStore']); + $storeDefinition->setArguments([new Reference($connectionDefinitionId)]); $container->setDefinition($storeDefinitionId = 'lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition); @@ -1648,8 +1648,8 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont // Generate services for lock instances $lockDefinition = new Definition(Lock::class); $lockDefinition->setPublic(false); - $lockDefinition->setFactory(array(new Reference('lock.'.$resourceName.'.factory'), 'createLock')); - $lockDefinition->setArguments(array($resourceName)); + $lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']); + $lockDefinition->setArguments([$resourceName]); $container->setDefinition('lock.'.$resourceName, $lockDefinition); // provide alias for default resource @@ -1678,16 +1678,16 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con // Inline any env vars referenced in the parameter $container->setParameter('cache.prefix.seed', $container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true)); } - foreach (array('doctrine', 'psr6', 'redis', 'memcached') as $name) { + foreach (['doctrine', 'psr6', 'redis', 'memcached'] as $name) { if (isset($config[$name = 'default_'.$name.'_provider'])) { $container->setAlias('cache.'.$name, new Alias(Compiler\CachePoolPass::getServiceProvider($container, $config[$name]), false)); } } - foreach (array('app', 'system') as $name) { - $config['pools']['cache.'.$name] = array( + foreach (['app', 'system'] as $name) { + $config['pools']['cache.'.$name] = [ 'adapter' => $config[$name], 'public' => true, - ); + ]; } foreach ($config['pools'] as $name => $pool) { $definition = new ChildDefinition($pool['adapter']); @@ -1703,22 +1703,22 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con $propertyAccessDefinition->setPublic(false); if (!$container->getParameter('kernel.debug')) { - $propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache')); - $propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); - $propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.system_clearer')); - $propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache')); + $propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']); + $propertyAccessDefinition->setArguments([null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]); + $propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']); + $propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']); } else { $propertyAccessDefinition->setClass(ArrayAdapter::class); - $propertyAccessDefinition->setArguments(array(0, false)); + $propertyAccessDefinition->setArguments([0, false]); } } if (\PHP_VERSION_ID < 70000) { - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Symfony\Component\Cache\Adapter\ApcuAdapter', 'Symfony\Component\Cache\Adapter\FilesystemAdapter', 'Symfony\Component\Cache\CacheItem', - )); + ]); } } diff --git a/EventListener/ResolveControllerNameSubscriber.php b/EventListener/ResolveControllerNameSubscriber.php index 5fb6c3b56..ffb32b2f2 100644 --- a/EventListener/ResolveControllerNameSubscriber.php +++ b/EventListener/ResolveControllerNameSubscriber.php @@ -41,8 +41,8 @@ public function onKernelRequest(GetResponseEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 24), - ); + return [ + KernelEvents::REQUEST => ['onKernelRequest', 24], + ]; } } diff --git a/FrameworkBundle.php b/FrameworkBundle.php index 3288c4b1a..daf7a37bf 100644 --- a/FrameworkBundle.php +++ b/FrameworkBundle.php @@ -84,13 +84,13 @@ public function build(ContainerBuilder $container) { 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/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index d9bd45635..6d79c6a90 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -37,7 +37,7 @@ public function __construct(KernelInterface $kernel, $cacheDir = null) $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 @@ protected function forward(Request $request, $raw = false, Response $entry = nul */ protected function getOptions() { - return array(); + return []; } protected function createSurrogate() diff --git a/Kernel/MicroKernelTrait.php b/Kernel/MicroKernelTrait.php index 813458901..3d4e7b9af 100644 --- a/Kernel/MicroKernelTrait.php +++ b/Kernel/MicroKernelTrait.php @@ -62,12 +62,12 @@ abstract protected function configureContainer(ContainerBuilder $c, LoaderInterf public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function (ContainerBuilder $container) use ($loader) { - $container->loadFromExtension('framework', array( - 'router' => array( + $container->loadFromExtension('framework', [ + 'router' => [ 'resource' => 'kernel:loadRoutes', 'type' => 'service', - ), - )); + ], + ]); if ($this instanceof EventSubscriberInterface) { $container->register('kernel', static::class) diff --git a/Routing/AnnotatedRouteControllerLoader.php b/Routing/AnnotatedRouteControllerLoader.php index 474c72556..51419c891 100644 --- a/Routing/AnnotatedRouteControllerLoader.php +++ b/Routing/AnnotatedRouteControllerLoader.php @@ -43,14 +43,14 @@ protected function configureRoute(Route $route, \ReflectionClass $class, \Reflec */ 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/Routing/RedirectableUrlMatcher.php b/Routing/RedirectableUrlMatcher.php index 5571c74e8..fd1594c88 100644 --- a/Routing/RedirectableUrlMatcher.php +++ b/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 @@ public function redirect($path, $route, $scheme = null) 'httpPort' => $this->context->getHttpPort(), 'httpsPort' => $this->context->getHttpsPort(), '_route' => $route, - ); + ]; } } diff --git a/Routing/Router.php b/Routing/Router.php index 3904996aa..a846536a4 100644 --- a/Routing/Router.php +++ b/Routing/Router.php @@ -30,7 +30,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface { private $container; - private $collectedParameters = array(); + private $collectedParameters = []; /** * @param ContainerInterface $container A ContainerInterface instance @@ -38,7 +38,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI * @param array $options An array of options * @param RequestContext $context The context */ - public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null) + public function __construct(ContainerInterface $container, $resource, array $options = [], RequestContext $context = null) { $this->container = $container; @@ -99,13 +99,13 @@ private function resolveParameters(RouteCollection $collection) $route->setPath($this->resolve($route->getPath())); $route->setHost($this->resolve($route->getHost())); - $schemes = array(); + $schemes = []; foreach ($route->getSchemes() as $scheme) { $schemes = array_merge($schemes, explode('|', $this->resolve($scheme))); } $route->setSchemes($schemes); - $methods = array(); + $methods = []; foreach ($route->getMethods() as $method) { $methods = array_merge($methods, explode('|', $this->resolve($method))); } @@ -170,8 +170,8 @@ private function resolve($value) */ public static function getSubscribedServices() { - return array( + return [ 'routing.loader' => LoaderInterface::class, - ); + ]; } } diff --git a/Templating/DelegatingEngine.php b/Templating/DelegatingEngine.php index 07bf39f5b..f40760fc9 100644 --- a/Templating/DelegatingEngine.php +++ b/Templating/DelegatingEngine.php @@ -43,7 +43,7 @@ public function getEngine($name) /** * {@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/Templating/EngineInterface.php b/Templating/EngineInterface.php index cc0d573ee..0b3a8b320 100644 --- a/Templating/EngineInterface.php +++ b/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/Templating/Helper/ActionsHelper.php b/Templating/Helper/ActionsHelper.php index 76a6046d9..70e5a314b 100644 --- a/Templating/Helper/ActionsHelper.php +++ b/Templating/Helper/ActionsHelper.php @@ -39,7 +39,7 @@ public function __construct(FragmentHandler $handler) * * @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 @@ public function render($uri, array $options = array()) 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/Templating/Helper/CodeHelper.php b/Templating/Helper/CodeHelper.php index c4087a2f3..c8914c3a5 100644 --- a/Templating/Helper/CodeHelper.php +++ b/Templating/Helper/CodeHelper.php @@ -78,7 +78,7 @@ public function abbrMethod($method) */ 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 @@ public function fileExcerpt($file, $line) $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 @@ public function formatFile($file, $line, $text = null) $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 @@ public function formatFile($file, $line, $text = null) 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/Templating/Helper/FormHelper.php b/Templating/Helper/FormHelper.php index a07b0500e..9e602b2ae 100644 --- a/Templating/Helper/FormHelper.php +++ b/Templating/Helper/FormHelper.php @@ -76,7 +76,7 @@ public function setTheme(FormView $view, $themes, $useDefaultThemes = true) * * @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 @@ public function form(FormView $view, array $variables = array()) * * @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 @@ public function start(FormView $view, array $variables = array()) * * @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); } @@ -133,7 +133,7 @@ public function end(FormView $view, array $variables = array()) * * @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 @@ public function widget(FormView $view, array $variables = array()) * * @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 @@ public function row(FormView $view, array $variables = array()) * * @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); @@ -187,7 +187,7 @@ public function errors(FormView $view) * * @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); } @@ -201,7 +201,7 @@ public function rest(FormView $view, array $variables = array()) * * @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/Templating/Helper/RouterHelper.php b/Templating/Helper/RouterHelper.php index 683efd597..f24247908 100644 --- a/Templating/Helper/RouterHelper.php +++ b/Templating/Helper/RouterHelper.php @@ -39,7 +39,7 @@ public function __construct(UrlGeneratorInterface $router) * * @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 @@ public function path($name, $parameters = array(), $relative = false) * * @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/Templating/Helper/SessionHelper.php b/Templating/Helper/SessionHelper.php index 4de6e7eec..072c1d3d2 100644 --- a/Templating/Helper/SessionHelper.php +++ b/Templating/Helper/SessionHelper.php @@ -42,7 +42,7 @@ public function get($name, $default = null) 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/Templating/Helper/StopwatchHelper.php b/Templating/Helper/StopwatchHelper.php index 72269ec69..55232c462 100644 --- a/Templating/Helper/StopwatchHelper.php +++ b/Templating/Helper/StopwatchHelper.php @@ -33,11 +33,11 @@ public function getName() 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/Templating/Helper/TranslatorHelper.php b/Templating/Helper/TranslatorHelper.php index 5c4a9ae0f..4846cb110 100644 --- a/Templating/Helper/TranslatorHelper.php +++ b/Templating/Helper/TranslatorHelper.php @@ -29,7 +29,7 @@ public function __construct(TranslatorInterface $translator) /** * @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 @@ public function trans($id, array $parameters = array(), $domain = 'messages', $l /** * @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/Templating/Loader/TemplateLocator.php b/Templating/Loader/TemplateLocator.php index dc57cc096..b90b9a275 100644 --- a/Templating/Loader/TemplateLocator.php +++ b/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/Templating/PhpEngine.php b/Templating/PhpEngine.php index bad7c1793..ef9c43b8f 100644 --- a/Templating/PhpEngine.php +++ b/Templating/PhpEngine.php @@ -65,7 +65,7 @@ public function setHelpers(array $helpers) /** * {@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/Templating/TemplateNameParser.php b/Templating/TemplateNameParser.php index f1e54af31..22dbe3c97 100644 --- a/Templating/TemplateNameParser.php +++ b/Templating/TemplateNameParser.php @@ -25,7 +25,7 @@ class TemplateNameParser extends BaseTemplateNameParser { protected $kernel; - protected $cache = array(); + protected $cache = []; public function __construct(KernelInterface $kernel) { diff --git a/Templating/TemplateReference.php b/Templating/TemplateReference.php index d9bc982d7..8f1daf859 100644 --- a/Templating/TemplateReference.php +++ b/Templating/TemplateReference.php @@ -22,13 +22,13 @@ class TemplateReference extends BaseTemplateReference { public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null) { - $this->parameters = array( + $this->parameters = [ 'bundle' => $bundle, 'controller' => $controller, 'name' => $name, 'format' => $format, 'engine' => $engine, - ); + ]; } /** diff --git a/Templating/TimedPhpEngine.php b/Templating/TimedPhpEngine.php index 3263ea24d..783e675f9 100644 --- a/Templating/TimedPhpEngine.php +++ b/Templating/TimedPhpEngine.php @@ -35,7 +35,7 @@ public function __construct(TemplateNameParserInterface $parser, ContainerInterf /** * {@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/Test/KernelTestCase.php b/Test/KernelTestCase.php index 4febf5033..0feb15380 100644 --- a/Test/KernelTestCase.php +++ b/Test/KernelTestCase.php @@ -158,7 +158,7 @@ protected static function getKernelClass() * * @return KernelInterface A KernelInterface instance */ - protected static function bootKernel(array $options = array()) + protected static function bootKernel(array $options = []) { static::ensureKernelShutdown(); @@ -178,7 +178,7 @@ protected static function bootKernel(array $options = array()) * * @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/Test/WebTestCase.php b/Test/WebTestCase.php index 7302dc78a..e56e938dd 100644 --- a/Test/WebTestCase.php +++ b/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/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php index b32274e7e..9cc3bfa2d 100644 --- a/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php +++ b/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php @@ -34,7 +34,7 @@ protected function tearDown() 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 @@ public function testAnnotationsCacheWarmerWithDebugDisabled() 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/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php b/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php index 5e442d662..20eb58ed7 100644 --- a/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php +++ b/Tests/CacheWarmer/ClassCacheCacheWarmerTest.php @@ -27,9 +27,9 @@ public function testWithDeclaredClasses() $dir = sys_get_temp_dir(); @unlink($dir.'/classes.php'); - file_put_contents($dir.'/classes.map', sprintf('warmUp($dir); diff --git a/Tests/CacheWarmer/SerializerCacheWarmerTest.php b/Tests/CacheWarmer/SerializerCacheWarmerTest.php index fdd40d48d..50a5abf0a 100644 --- a/Tests/CacheWarmer/SerializerCacheWarmerTest.php +++ b/Tests/CacheWarmer/SerializerCacheWarmerTest.php @@ -28,10 +28,10 @@ public function testWarmUp() $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 @@ public function testWarmUpWithoutLoader() $fallbackPool = new ArrayAdapter(); - $warmer = new SerializerCacheWarmer(array(), $file, $fallbackPool); + $warmer = new SerializerCacheWarmer([], $file, $fallbackPool); $warmer->warmUp(\dirname($file)); $this->assertFileExists($file); diff --git a/Tests/CacheWarmer/TemplateFinderTest.php b/Tests/CacheWarmer/TemplateFinderTest.php index 5da592c35..94b5432c3 100644 --- a/Tests/CacheWarmer/TemplateFinderTest.php +++ b/Tests/CacheWarmer/TemplateFinderTest.php @@ -34,7 +34,7 @@ public function testFindAllTemplates() $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/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 75d5934c7..30d024266 100644 --- a/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -39,13 +39,13 @@ protected function setUp() { $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 @@ public function testWarmUp() $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 @@ public function testWarmUpEmpty() $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $this->fileLocator ->expects($this->never()) diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index d021b0a29..ba253d1d1 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -54,7 +54,7 @@ public function testEnableRebootKernel() private function getKernelMock() { $mock = $this->getMockBuilder($this->getKernelClass()) - ->setMethods(array('shutdown', 'boot', 'handle')) + ->setMethods(['shutdown', 'boot', 'handle']) ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index e2104d36f..f211f2838 100644 --- a/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -45,7 +45,7 @@ protected function tearDown() 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/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php b/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php index 213d75ecc..1022b31a4 100644 --- a/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php +++ b/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/Tests/Command/CachePruneCommandTest.php b/Tests/Command/CachePruneCommandTest.php index 5356f4a0a..3a603122e 100644 --- a/Tests/Command/CachePruneCommandTest.php +++ b/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([]); } /** @@ -50,7 +50,7 @@ private function getRewindableGenerator() private function getEmptyRewindableGenerator() { return new RewindableGenerator(function () { - return new \ArrayIterator(array()); + return new \ArrayIterator([]); }, 0); } @@ -75,7 +75,7 @@ private function getKernel() $kernel ->expects($this->once()) ->method('getBundles') - ->willReturn(array()); + ->willReturn([]); return $kernel; } diff --git a/Tests/Command/RouterDebugCommandTest.php b/Tests/Command/RouterDebugCommandTest.php index 8422c0277..35a9e4ac0 100644 --- a/Tests/Command/RouterDebugCommandTest.php +++ b/Tests/Command/RouterDebugCommandTest.php @@ -24,7 +24,7 @@ class RouterDebugCommandTest extends TestCase public function testDebugAllRoutes() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => null), array('decorated' => false)); + $ret = $tester->execute(['name' => null], ['decorated' => false]); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Name Method Scheme Host Path', $tester->getDisplay()); @@ -33,7 +33,7 @@ public function testDebugAllRoutes() public function testDebugSingleRoute() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('name' => 'foo'), array('decorated' => false)); + $ret = $tester->execute(['name' => 'foo'], ['decorated' => false]); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Route Name | foo', $tester->getDisplay()); @@ -44,7 +44,7 @@ public function testDebugSingleRoute() */ public function testDebugInvalidRoute() { - $this->createCommandTester()->execute(array('name' => 'test')); + $this->createCommandTester()->execute(['name' => 'test']); } /** @@ -58,7 +58,7 @@ public function testLegacyDebugCommand() $tester = new CommandTester($application->find('debug:router')); - $tester->execute(array()); + $tester->execute([]); $this->assertRegExp('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay()); } @@ -117,7 +117,7 @@ private function getKernel() $kernel ->expects($this->once()) ->method('getBundles') - ->willReturn(array()) + ->willReturn([]) ; return $kernel; diff --git a/Tests/Command/RouterMatchCommandTest.php b/Tests/Command/RouterMatchCommandTest.php index 0b07bc9f5..e8d31778a 100644 --- a/Tests/Command/RouterMatchCommandTest.php +++ b/Tests/Command/RouterMatchCommandTest.php @@ -26,7 +26,7 @@ class RouterMatchCommandTest extends TestCase public function testWithMatchPath() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('path_info' => '/foo', 'foo'), array('decorated' => false)); + $ret = $tester->execute(['path_info' => '/foo', 'foo'], ['decorated' => false]); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Route Name | foo', $tester->getDisplay()); @@ -35,7 +35,7 @@ public function testWithMatchPath() public function testWithNotMatchPath() { $tester = $this->createCommandTester(); - $ret = $tester->execute(array('path_info' => '/test', 'foo'), array('decorated' => false)); + $ret = $tester->execute(['path_info' => '/test', 'foo'], ['decorated' => false]); $this->assertEquals(1, $ret, 'Returns 1 in case of failure'); $this->assertContains('None of the routes match the path "/test"', $tester->getDisplay()); @@ -54,7 +54,7 @@ public function testLegacyMatchCommand() $tester = new CommandTester($application->find('router:match')); - $tester->execute(array('path_info' => '/')); + $tester->execute(['path_info' => '/']); $this->assertContains('None of the routes match the path "/"', $tester->getDisplay()); } @@ -119,7 +119,7 @@ private function getKernel() $kernel ->expects($this->once()) ->method('getBundles') - ->willReturn(array()) + ->willReturn([]) ; return $kernel; diff --git a/Tests/Command/TranslationDebugCommandTest.php b/Tests/Command/TranslationDebugCommandTest.php index f026945bc..622033e89 100644 --- a/Tests/Command/TranslationDebugCommandTest.php +++ b/Tests/Command/TranslationDebugCommandTest.php @@ -25,24 +25,24 @@ class TranslationDebugCommandTest extends TestCase public function testDebugMissingMessages() { - $tester = $this->createCommandTester(array('foo' => 'foo')); - $tester->execute(array('locale' => 'en', 'bundle' => 'foo')); + $tester = $this->createCommandTester(['foo' => 'foo']); + $tester->execute(['locale' => 'en', 'bundle' => 'foo']); $this->assertRegExp('/missing/', $tester->getDisplay()); } public function testDebugUnusedMessages() { - $tester = $this->createCommandTester(array(), array('foo' => 'foo')); - $tester->execute(array('locale' => 'en', 'bundle' => 'foo')); + $tester = $this->createCommandTester([], ['foo' => 'foo']); + $tester->execute(['locale' => 'en', 'bundle' => 'foo']); $this->assertRegExp('/unused/', $tester->getDisplay()); } public function testDebugFallbackMessages() { - $tester = $this->createCommandTester(array(), array('foo' => 'foo')); - $tester->execute(array('locale' => 'fr', 'bundle' => 'foo')); + $tester = $this->createCommandTester([], ['foo' => 'foo']); + $tester->execute(['locale' => 'fr', 'bundle' => 'foo']); $this->assertRegExp('/fallback/', $tester->getDisplay()); } @@ -50,15 +50,15 @@ public function testDebugFallbackMessages() public function testNoDefinedMessages() { $tester = $this->createCommandTester(); - $tester->execute(array('locale' => 'fr', 'bundle' => 'test')); + $tester->execute(['locale' => 'fr', 'bundle' => 'test']); $this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay()); } public function testDebugDefaultDirectory() { - $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar')); - $tester->execute(array('locale' => 'en')); + $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); + $tester->execute(['locale' => 'en']); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); @@ -72,8 +72,8 @@ public function testDebugDefaultRootDirectory() $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); - $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar')); - $tester->execute(array('locale' => 'en')); + $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); + $tester->execute(['locale' => 'en']); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); @@ -87,8 +87,8 @@ public function testDebugCustomDirectory() ->with($this->equalTo($this->translationDir)) ->willThrowException(new \InvalidArgumentException()); - $tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'), $kernel); - $tester->execute(array('locale' => 'en', 'bundle' => $this->translationDir)); + $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar'], $kernel); + $tester->execute(['locale' => 'en', 'bundle' => $this->translationDir]); $this->assertRegExp('/missing/', $tester->getDisplay()); $this->assertRegExp('/unused/', $tester->getDisplay()); @@ -105,8 +105,8 @@ public function testDebugInvalidDirectory() ->with($this->equalTo('dir')) ->willThrowException(new \InvalidArgumentException()); - $tester = $this->createCommandTester(array(), array(), $kernel); - $tester->execute(array('locale' => 'en', 'bundle' => 'dir')); + $tester = $this->createCommandTester([], [], $kernel); + $tester->execute(['locale' => 'en', 'bundle' => 'dir']); } protected function setUp() @@ -127,7 +127,7 @@ protected function tearDown() /** * @return CommandTester */ - private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), $kernel = null) + private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null) { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() @@ -136,7 +136,7 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(array('en'))); + ->will($this->returnValue(['en'])); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor @@ -159,15 +159,15 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag ); if (null === $kernel) { - $returnValues = array( - array('foo', $this->getBundle($this->translationDir)), - array('test', $this->getBundle('test')), - ); + $returnValues = [ + ['foo', $this->getBundle($this->translationDir)], + ['test', $this->getBundle('test')], + ]; if (HttpKernel\Kernel::VERSION_ID < 40000) { - $returnValues = array( - array('foo', true, $this->getBundle($this->translationDir)), - array('test', true, $this->getBundle('test')), - ); + $returnValues = [ + ['foo', true, $this->getBundle($this->translationDir)], + ['test', true, $this->getBundle('test')], + ]; } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel @@ -184,7 +184,7 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $kernel ->expects($this->any()) @@ -214,18 +214,18 @@ public function testLegacyDebugCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap(array( - array('translation.extractor', 1, $extractor), - array('translation.reader', 1, $loader), - array('translator', 1, $translator), - array('kernel', 1, $kernel), - ))); + ->will($this->returnValueMap([ + ['translation.extractor', 1, $extractor], + ['translation.reader', 1, $loader], + ['translator', 1, $translator], + ['kernel', 1, $kernel], + ])); $kernel ->expects($this->any()) @@ -239,7 +239,7 @@ public function testLegacyDebugCommand() $application->add($command); $tester = new CommandTester($application->find('debug:translation')); - $tester->execute(array('locale' => 'en')); + $tester->execute(['locale' => 'en']); $this->assertContains('No defined or extracted', $tester->getDisplay()); } diff --git a/Tests/Command/TranslationUpdateCommandTest.php b/Tests/Command/TranslationUpdateCommandTest.php index e92c17565..42d4115f1 100644 --- a/Tests/Command/TranslationUpdateCommandTest.php +++ b/Tests/Command/TranslationUpdateCommandTest.php @@ -25,8 +25,8 @@ class TranslationUpdateCommandTest extends TestCase public function testDumpMessagesAndClean() { - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } @@ -38,16 +38,16 @@ public function testDumpMessagesAndCleanInRootDirectory() $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true)); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } public function testDumpTwoMessagesAndClean() { - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo', 'bar' => 'bar'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'bar' => 'bar']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]); $this->assertRegExp('/foo/', $tester->getDisplay()); $this->assertRegExp('/bar/', $tester->getDisplay()); $this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay()); @@ -55,16 +55,16 @@ public function testDumpTwoMessagesAndClean() public function testDumpMessagesForSpecificDomain() { - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain')); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain']); $this->assertRegExp('/bar/', $tester->getDisplay()); $this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay()); } public function testWriteMessages() { - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true)); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true]); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } @@ -75,15 +75,15 @@ public function testWriteMessagesInRootDirectory() $this->fs->mkdir($this->translationDir.'/translations'); $this->fs->mkdir($this->translationDir.'/templates'); - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', '--force' => true)); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } public function testWriteMessagesForSpecificDomain() { - $tester = $this->createCommandTester(array('messages' => array('foo' => 'foo'), 'mydomain' => array('bar' => 'bar'))); - $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain')); + $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); + $tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain']); $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } @@ -105,7 +105,7 @@ protected function tearDown() /** * @return CommandTester */ - private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), HttpKernel\KernelInterface $kernel = null) + private function createCommandTester($extractedMessages = [], $loadedMessages = [], HttpKernel\KernelInterface $kernel = null) { $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator') ->disableOriginalConstructor() @@ -114,7 +114,7 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(array('en'))); + ->will($this->returnValue(['en'])); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor @@ -143,19 +143,19 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag ->expects($this->any()) ->method('getFormats') ->will( - $this->returnValue(array('xlf', 'yml')) + $this->returnValue(['xlf', 'yml']) ); if (null === $kernel) { - $returnValues = array( - array('foo', $this->getBundle($this->translationDir)), - array('test', $this->getBundle('test')), - ); + $returnValues = [ + ['foo', $this->getBundle($this->translationDir)], + ['test', $this->getBundle('test')], + ]; if (HttpKernel\Kernel::VERSION_ID < 40000) { - $returnValues = array( - array('foo', true, $this->getBundle($this->translationDir)), - array('test', true, $this->getBundle('test')), - ); + $returnValues = [ + ['foo', true, $this->getBundle($this->translationDir)], + ['test', true, $this->getBundle('test')], + ]; } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel @@ -172,7 +172,7 @@ private function createCommandTester($extractedMessages = array(), $loadedMessag $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $kernel ->expects($this->any()) @@ -203,19 +203,19 @@ public function testLegacyUpdateCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap(array( - array('translation.extractor', 1, $extractor), - array('translation.reader', 1, $loader), - array('translation.writer', 1, $writer), - array('translator', 1, $translator), - array('kernel', 1, $kernel), - ))); + ->will($this->returnValueMap([ + ['translation.extractor', 1, $extractor], + ['translation.reader', 1, $loader], + ['translation.writer', 1, $writer], + ['translator', 1, $translator], + ['kernel', 1, $kernel], + ])); $kernel ->expects($this->any()) @@ -229,7 +229,7 @@ public function testLegacyUpdateCommand() $application->add($command); $tester = new CommandTester($application->find('translation:update')); - $tester->execute(array('locale' => 'en')); + $tester->execute(['locale' => 'en']); $this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay()); } diff --git a/Tests/Command/YamlLintCommandTest.php b/Tests/Command/YamlLintCommandTest.php index 2daa2e322..a71fb824d 100644 --- a/Tests/Command/YamlLintCommandTest.php +++ b/Tests/Command/YamlLintCommandTest.php @@ -36,8 +36,8 @@ public function testLintCorrectFile() $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 @@ public function testLintIncorrectFile() $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 @@ public function testLintFileNotReadable() $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 @@ public function testLintFilesFromBundleDirectory() { $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 @@ private function getKernelAwareApplicationMock() protected function setUp() { @mkdir(sys_get_temp_dir().'/yml-lint-test'); - $this->files = array(); + $this->files = []; } protected function tearDown() diff --git a/Tests/Console/ApplicationTest.php b/Tests/Console/ApplicationTest.php index c977bb13a..8c25ef967 100644 --- a/Tests/Console/ApplicationTest.php +++ b/Tests/Console/ApplicationTest.php @@ -29,30 +29,30 @@ public function testBundleInterfaceImplementation() { $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 @@ public function testBundleSingleCommandIsRetrievable() { $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 @@ public function testBundleCommandCanBeFound() { $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 @@ public function testBundleCommandCanBeFound() 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 @@ public function testBundleCommandCanBeFoundByAlias() 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 @@ public function testRunOnlyWarnsOnUnregistrableCommand() $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 @@ public function testRunOnlyWarnsOnUnregistrableCommand() $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 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound() $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 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound() $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'fine')); + $tester->run(['command' => 'fine']); $output = $tester->getDisplay(); $this->assertSame(1, $tester->getStatusCode()); @@ -212,14 +212,14 @@ private function getKernel(array $bundles, $useDispatcher = false) $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/Tests/Console/Descriptor/AbstractDescriptorTest.php b/Tests/Console/Descriptor/AbstractDescriptorTest.php index ab5c95a7d..9bc05e538 100644 --- a/Tests/Console/Descriptor/AbstractDescriptorTest.php +++ b/Tests/Console/Descriptor/AbstractDescriptorTest.php @@ -83,13 +83,13 @@ public function getDescribeContainerDefinitionTestData() /** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */ public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription) { - $this->assertDescription($expectedDescription, $definition, array('show_arguments' => true)); + $this->assertDescription($expectedDescription, $definition, ['show_arguments' => true]); } public function getDescribeContainerDefinitionWithArgumentsShownTestData() { $definitions = ObjectsProvider::getContainerDefinitions(); - $definitionsWithArgs = array(); + $definitionsWithArgs = []; foreach ($definitions as $key => $definition) { $definitionsWithArgs[str_replace('definition_', 'definition_arguments_', $key)] = $definition; @@ -110,7 +110,7 @@ public function getDescribeContainerAliasTestData() } /** @dataProvider getDescribeContainerDefinitionWhichIsAnAliasTestData */ - public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $expectedDescription, ContainerBuilder $builder, $options = array()) + public function testDescribeContainerDefinitionWhichIsAnAlias(Alias $alias, $expectedDescription, ContainerBuilder $builder, $options = []) { $this->assertDescription($expectedDescription, $builder, $options); } @@ -122,7 +122,7 @@ public function getDescribeContainerDefinitionWhichIsAnAliasTestData() $builder->setDefinition('service_2', $builder->getDefinition('definition_2')); $aliases = ObjectsProvider::getContainerAliases(); - $aliasesWithDefinitions = array(); + $aliasesWithDefinitions = []; foreach ($aliases as $name => $alias) { $aliasesWithDefinitions[str_replace('alias_', 'alias_with_definition_', $name)] = $alias; } @@ -131,7 +131,7 @@ public function getDescribeContainerDefinitionWhichIsAnAliasTestData() $data = $this->getDescriptionTestData($aliasesWithDefinitions); foreach ($aliases as $name => $alias) { $data[$i][] = $builder; - $data[$i][] = array('id' => $name); + $data[$i][] = ['id' => $name]; ++$i; } @@ -148,8 +148,8 @@ public function getDescribeContainerParameterTestData() { $data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter()); - $data[0][] = array('parameter' => 'database_name'); - $data[1][] = array('parameter' => 'twig.form.resources'); + $data[0][] = ['parameter' => 'database_name']; + $data[1][] = ['parameter' => 'twig.form.resources']; return $data; } @@ -180,14 +180,14 @@ abstract protected function getDescriptor(); abstract protected function getFormat(); - private function assertDescription($expectedDescription, $describedObject, array $options = array()) + private function assertDescription($expectedDescription, $describedObject, array $options = []) { $options['raw_output'] = true; $options['raw_text'] = true; $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); if ('txt' === $this->getFormat()) { - $options['output'] = new SymfonyStyle(new ArrayInput(array()), $output); + $options['output'] = new SymfonyStyle(new ArrayInput([]), $output); } $this->getDescriptor()->describe($output, $describedObject, $options); @@ -201,10 +201,10 @@ private function assertDescription($expectedDescription, $describedObject, array private function getDescriptionTestData(array $objects) { - $data = array(); + $data = []; foreach ($objects as $name => $object) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s.%s', __DIR__, $name, $this->getFormat())); - $data[] = array($object, $description); + $data[] = [$object, $description]; } return $data; @@ -212,19 +212,19 @@ private function getDescriptionTestData(array $objects) private function getContainerBuilderDescriptionTestData(array $objects) { - $variations = array( - 'services' => array('show_private' => true), - 'public' => array('show_private' => false), - 'tag1' => array('show_private' => true, 'tag' => 'tag1'), - 'tags' => array('group_by' => 'tags', 'show_private' => true), - 'arguments' => array('show_private' => false, 'show_arguments' => true), - ); + $variations = [ + 'services' => ['show_private' => true], + 'public' => ['show_private' => false], + 'tag1' => ['show_private' => true, 'tag' => 'tag1'], + 'tags' => ['group_by' => 'tags', 'show_private' => true], + 'arguments' => ['show_private' => false, 'show_arguments' => true], + ]; - $data = array(); + $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s_%s.%s', __DIR__, $name, $suffix, $this->getFormat())); - $data[] = array($object, $description, $options); + $data[] = [$object, $description, $options]; } } @@ -233,16 +233,16 @@ private function getContainerBuilderDescriptionTestData(array $objects) private function getEventDispatcherDescriptionTestData(array $objects) { - $variations = array( - 'events' => array(), - 'event1' => array('event' => 'event1'), - ); + $variations = [ + 'events' => [], + 'event1' => ['event' => 'event1'], + ]; - $data = array(); + $data = []; foreach ($objects as $name => $object) { foreach ($variations as $suffix => $options) { $description = file_get_contents(sprintf('%s/../../Fixtures/Descriptor/%s_%s.%s', __DIR__, $name, $suffix, $this->getFormat())); - $data[] = array($object, $description, $options); + $data[] = [$object, $description, $options]; } } diff --git a/Tests/Console/Descriptor/ObjectsProvider.php b/Tests/Console/Descriptor/ObjectsProvider.php index b46e32235..c33f603a7 100644 --- a/Tests/Console/Descriptor/ObjectsProvider.php +++ b/Tests/Console/Descriptor/ObjectsProvider.php @@ -31,60 +31,60 @@ public static function getRouteCollections() $collection1->add($name, $route); } - return array('route_collection_1' => $collection1); + return ['route_collection_1' => $collection1]; } public static function getRoutes() { - return array( + return [ 'route_1' => new RouteStub( '/hello/{name}', - array('name' => 'Joseph'), - array('name' => '[a-z]+'), - array('opt1' => 'val1', 'opt2' => 'val2'), + ['name' => 'Joseph'], + ['name' => '[a-z]+'], + ['opt1' => 'val1', 'opt2' => 'val2'], 'localhost', - array('http', 'https'), - array('get', 'head') + ['http', 'https'], + ['get', 'head'] ), 'route_2' => new RouteStub( '/name/add', - array(), - array(), - array('opt1' => 'val1', 'opt2' => 'val2'), + [], + [], + ['opt1' => 'val1', 'opt2' => 'val2'], 'localhost', - array('http', 'https'), - array('put', 'post') + ['http', 'https'], + ['put', 'post'] ), - ); + ]; } public static function getContainerParameters() { - return array( - 'parameters_1' => new ParameterBag(array( + return [ + 'parameters_1' => new ParameterBag([ 'integer' => 12, 'string' => 'Hello world!', 'boolean' => true, - 'array' => array(12, 'Hello world!', true), - )), - ); + 'array' => [12, 'Hello world!', true], + ]), + ]; } public static function getContainerParameter() { $builder = new ContainerBuilder(); $builder->setParameter('database_name', 'symfony'); - $builder->setParameter('twig.form.resources', array( + $builder->setParameter('twig.form.resources', [ 'bootstrap_3_horizontal_layout.html.twig', 'bootstrap_3_layout.html.twig', 'form_div_layout.html.twig', 'form_table_layout.html.twig', - )); + ]); - return array( + return [ 'parameter' => $builder, 'array_parameter' => $builder, - ); + ]; } public static function getContainerBuilders() @@ -93,7 +93,7 @@ public static function getContainerBuilders() $builder1->setDefinitions(self::getContainerDefinitions()); $builder1->setAliases(self::getContainerAliases()); - return array('builder_1' => $builder1); + return ['builder_1' => $builder1]; } public static function getContainerDefinitions() @@ -101,7 +101,7 @@ public static function getContainerDefinitions() $definition1 = new Definition('Full\\Qualified\\Class1'); $definition2 = new Definition('Full\\Qualified\\Class2'); - return array( + return [ 'definition_1' => $definition1 ->setPublic(true) ->setSynthetic(false) @@ -109,37 +109,37 @@ public static function getContainerDefinitions() ->setAbstract(true) ->addArgument(new Reference('definition2')) ->addArgument('%parameter%') - ->addArgument(new Definition('inline_service', array('arg1', 'arg2'))) - ->addArgument(array( + ->addArgument(new Definition('inline_service', ['arg1', 'arg2'])) + ->addArgument([ 'foo', new Reference('definition2'), new Definition('inline_service'), - )) - ->addArgument(new IteratorArgument(array( + ]) + ->addArgument(new IteratorArgument([ new Reference('definition_1'), new Reference('definition_2'), - ))) - ->setFactory(array('Full\\Qualified\\FactoryClass', 'get')), + ])) + ->setFactory(['Full\\Qualified\\FactoryClass', 'get']), 'definition_2' => $definition2 ->setPublic(false) ->setSynthetic(true) ->setFile('/path/to/file') ->setLazy(false) ->setAbstract(false) - ->addTag('tag1', array('attr1' => 'val1', 'attr2' => 'val2')) - ->addTag('tag1', array('attr3' => 'val3')) + ->addTag('tag1', ['attr1' => 'val1', 'attr2' => 'val2']) + ->addTag('tag1', ['attr3' => 'val3']) ->addTag('tag2') - ->addMethodCall('setMailer', array(new Reference('mailer'))) - ->setFactory(array(new Reference('factory.service'), 'get')), - ); + ->addMethodCall('setMailer', [new Reference('mailer')]) + ->setFactory([new Reference('factory.service'), 'get']), + ]; } public static function getContainerAliases() { - return array( + return [ 'alias_1' => new Alias('service_1', true), 'alias_2' => new Alias('service_2', false), - ); + ]; } public static function getEventDispatchers() @@ -150,20 +150,20 @@ public static function getEventDispatchers() $eventDispatcher->addListener('event1', function () { return 'Closure'; }, -1); $eventDispatcher->addListener('event2', new CallableClass()); - return array('event_dispatcher_1' => $eventDispatcher); + return ['event_dispatcher_1' => $eventDispatcher]; } public static function getCallables() { - $callables = array( + $callables = [ 'callable_1' => 'array_key_exists', - 'callable_2' => array('Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'), - 'callable_3' => array(new CallableClass(), 'method'), + 'callable_2' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'], + 'callable_3' => [new CallableClass(), 'method'], 'callable_4' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass::staticMethod', - 'callable_5' => array('Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'), + 'callable_5' => ['Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\ExtendedCallableClass', 'parent::staticMethod'], 'callable_6' => function () { return 'Closure'; }, 'callable_7' => new CallableClass(), - ); + ]; if (\PHP_VERSION_ID >= 70100) { $callables['callable_from_callable'] = \Closure::fromCallable(new CallableClass()); @@ -199,6 +199,6 @@ class RouteStub extends Route { public function compile() { - return new CompiledRoute('', '#PATH_REGEX#', array(), array(), '#HOST_REGEX#'); + return new CompiledRoute('', '#PATH_REGEX#', [], [], '#HOST_REGEX#'); } } diff --git a/Tests/Controller/ControllerNameParserTest.php b/Tests/Controller/ControllerNameParserTest.php index b5edad94c..66729f5fa 100644 --- a/Tests/Controller/ControllerNameParserTest.php +++ b/Tests/Controller/ControllerNameParserTest.php @@ -100,13 +100,13 @@ public function testMissingControllers($name) public function getMissingControllersTest() { // a normal bundle - $bundles = array( - array('FooBundle:Fake:index'), - ); + $bundles = [ + ['FooBundle:Fake:index'], + ]; // a bundle with children if (Kernel::VERSION_ID < 40000) { - $bundles[] = array('SensioFooBundle:Fake:index'); + $bundles[] = ['SensioFooBundle:Fake:index']; } return $bundles; @@ -136,21 +136,21 @@ public function testInvalidBundleName($bundleName, $suggestedBundleName) public function getInvalidBundleNameTests() { - return array( - 'Alternative will be found using levenshtein' => array('FoodBundle:Default:index', 'FooBundle:Default:index'), - 'Alternative will be found using partial match' => array('FabpotFooBund:Default:index', 'FabpotFooBundle:Default:index'), - 'Bundle does not exist at all' => array('CrazyBundle:Default:index', false), - ); + return [ + 'Alternative will be found using levenshtein' => ['FoodBundle:Default:index', 'FooBundle:Default:index'], + 'Alternative will be found using partial match' => ['FabpotFooBund:Default:index', 'FabpotFooBundle:Default:index'], + 'Bundle does not exist at all' => ['CrazyBundle:Default:index', false], + ]; } private function createParser() { - $bundles = array( - 'SensioFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')), - 'SensioCmsFooBundle' => array($this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle')), - 'FooBundle' => array($this->getBundle('TestBundle\FooBundle', 'FooBundle')), - 'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')), - ); + $bundles = [ + 'SensioFooBundle' => [$this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')], + 'SensioCmsFooBundle' => [$this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle')], + 'FooBundle' => [$this->getBundle('TestBundle\FooBundle', 'FooBundle')], + 'FabpotFooBundle' => [$this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')], + ]; $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel @@ -165,13 +165,13 @@ private function createParser() })) ; - $bundles = array( + $bundles = [ 'SensioFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), 'SensioCmsFooBundle' => $this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle'), 'FoooooBundle' => $this->getBundle('TestBundle\FooBundle', 'FoooooBundle'), 'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'), 'FabpotFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), - ); + ]; $kernel ->expects($this->any()) ->method('getBundles') diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 5880ee018..93ce1527b 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -83,7 +83,7 @@ class_exists(AbstractControllerTest::class); $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()); } @@ -101,7 +101,7 @@ class_exists(AbstractControllerTest::class); $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)); } @@ -119,7 +119,7 @@ class_exists(AbstractControllerTest::class); $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()); } @@ -139,7 +139,7 @@ class_exists(AbstractControllerTest::class); $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)); } @@ -159,7 +159,7 @@ class_exists(AbstractControllerTest::class); $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/Tests/Controller/ControllerTraitTest.php b/Tests/Controller/ControllerTraitTest.php index e72f53649..36b6bd95b 100644 --- a/Tests/Controller/ControllerTraitTest.php +++ b/Tests/Controller/ControllerTraitTest.php @@ -59,7 +59,7 @@ public function testForward() 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 @@ public function testJson() $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 @@ public function testJsonWithSerializer() $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 @@ public function testJsonWithSerializer() $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 @@ public function testJsonWithSerializerContextOverride() $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 @@ public function testJsonWithSerializerContextOverride() $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 @@ public function testAddFlash() $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/Tests/Controller/RedirectControllerTest.php b/Tests/Controller/RedirectControllerTest.php index 9a1883b6d..076912d6e 100644 --- a/Tests/Controller/RedirectControllerTest.php +++ b/Tests/Controller/RedirectControllerTest.php @@ -53,17 +53,17 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte $route = 'new-route'; $url = '/redirect-url'; - $attributes = array( + $attributes = [ 'route' => $route, 'permanent' => $permanent, '_route' => 'current-route', - '_route_params' => array( + '_route_params' => [ 'route' => $route, 'permanent' => $permanent, 'additional-parameter' => 'value', 'ignoreAttributes' => $ignoreAttributes, - ), - ); + ], + ]; $request->attributes = new ParameterBag($attributes); @@ -84,12 +84,12 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte public function provider() { - return array( - array(true, false, 301, array('additional-parameter' => 'value')), - array(false, false, 302, array('additional-parameter' => 'value')), - array(false, true, 302, array()), - array(false, array('additional-parameter'), 302, array()), - ); + return [ + [true, false, 301, ['additional-parameter' => 'value']], + [false, false, 302, ['additional-parameter' => 'value']], + [false, true, 302, []], + [false, ['additional-parameter'], 302, []], + ]; } public function testEmptyPath() @@ -169,33 +169,33 @@ public function testUrlRedirectDefaultPortParameters() public function urlRedirectProvider() { - return array( + return [ // Standard ports - array('http', null, null, 'http', 80, ''), - array('http', 80, null, 'http', 80, ''), - array('https', null, null, 'http', 80, ''), - array('https', 80, null, 'http', 80, ''), + ['http', null, null, 'http', 80, ''], + ['http', 80, null, 'http', 80, ''], + ['https', null, null, 'http', 80, ''], + ['https', 80, null, 'http', 80, ''], - array('http', null, null, 'https', 443, ''), - array('http', null, 443, 'https', 443, ''), - array('https', null, null, 'https', 443, ''), - array('https', null, 443, 'https', 443, ''), + ['http', null, null, 'https', 443, ''], + ['http', null, 443, 'https', 443, ''], + ['https', null, null, 'https', 443, ''], + ['https', null, 443, 'https', 443, ''], // Non-standard ports - array('http', null, null, 'http', 8080, ':8080'), - array('http', 4080, null, 'http', 8080, ':4080'), - array('http', 80, null, 'http', 8080, ''), - array('https', null, null, 'http', 8080, ''), - array('https', null, 8443, 'http', 8080, ':8443'), - array('https', null, 443, 'http', 8080, ''), - - array('https', null, null, 'https', 8443, ':8443'), - array('https', null, 4443, 'https', 8443, ':4443'), - array('https', null, 443, 'https', 8443, ''), - array('http', null, null, 'https', 8443, ''), - array('http', 8080, 4443, 'https', 8443, ':8080'), - array('http', 80, 4443, 'https', 8443, ''), - ); + ['http', null, null, 'http', 8080, ':8080'], + ['http', 4080, null, 'http', 8080, ':4080'], + ['http', 80, null, 'http', 8080, ''], + ['https', null, null, 'http', 8080, ''], + ['https', null, 8443, 'http', 8080, ':8443'], + ['https', null, 443, 'http', 8080, ''], + + ['https', null, null, 'https', 8443, ':8443'], + ['https', null, 4443, 'https', 8443, ':4443'], + ['https', null, 443, 'https', 8443, ''], + ['http', null, null, 'https', 8443, ''], + ['http', 8080, 4443, 'https', 8443, ':8080'], + ['http', 80, 4443, 'https', 8443, ''], + ]; } /** @@ -217,13 +217,13 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, public function pathQueryParamsProvider() { - return array( - array('http://www.example.com/base/redirect-path', '/redirect-path', ''), - array('http://www.example.com/base/redirect-path?foo=bar', '/redirect-path?foo=bar', ''), - array('http://www.example.com/base/redirect-path?foo=bar', '/redirect-path', 'foo=bar'), - array('http://www.example.com/base/redirect-path?foo=bar&abc=example', '/redirect-path?foo=bar', 'abc=example'), - array('http://www.example.com/base/redirect-path?foo=bar&abc=example&baz=def', '/redirect-path?foo=bar', 'abc=example&baz=def'), - ); + return [ + ['http://www.example.com/base/redirect-path', '/redirect-path', ''], + ['http://www.example.com/base/redirect-path?foo=bar', '/redirect-path?foo=bar', ''], + ['http://www.example.com/base/redirect-path?foo=bar', '/redirect-path', 'foo=bar'], + ['http://www.example.com/base/redirect-path?foo=bar&abc=example', '/redirect-path?foo=bar', 'abc=example'], + ['http://www.example.com/base/redirect-path?foo=bar&abc=example&baz=def', '/redirect-path?foo=bar', 'abc=example&baz=def'], + ]; } /** diff --git a/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php index 08eaaedff..341994e43 100644 --- a/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php @@ -24,20 +24,20 @@ class AddCacheWarmerPassTest extends TestCase public function testThatCacheWarmersAreProcessedInPriorityOrder() { $container = new ContainerBuilder(); - $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument(array()); - $container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', array('priority' => 100)); - $container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', array('priority' => 200)); + $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument([]); + $container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', ['priority' => 100]); + $container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', ['priority' => 200]); $container->register('my_cache_warmer_service3')->addTag('kernel.cache_warmer'); $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); $this->assertEquals( - array( + [ new Reference('my_cache_warmer_service2'), new Reference('my_cache_warmer_service1'), new Reference('my_cache_warmer_service3'), - ), + ], $cacheWarmerDefinition->getArgument(0) ); } @@ -56,11 +56,11 @@ public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition() public function testThatCacheWarmersMightBeNotDefined() { $container = new ContainerBuilder(); - $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument(array()); + $cacheWarmerDefinition = $container->register('cache_warmer')->addArgument([]); $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); - $this->assertSame(array(), $cacheWarmerDefinition->getArgument(0)); + $this->assertSame([], $cacheWarmerDefinition->getArgument(0)); } } diff --git a/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php b/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php index 58a0da41c..17cbf62d0 100644 --- a/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php @@ -53,15 +53,15 @@ public function testProcess($public) } $this->assertTrue($container->hasParameter('console.command.ids')); - $this->assertSame(array($alias => $id), $container->getParameter('console.command.ids')); + $this->assertSame([$alias => $id], $container->getParameter('console.command.ids')); } public function visibilityProvider() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } /** diff --git a/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php b/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php index a5291114d..6fdf8a51e 100644 --- a/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php @@ -28,21 +28,21 @@ public function testThatConstraintValidatorServicesAreProcessed() { $container = new ContainerBuilder(); $validatorFactory = $container->register('validator.validator_factory') - ->addArgument(array()); + ->addArgument([]); $container->register('my_constraint_validator_service1', Validator1::class) - ->addTag('validator.constraint_validator', array('alias' => 'my_constraint_validator_alias1')); + ->addTag('validator.constraint_validator', ['alias' => 'my_constraint_validator_alias1']); $container->register('my_constraint_validator_service2', Validator2::class) ->addTag('validator.constraint_validator'); $addConstraintValidatorsPass = new AddConstraintValidatorsPass(); $addConstraintValidatorsPass->process($container); - $expected = (new Definition(ServiceLocator::class, array(array( + $expected = (new Definition(ServiceLocator::class, [[ Validator1::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')), 'my_constraint_validator_alias1' => new ServiceClosureArgument(new Reference('my_constraint_validator_service1')), Validator2::class => new ServiceClosureArgument(new Reference('my_constraint_validator_service2')), - ))))->addTag('container.service_locator')->setPublic(false); + ]]))->addTag('container.service_locator')->setPublic(false); $this->assertEquals($expected, $container->getDefinition((string) $validatorFactory->getArgument(0))); } @@ -54,7 +54,7 @@ public function testAbstractConstraintValidator() { $container = new ContainerBuilder(); $validatorFactory = $container->register('validator.validator_factory') - ->addArgument(array()); + ->addArgument([]); $container->register('my_abstract_constraint_validator') ->setAbstract(true) diff --git a/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php b/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php index 6a9438ecb..992691de6 100644 --- a/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php +++ b/Tests/DependencyInjection/Compiler/CacheCollectorPassTest.php @@ -37,10 +37,10 @@ public function testProcess() $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/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php b/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php index 9230405d7..728595ae9 100644 --- a/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php +++ b/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php @@ -36,13 +36,13 @@ public function testPoolRefsAreWeak() $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 @@ public function testPoolRefsAreWeak() $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/Tests/DependencyInjection/Compiler/CachePoolPassTest.php b/Tests/DependencyInjection/Compiler/CachePoolPassTest.php index 4619301b6..1e7dc416c 100644 --- a/Tests/DependencyInjection/Compiler/CachePoolPassTest.php +++ b/Tests/DependencyInjection/Compiler/CachePoolPassTest.php @@ -76,10 +76,10 @@ public function testArgsAreReplaced() $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 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() $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/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php b/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php index df9a49b42..2ef2e1535 100644 --- a/Tests/DependencyInjection/Compiler/CachePoolPrunerPassTest.php +++ b/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 @@ public function testCompilePassIsIgnoredIfCommandDoesNotExist() 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/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php b/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php index 482d8818b..1b69a4283 100644 --- a/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php +++ b/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php @@ -27,18 +27,18 @@ public function testThatCheckersAreProcessedInPriorityOrder() $container = new ContainerBuilder(); $definition = $container->register('config_cache_factory')->addArgument(null); - $container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100)); - $container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200)); + $container->register('checker_2')->addTag('config_cache.resource_checker', ['priority' => 100]); + $container->register('checker_1')->addTag('config_cache.resource_checker', ['priority' => 200]); $container->register('checker_3')->addTag('config_cache.resource_checker'); $pass = new ConfigCachePass(); $pass->process($container); - $expected = new IteratorArgument(array( + $expected = new IteratorArgument([ new Reference('checker_1'), new Reference('checker_2'), new Reference('checker_3'), - )); + ]); $this->assertEquals($expected, $definition->getArgument(0)); } diff --git a/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php b/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php index 1adfdf273..06bdd15fb 100644 --- a/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php +++ b/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php @@ -25,19 +25,19 @@ class ControllerArgumentValueResolverPassTest extends TestCase { public function testServicesAreOrderedAccordingToPriority() { - $services = array( - 'n3' => array(array()), - 'n1' => array(array('priority' => 200)), - 'n2' => array(array('priority' => 100)), - ); + $services = [ + 'n3' => [[]], + 'n1' => [['priority' => 200]], + 'n2' => [['priority' => 100]], + ]; - $expected = array( + $expected = [ new Reference('n1'), new Reference('n2'), new Reference('n3'), - ); + ]; - $definition = new Definition(ArgumentResolver::class, array(null, array())); + $definition = new Definition(ArgumentResolver::class, [null, []]); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); @@ -51,12 +51,12 @@ public function testServicesAreOrderedAccordingToPriority() public function testReturningEmptyArrayWhenNoService() { - $definition = new Definition(ArgumentResolver::class, array(null, array())); + $definition = new Definition(ArgumentResolver::class, [null, []]); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); (new ControllerArgumentValueResolverPass())->process($container); - $this->assertEquals(array(), $definition->getArgument(1)->getValues()); + $this->assertEquals([], $definition->getArgument(1)->getValues()); } public function testNoArgumentResolver() diff --git a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php index 2d6e8ca3b..8748d1e9c 100644 --- a/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/DataCollectorTranslatorPassTest.php @@ -33,11 +33,11 @@ protected function setUp() $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 @@ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBag 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 @@ public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTrans 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/Tests/DependencyInjection/Compiler/FormPassTest.php b/Tests/DependencyInjection/Compiler/FormPassTest.php index 58dbd2efd..95423c260 100644 --- a/Tests/DependencyInjection/Compiler/FormPassTest.php +++ b/Tests/DependencyInjection/Compiler/FormPassTest.php @@ -42,12 +42,12 @@ public function testAddTaggedTypes() $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); $extDefinition->setPublic(true); - $extDefinition->setArguments(array( + $extDefinition->setArguments([ new Reference('service_container'), - array(), - array(), - array(), - )); + [], + [], + [], + ]); $container->setDefinition('form.extension', $extDefinition); $container->register('my.type1', __CLASS__.'_Type1')->addTag('form.type')->setPublic(true); @@ -57,10 +57,10 @@ public function testAddTaggedTypes() $extDefinition = $container->getDefinition('form.extension'); - $this->assertEquals(array( + $this->assertEquals([ __CLASS__.'_Type1' => 'my.type1', __CLASS__.'_Type2' => 'my.type2', - ), $extDefinition->getArgument(1)); + ], $extDefinition->getArgument(1)); } /** @@ -71,12 +71,12 @@ public function testAddTaggedTypeExtensions(array $extensions, array $expectedRe $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); - $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', array( + $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', [ new Reference('service_container'), - array(), - array(), - array(), - )); + [], + [], + [], + ]); $extDefinition->setPublic(true); $container->setDefinition('form.extension', $extDefinition); @@ -96,33 +96,33 @@ public function testAddTaggedTypeExtensions(array $extensions, array $expectedRe */ public function addTaggedTypeExtensionsDataProvider() { - return array( - array( - array( - 'my.type_extension1' => array('extended_type' => 'type1'), - 'my.type_extension2' => array('extended_type' => 'type1'), - 'my.type_extension3' => array('extended_type' => 'type2'), - ), - array( - 'type1' => array('my.type_extension1', 'my.type_extension2'), - 'type2' => array('my.type_extension3'), - ), - ), - array( - array( - 'my.type_extension1' => array('extended_type' => 'type1', 'priority' => 1), - 'my.type_extension2' => array('extended_type' => 'type1', 'priority' => 2), - 'my.type_extension3' => array('extended_type' => 'type1', 'priority' => -1), - 'my.type_extension4' => array('extended_type' => 'type2', 'priority' => 2), - 'my.type_extension5' => array('extended_type' => 'type2', 'priority' => 1), - 'my.type_extension6' => array('extended_type' => 'type2', 'priority' => 1), - ), - array( - 'type1' => array('my.type_extension2', 'my.type_extension1', 'my.type_extension3'), - 'type2' => array('my.type_extension4', 'my.type_extension5', 'my.type_extension6'), - ), - ), - ); + return [ + [ + [ + 'my.type_extension1' => ['extended_type' => 'type1'], + 'my.type_extension2' => ['extended_type' => 'type1'], + 'my.type_extension3' => ['extended_type' => 'type2'], + ], + [ + 'type1' => ['my.type_extension1', 'my.type_extension2'], + 'type2' => ['my.type_extension3'], + ], + ], + [ + [ + 'my.type_extension1' => ['extended_type' => 'type1', 'priority' => 1], + 'my.type_extension2' => ['extended_type' => 'type1', 'priority' => 2], + 'my.type_extension3' => ['extended_type' => 'type1', 'priority' => -1], + 'my.type_extension4' => ['extended_type' => 'type2', 'priority' => 2], + 'my.type_extension5' => ['extended_type' => 'type2', 'priority' => 1], + 'my.type_extension6' => ['extended_type' => 'type2', 'priority' => 1], + ], + [ + 'type1' => ['my.type_extension2', 'my.type_extension1', 'my.type_extension3'], + 'type2' => ['my.type_extension4', 'my.type_extension5', 'my.type_extension6'], + ], + ], + ]; } /** @@ -134,12 +134,12 @@ public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute() $container = new ContainerBuilder(); $container->addCompilerPass(new FormPass()); - $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', array( + $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension', [ new Reference('service_container'), - array(), - array(), - array(), - )); + [], + [], + [], + ]); $extDefinition->setPublic(true); $container->setDefinition('form.extension', $extDefinition); @@ -156,12 +156,12 @@ public function testAddTaggedGuessers() $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); $extDefinition->setPublic(true); - $extDefinition->setArguments(array( + $extDefinition->setArguments([ new Reference('service_container'), - array(), - array(), - array(), - )); + [], + [], + [], + ]); $definition1 = new Definition('stdClass'); $definition1->addTag('form.type_guesser'); @@ -176,10 +176,10 @@ public function testAddTaggedGuessers() $extDefinition = $container->getDefinition('form.extension'); - $this->assertSame(array( + $this->assertSame([ 'my.guesser1', 'my.guesser2', - ), $extDefinition->getArgument(3)); + ], $extDefinition->getArgument(3)); } /** @@ -191,15 +191,15 @@ public function testPrivateTaggedServices($id, $tagName) $container->addCompilerPass(new FormPass()); $extDefinition = new Definition('Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension'); - $extDefinition->setArguments(array( + $extDefinition->setArguments([ new Reference('service_container'), - array(), - array(), - array(), - )); + [], + [], + [], + ]); $container->setDefinition('form.extension', $extDefinition); - $container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, array('extended_type' => 'Foo')); + $container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, ['extended_type' => 'Foo']); $container->compile(); $this->assertTrue($container->getDefinition($id)->isPublic()); @@ -207,11 +207,11 @@ public function testPrivateTaggedServices($id, $tagName) public function privateTaggedServicesProvider() { - return array( - array('my.type', 'form.type'), - array('my.type_extension', 'form.type_extension'), - array('my.guesser', 'form.type_guesser'), - ); + return [ + ['my.type', 'form.type'], + ['my.type_extension', 'form.type_extension'], + ['my.guesser', 'form.type_guesser'], + ]; } } diff --git a/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php b/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php index 7788df0c7..6838d4788 100644 --- a/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php @@ -30,17 +30,17 @@ public function testProcess() $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/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index f46779ada..b693165f8 100644 --- a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -32,7 +32,7 @@ public function testTemplateNoIdThrowsException() $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 @@ public function testValidCollector() $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/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index c7b2e3927..33fc9cc7f 100644 --- a/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -29,44 +29,44 @@ public function testServicesAreOrderedAccordingToPriority($index, $tag) { $container = new ContainerBuilder(); - $definition = $container->register('property_info')->setArguments(array(null, null, null, null)); - $container->register('n2')->addTag($tag, array('priority' => 100)); - $container->register('n1')->addTag($tag, array('priority' => 200)); + $definition = $container->register('property_info')->setArguments([null, null, null, null]); + $container->register('n2')->addTag($tag, ['priority' => 100]); + $container->register('n1')->addTag($tag, ['priority' => 200]); $container->register('n3')->addTag($tag); $propertyInfoPass = new PropertyInfoPass(); $propertyInfoPass->process($container); - $expected = new IteratorArgument(array( + $expected = new IteratorArgument([ new Reference('n1'), new Reference('n2'), new Reference('n3'), - )); + ]); $this->assertEquals($expected, $definition->getArgument($index)); } public function provideTags() { - return array( - array(0, 'property_info.list_extractor'), - array(1, 'property_info.type_extractor'), - array(2, 'property_info.description_extractor'), - array(3, 'property_info.access_extractor'), - ); + return [ + [0, 'property_info.list_extractor'], + [1, 'property_info.type_extractor'], + [2, 'property_info.description_extractor'], + [3, 'property_info.access_extractor'], + ]; } public function testReturningEmptyArrayWhenNoService() { $container = new ContainerBuilder(); $propertyInfoExtractorDefinition = $container->register('property_info') - ->setArguments(array(array(), array(), array(), array())); + ->setArguments([[], [], [], []]); $propertyInfoPass = new PropertyInfoPass(); $propertyInfoPass->process($container); - $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(0)); - $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(1)); - $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(2)); - $this->assertEquals(new IteratorArgument(array()), $propertyInfoExtractorDefinition->getArgument(3)); + $this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(0)); + $this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(1)); + $this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(2)); + $this->assertEquals(new IteratorArgument([]), $propertyInfoExtractorDefinition->getArgument(3)); } } diff --git a/Tests/DependencyInjection/Compiler/SerializerPassTest.php b/Tests/DependencyInjection/Compiler/SerializerPassTest.php index d259f8190..e1a7b0be6 100644 --- a/Tests/DependencyInjection/Compiler/SerializerPassTest.php +++ b/Tests/DependencyInjection/Compiler/SerializerPassTest.php @@ -46,8 +46,8 @@ public function testThrowExceptionWhenNoEncoders() { $container = new ContainerBuilder(); $container->register('serializer') - ->addArgument(array()) - ->addArgument(array()); + ->addArgument([]) + ->addArgument([]); $container->register('normalizer')->addTag('serializer.normalizer'); $serializerPass = new SerializerPass(); @@ -58,19 +58,19 @@ public function testServicesAreOrderedAccordingToPriority() { $container = new ContainerBuilder(); - $definition = $container->register('serializer')->setArguments(array(null, null)); - $container->register('n2')->addTag('serializer.normalizer', array('priority' => 100))->addTag('serializer.encoder', array('priority' => 100)); - $container->register('n1')->addTag('serializer.normalizer', array('priority' => 200))->addTag('serializer.encoder', array('priority' => 200)); + $definition = $container->register('serializer')->setArguments([null, null]); + $container->register('n2')->addTag('serializer.normalizer', ['priority' => 100])->addTag('serializer.encoder', ['priority' => 100]); + $container->register('n1')->addTag('serializer.normalizer', ['priority' => 200])->addTag('serializer.encoder', ['priority' => 200]); $container->register('n3')->addTag('serializer.normalizer')->addTag('serializer.encoder'); $serializerPass = new SerializerPass(); $serializerPass->process($container); - $expected = array( + $expected = [ new Reference('n1'), new Reference('n2'), new Reference('n3'), - ); + ]; $this->assertEquals($expected, $definition->getArgument(0)); $this->assertEquals($expected, $definition->getArgument(1)); } diff --git a/Tests/DependencyInjection/Compiler/TranslatorPassTest.php b/Tests/DependencyInjection/Compiler/TranslatorPassTest.php index d31fb18a1..e654edf66 100644 --- a/Tests/DependencyInjection/Compiler/TranslatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/TranslatorPassTest.php @@ -26,10 +26,10 @@ class TranslatorPassTest extends TestCase public function testValidCollector() { $loader = (new Definition()) - ->addTag('translation.loader', array('alias' => 'xliff', 'legacy-alias' => 'xlf')); + ->addTag('translation.loader', ['alias' => 'xliff', 'legacy-alias' => 'xlf']); $translator = (new Definition()) - ->setArguments(array(null, null, null, null)); + ->setArguments([null, null, null, null]); $container = new ContainerBuilder(); $container->setDefinition('translator.default', $translator); @@ -39,15 +39,15 @@ public function testValidCollector() $pass->process($container); $expected = (new Definition()) - ->addTag('translation.loader', array('alias' => 'xliff', 'legacy-alias' => 'xlf')) - ->addMethodCall('addLoader', array('xliff', new Reference('translation.loader'))) - ->addMethodCall('addLoader', array('xlf', new Reference('translation.loader'))) + ->addTag('translation.loader', ['alias' => 'xliff', 'legacy-alias' => 'xlf']) + ->addMethodCall('addLoader', ['xliff', new Reference('translation.loader')]) + ->addMethodCall('addLoader', ['xlf', new Reference('translation.loader')]) ; $this->assertEquals($expected, $loader); - $this->assertSame(array('translation.loader' => array('xliff', 'xlf')), $translator->getArgument(3)); + $this->assertSame(['translation.loader' => ['xliff', 'xlf']], $translator->getArgument(3)); - $expected = array('translation.loader' => new ServiceClosureArgument(new Reference('translation.loader'))); + $expected = ['translation.loader' => new ServiceClosureArgument(new Reference('translation.loader'))]; $this->assertEquals($expected, $container->getDefinition((string) $translator->getArgument(0))->getArgument(0)); } } diff --git a/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php b/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php index d91c806bc..1377a6288 100644 --- a/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php +++ b/Tests/DependencyInjection/Compiler/UnusedTagsPassTest.php @@ -29,6 +29,6 @@ public function testProcess() $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/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index d3317809a..1be401571 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -23,25 +23,25 @@ class ConfigurationTest extends TestCase public function testDefaultConfig() { $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(true), array(array('secret' => 's3cr3t'))); + $config = $processor->processConfiguration(new Configuration(true), [['secret' => 's3cr3t']]); $this->assertEquals( - array_merge(array('secret' => 's3cr3t', 'trusted_hosts' => array()), self::getBundleDefaultConfig()), + array_merge(['secret' => 's3cr3t', 'trusted_hosts' => []], self::getBundleDefaultConfig()), $config ); } public function testDoNoDuplicateDefaultFormResources() { - $input = array('templating' => array( - 'form' => array('resources' => array('FrameworkBundle:Form')), - 'engines' => array('php'), - )); + $input = ['templating' => [ + 'form' => ['resources' => ['FrameworkBundle:Form']], + 'engines' => ['php'], + ]]; $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(true), array($input)); + $config = $processor->processConfiguration(new Configuration(true), [$input]); - $this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']); + $this->assertEquals(['FrameworkBundle:Form'], $config['templating']['form']['resources']); } /** @@ -52,7 +52,7 @@ public function testTrustedProxiesSetToNullIsDeprecated() { $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array(array('trusted_proxies' => null))); + $processor->processConfiguration($configuration, [['trusted_proxies' => null]]); } /** @@ -63,7 +63,7 @@ public function testTrustedProxiesSetToEmptyArrayIsDeprecated() { $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array(array('trusted_proxies' => array()))); + $processor->processConfiguration($configuration, [['trusted_proxies' => []]]); } /** @@ -74,7 +74,7 @@ public function testTrustedProxiesSetToNonEmptyArrayIsInvalid() { $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array(array('trusted_proxies' => array('127.0.0.1')))); + $processor->processConfiguration($configuration, [['trusted_proxies' => ['127.0.0.1']]]); } /** @@ -86,7 +86,7 @@ public function testValidSessionName($sessionName) $processor = new Processor(); $config = $processor->processConfiguration( new Configuration(true), - array(array('session' => array('name' => $sessionName))) + [['session' => ['name' => $sessionName]]] ); $this->assertEquals($sessionName, $config['session']['name']); @@ -94,12 +94,12 @@ public function testValidSessionName($sessionName) public function getTestValidSessionName() { - return array( - array(null), - array('PHPSESSID'), - array('a&b'), - array(',_-!@#$%^*(){}:<>/?'), - ); + return [ + [null], + ['PHPSESSID'], + ['a&b'], + [',_-!@#$%^*(){}:<>/?'], + ]; } /** @@ -111,20 +111,20 @@ public function testInvalidSessionName($sessionName) $processor = new Processor(); $processor->processConfiguration( new Configuration(true), - array(array('session' => array('name' => $sessionName))) + [['session' => ['name' => $sessionName]]] ); } public function getTestInvalidSessionName() { - return array( - array('a.b'), - array('a['), - array('a[]'), - array('a[b]'), - array('a=b'), - array('a+b'), - ); + return [ + ['a.b'], + ['a['], + ['a[]'], + ['a[b]'], + ['a=b'], + ['a+b'], + ]; } /** @@ -135,27 +135,27 @@ public function testValidTrustedProxies($trustedProxies, $processedProxies) { $processor = new Processor(); $configuration = new Configuration(true); - $config = $processor->processConfiguration($configuration, array(array( + $config = $processor->processConfiguration($configuration, [[ 'secret' => 's3cr3t', 'trusted_proxies' => $trustedProxies, - ))); + ]]); $this->assertEquals($processedProxies, $config['trusted_proxies']); } public function getTestValidTrustedProxiesData() { - return array( - array(array('127.0.0.1'), array('127.0.0.1')), - array(array('::1'), array('::1')), - array(array('127.0.0.1', '::1'), array('127.0.0.1', '::1')), - array(null, array()), - array(false, array()), - array(array(), array()), - array(array('10.0.0.0/8'), array('10.0.0.0/8')), - array(array('::ffff:0:0/96'), array('::ffff:0:0/96')), - array(array('0.0.0.0/0'), array('0.0.0.0/0')), - ); + return [ + [['127.0.0.1'], ['127.0.0.1']], + [['::1'], ['::1']], + [['127.0.0.1', '::1'], ['127.0.0.1', '::1']], + [null, []], + [false, []], + [[], []], + [['10.0.0.0/8'], ['10.0.0.0/8']], + [['::ffff:0:0/96'], ['::ffff:0:0/96']], + [['0.0.0.0/0'], ['0.0.0.0/0']], + ]; } /** @@ -166,12 +166,12 @@ public function testInvalidTypeTrustedProxies() { $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array( - array( + $processor->processConfiguration($configuration, [ + [ 'secret' => 's3cr3t', 'trusted_proxies' => 'Not an IP address', - ), - )); + ], + ]); } /** @@ -183,30 +183,30 @@ public function testInvalidValueTrustedProxies() $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array( - array( + $processor->processConfiguration($configuration, [ + [ 'secret' => 's3cr3t', - 'trusted_proxies' => array('Not an IP address'), - ), - )); + 'trusted_proxies' => ['Not an IP address'], + ], + ]); } public function testAssetsCanBeEnabled() { $processor = new Processor(); $configuration = new Configuration(true); - $config = $processor->processConfiguration($configuration, array(array('assets' => null))); + $config = $processor->processConfiguration($configuration, [['assets' => null]]); - $defaultConfig = array( + $defaultConfig = [ 'enabled' => true, 'version_strategy' => null, 'version' => null, 'version_format' => '%%s?%%s', 'base_path' => '', - 'base_urls' => array(), - 'packages' => array(), + 'base_urls' => [], + 'packages' => [], 'json_manifest_path' => null, - ); + ]; $this->assertEquals($defaultConfig, $config['assets']); } @@ -225,125 +225,125 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess $processor = new Processor(); $configuration = new Configuration(true); - $processor->processConfiguration($configuration, array( - array( + $processor->processConfiguration($configuration, [ + [ 'assets' => $assetConfig, - ), - )); + ], + ]); } public function provideInvalidAssetConfigurationTests() { // helper to turn config into embedded package config $createPackageConfig = function (array $packageConfig) { - return array( + return [ 'base_urls' => '//example.com', 'version' => 1, - 'packages' => array( + 'packages' => [ 'foo' => $packageConfig, - ), - ); + ], + ]; }; - $config = array( + $config = [ 'version' => 1, 'version_strategy' => 'foo', - ); - yield array($config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".'); - yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.'); + ]; + yield [$config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".']; + yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.']; - $config = array( + $config = [ 'json_manifest_path' => '/foo.json', 'version_strategy' => 'foo', - ); - yield array($config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".'); - yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.'); + ]; + yield [$config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".']; + yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.']; - $config = array( + $config = [ 'json_manifest_path' => '/foo.json', 'version' => '1', - ); - yield array($config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".'); - yield array($createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'); + ]; + yield [$config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".']; + yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.']; } protected static function getBundleDefaultConfig() { - return array( + return [ 'http_method_override' => true, - 'trusted_proxies' => array(), + 'trusted_proxies' => [], 'ide' => null, 'default_locale' => 'en', - 'csrf_protection' => array( + 'csrf_protection' => [ 'enabled' => false, - ), - 'form' => array( + ], + 'form' => [ 'enabled' => !class_exists(FullStack::class), - 'csrf_protection' => array( + 'csrf_protection' => [ 'enabled' => null, // defaults to csrf_protection.enabled 'field_name' => '_token', - ), - ), - 'esi' => array('enabled' => false), - 'ssi' => array('enabled' => false), - 'fragments' => array( + ], + ], + 'esi' => ['enabled' => false], + 'ssi' => ['enabled' => false], + 'fragments' => [ 'enabled' => false, 'path' => '/_fragment', - ), - 'profiler' => array( + ], + 'profiler' => [ 'enabled' => false, 'only_exceptions' => false, 'only_master_requests' => false, 'dsn' => 'file:%kernel.cache_dir%/profiler', 'collect' => true, - 'matcher' => array( + 'matcher' => [ 'enabled' => false, - 'ips' => array(), - ), - ), - 'translator' => array( + 'ips' => [], + ], + ], + 'translator' => [ 'enabled' => !class_exists(FullStack::class), - 'fallbacks' => array('en'), + 'fallbacks' => ['en'], 'logging' => true, 'formatter' => 'translator.formatter.default', - 'paths' => array(), + 'paths' => [], 'default_path' => '%kernel.project_dir%/translations', - ), - 'validation' => array( + ], + 'validation' => [ 'enabled' => !class_exists(FullStack::class), 'enable_annotations' => !class_exists(FullStack::class), - 'static_method' => array('loadValidatorMetadata'), + 'static_method' => ['loadValidatorMetadata'], 'translation_domain' => 'validators', 'strict_email' => false, - 'mapping' => array( - 'paths' => array(), - ), - ), - 'annotations' => array( + 'mapping' => [ + 'paths' => [], + ], + ], + 'annotations' => [ 'cache' => 'php_array', 'file_cache_dir' => '%kernel.cache_dir%/annotations', 'debug' => true, 'enabled' => true, - ), - 'serializer' => array( + ], + 'serializer' => [ 'enabled' => !class_exists(FullStack::class), 'enable_annotations' => !class_exists(FullStack::class), - 'mapping' => array('paths' => array()), - ), - 'property_access' => array( + 'mapping' => ['paths' => []], + ], + 'property_access' => [ 'magic_call' => false, 'throw_exception_on_invalid_index' => false, - ), - 'property_info' => array( + ], + 'property_info' => [ 'enabled' => !class_exists(FullStack::class), - ), - 'router' => array( + ], + 'router' => [ 'enabled' => false, 'http_port' => 80, 'https_port' => 443, 'strict_requirements' => true, - ), - 'session' => array( + ], + 'session' => [ 'enabled' => false, 'storage_id' => 'session.storage.native', 'handler_id' => 'session.handler.native_file', @@ -352,57 +352,57 @@ protected static function getBundleDefaultConfig() 'save_path' => '%kernel.cache_dir%/sessions', 'metadata_update_threshold' => '0', 'use_strict_mode' => true, - ), - 'request' => array( + ], + 'request' => [ 'enabled' => false, - 'formats' => array(), - ), - 'templating' => array( + 'formats' => [], + ], + 'templating' => [ 'enabled' => false, 'hinclude_default_template' => null, - 'form' => array( - 'resources' => array('FrameworkBundle:Form'), - ), - 'engines' => array(), - 'loaders' => array(), - ), - 'assets' => array( + 'form' => [ + 'resources' => ['FrameworkBundle:Form'], + ], + 'engines' => [], + 'loaders' => [], + ], + 'assets' => [ 'enabled' => !class_exists(FullStack::class), 'version_strategy' => null, 'version' => null, 'version_format' => '%%s?%%s', 'base_path' => '', - 'base_urls' => array(), - 'packages' => array(), + 'base_urls' => [], + 'packages' => [], 'json_manifest_path' => null, - ), - 'cache' => array( - 'pools' => array(), + ], + 'cache' => [ + 'pools' => [], 'app' => 'cache.adapter.filesystem', 'system' => 'cache.adapter.system', 'directory' => '%kernel.cache_dir%/pools', 'default_redis_provider' => 'redis://localhost', 'default_memcached_provider' => 'memcached://localhost', - ), - 'workflows' => array( + ], + 'workflows' => [ 'enabled' => false, - 'workflows' => array(), - ), - 'php_errors' => array( + 'workflows' => [], + ], + 'php_errors' => [ 'log' => true, 'throw' => true, - ), - 'web_link' => array( + ], + 'web_link' => [ 'enabled' => !class_exists(FullStack::class), - ), - 'lock' => array( + ], + 'lock' => [ 'enabled' => !class_exists(FullStack::class), - 'resources' => array( - 'default' => array( + 'resources' => [ + 'default' => [ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock', - ), - ), - ), - ); + ], + ], + ], + ]; } } diff --git a/Tests/DependencyInjection/Fixtures/php/assets.php b/Tests/DependencyInjection/Fixtures/php/assets.php index dc6bf7bb8..c05c6fe3a 100644 --- a/Tests/DependencyInjection/Fixtures/php/assets.php +++ b/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/Tests/DependencyInjection/Fixtures/php/assets_disabled.php b/Tests/DependencyInjection/Fixtures/php/assets_disabled.php index 3ade7047a..d10595fba 100644 --- a/Tests/DependencyInjection/Fixtures/php/assets_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php b/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php index 4f9123aef..b57f78ba4 100644 --- a/Tests/DependencyInjection/Fixtures/php/assets_version_strategy_as_service.php +++ b/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/Tests/DependencyInjection/Fixtures/php/cache.php b/Tests/DependencyInjection/Fixtures/php/cache.php index ef7a1be19..2a85f849f 100644 --- a/Tests/DependencyInjection/Fixtures/php/cache.php +++ b/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/Tests/DependencyInjection/Fixtures/php/cache_env_var.php b/Tests/DependencyInjection/Fixtures/php/cache_env_var.php index b93ade8f4..4f819e720 100644 --- a/Tests/DependencyInjection/Fixtures/php/cache_env_var.php +++ b/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/Tests/DependencyInjection/Fixtures/php/csrf.php b/Tests/DependencyInjection/Fixtures/php/csrf.php index 497ceb2b6..886cb657b 100644 --- a/Tests/DependencyInjection/Fixtures/php/csrf.php +++ b/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/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php b/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php index d1df1c596..34fdb4c1f 100644 --- a/Tests/DependencyInjection/Fixtures/php/csrf_needs_session.php +++ b/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/Tests/DependencyInjection/Fixtures/php/default_config.php b/Tests/DependencyInjection/Fixtures/php/default_config.php index cd2e56bdd..4b2021df7 100644 --- a/Tests/DependencyInjection/Fixtures/php/default_config.php +++ b/Tests/DependencyInjection/Fixtures/php/default_config.php @@ -1,3 +1,3 @@ loadFromExtension('framework', array()); +$container->loadFromExtension('framework', []); diff --git a/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php b/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php index b8f3aa044..beada36b8 100644 --- a/Tests/DependencyInjection/Fixtures/php/esi_and_ssi_without_fragments.php +++ b/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/Tests/DependencyInjection/Fixtures/php/esi_disabled.php b/Tests/DependencyInjection/Fixtures/php/esi_disabled.php index 1fb5936fd..a24cd8158 100644 --- a/Tests/DependencyInjection/Fixtures/php/esi_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php b/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php index 7360c49c7..e0befdb32 100644 --- a/Tests/DependencyInjection/Fixtures/php/form_no_csrf.php +++ b/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/Tests/DependencyInjection/Fixtures/php/full.php b/Tests/DependencyInjection/Fixtures/php/full.php index 64de9309e..e3b9014e4 100644 --- a/Tests/DependencyInjection/Fixtures/php/full.php +++ b/Tests/DependencyInjection/Fixtures/php/full.php @@ -1,30 +1,30 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'secret' => 's3cr3t', 'default_locale' => 'fr', 'csrf_protection' => true, - 'form' => array( - 'csrf_protection' => array( + 'form' => [ + 'csrf_protection' => [ 'field_name' => '_csrf', - ), - ), + ], + ], 'http_method_override' => false, - 'esi' => array( + 'esi' => [ 'enabled' => true, - ), - 'ssi' => array( + ], + 'ssi' => [ 'enabled' => true, - ), - 'profiler' => array( + ], + 'profiler' => [ 'only_exceptions' => true, 'enabled' => false, - ), - 'router' => array( + ], + 'router' => [ 'resource' => '%kernel.project_dir%/config/routing.xml', 'type' => 'xml', - ), - 'session' => array( + ], + 'session' => [ 'storage_id' => 'session.storage.native', 'handler_id' => 'session.handler.native_file', 'name' => '_SYMFONY', @@ -38,47 +38,47 @@ 'gc_divisor' => 108, 'gc_probability' => 1, 'save_path' => '/path/to/sessions', - ), - 'templating' => array( + ], + 'templating' => [ 'cache' => '/path/to/cache', - 'engines' => array('php', 'twig'), - 'loader' => array('loader.foo', 'loader.bar'), - 'form' => array( - 'resources' => array('theme1', 'theme2'), - ), + 'engines' => ['php', 'twig'], + 'loader' => ['loader.foo', 'loader.bar'], + 'form' => [ + 'resources' => ['theme1', 'theme2'], + ], 'hinclude_default_template' => 'global_hinclude_template', - ), - 'assets' => array( + ], + 'assets' => [ 'version' => 'v1', - ), - 'translator' => array( + ], + 'translator' => [ 'enabled' => true, 'fallback' => 'fr', - 'paths' => array('%kernel.project_dir%/Fixtures/translations'), - ), - 'validation' => array( + 'paths' => ['%kernel.project_dir%/Fixtures/translations'], + ], + 'validation' => [ 'enabled' => true, - ), - 'annotations' => array( + ], + 'annotations' => [ 'cache' => 'file', 'debug' => true, 'file_cache_dir' => '%kernel.cache_dir%/annotations', - ), - 'serializer' => array( + ], + 'serializer' => [ 'enabled' => true, 'enable_annotations' => true, 'name_converter' => 'serializer.name_converter.camel_case_to_snake_case', 'circular_reference_handler' => 'my.circular.reference.handler', - ), + ], 'property_info' => true, 'ide' => 'file%%link%%format', - 'request' => array( - 'formats' => array( - 'csv' => array( + 'request' => [ + 'formats' => [ + 'csv' => [ 'text/csv', 'text/plain', - ), + ], 'pdf' => 'application/pdf', - ), - ), -)); + ], + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php b/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php index 1338ec551..cff0582bf 100644 --- a/Tests/DependencyInjection/Fixtures/php/php_errors_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php b/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php index a33875ec6..9afa5d1c0 100644 --- a/Tests/DependencyInjection/Fixtures/php/php_errors_enabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/profiler.php b/Tests/DependencyInjection/Fixtures/php/profiler.php index 6615aa74c..552c95e13 100644 --- a/Tests/DependencyInjection/Fixtures/php/profiler.php +++ b/Tests/DependencyInjection/Fixtures/php/profiler.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'profiler' => array( +$container->loadFromExtension('framework', [ + 'profiler' => [ 'enabled' => true, - ), -)); + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/php/property_accessor.php b/Tests/DependencyInjection/Fixtures/php/property_accessor.php index 4340e61fc..b5b060c1b 100644 --- a/Tests/DependencyInjection/Fixtures/php/property_accessor.php +++ b/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/Tests/DependencyInjection/Fixtures/php/property_info.php b/Tests/DependencyInjection/Fixtures/php/property_info.php index 847e15fa1..bff8d4115 100644 --- a/Tests/DependencyInjection/Fixtures/php/property_info.php +++ b/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/Tests/DependencyInjection/Fixtures/php/request.php b/Tests/DependencyInjection/Fixtures/php/request.php index 1e7cb2921..d69d7512a 100644 --- a/Tests/DependencyInjection/Fixtures/php/request.php +++ b/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/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php b/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php index dedd090be..937a07c22 100644 --- a/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php +++ b/Tests/DependencyInjection/Fixtures/php/serializer_disabled.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'serializer' => array( +$container->loadFromExtension('framework', [ + 'serializer' => [ 'enabled' => false, - ), -)); + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php b/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php index eadad57ec..de3381c21 100644 --- a/Tests/DependencyInjection/Fixtures/php/serializer_enabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php b/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php index 65ddd3215..9636b1d66 100644 --- a/Tests/DependencyInjection/Fixtures/php/serializer_legacy_cache.php +++ b/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/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php b/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php index f2b928ff2..2f6f48e95 100644 --- a/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php +++ b/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/Tests/DependencyInjection/Fixtures/php/session.php b/Tests/DependencyInjection/Fixtures/php/session.php index 104183764..375008c7d 100644 --- a/Tests/DependencyInjection/Fixtures/php/session.php +++ b/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/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php b/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php index 4d61d8216..32e1bf0c5 100644 --- a/Tests/DependencyInjection/Fixtures/php/ssi_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/templating_disabled.php b/Tests/DependencyInjection/Fixtures/php/templating_disabled.php index f76d8ad35..2d5e6d779 100644 --- a/Tests/DependencyInjection/Fixtures/php/templating_disabled.php +++ b/Tests/DependencyInjection/Fixtures/php/templating_disabled.php @@ -1,5 +1,5 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'templating' => false, -)); +]); diff --git a/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php b/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php index bf12a8bc4..f4d5a28aa 100644 --- a/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php +++ b/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/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php b/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php index 535a9a2e9..851a7e140 100644 --- a/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php b/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php index 4fb2aec55..1d65c0caa 100644 --- a/Tests/DependencyInjection/Fixtures/php/templating_php_translator_disabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php b/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php index b8053c853..2d4710ba3 100644 --- a/Tests/DependencyInjection/Fixtures/php/templating_php_translator_enabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php b/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php index 0abe3a46a..592a61de6 100644 --- a/Tests/DependencyInjection/Fixtures/php/translator_fallbacks.php +++ b/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/Tests/DependencyInjection/Fixtures/php/validation_annotations.php b/Tests/DependencyInjection/Fixtures/php/validation_annotations.php index 35a0b3d39..dff03e398 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_annotations.php +++ b/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/Tests/DependencyInjection/Fixtures/php/validation_mapping.php b/Tests/DependencyInjection/Fixtures/php/validation_mapping.php index 5d44c6c21..f8b19e348 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_mapping.php +++ b/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/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php b/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php index 476da7948..ad2bd817a 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_multiple_static_methods.php +++ b/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/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php b/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php index b428e06f5..a9d98e17c 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_no_static_method.php +++ b/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/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php b/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php index 64a47a232..caa47d747 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php +++ b/Tests/DependencyInjection/Fixtures/php/validation_strict_email.php @@ -1,7 +1,7 @@ loadFromExtension('framework', array( - 'validation' => array( +$container->loadFromExtension('framework', [ + 'validation' => [ 'strict_email' => true, - ), -)); + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php b/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php index 40a81d493..42ea07130 100644 --- a/Tests/DependencyInjection/Fixtures/php/validation_translation_domain.php +++ b/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/Tests/DependencyInjection/Fixtures/php/web_link.php b/Tests/DependencyInjection/Fixtures/php/web_link.php index 990064cca..44d52e402 100644 --- a/Tests/DependencyInjection/Fixtures/php/web_link.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php index d97f9700a..003b99f21 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php index 89c86339a..19de6363e 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php index 2619a2dd4..c1a525db0 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php index 062fdb9f0..4b38093a3 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_support_and_support_strategy.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php b/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php index 7d9e59640..eca1e29c4 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php b/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php index 06948785e..dd2a92dc2 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflow_without_support_and_support_strategy.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflows.php b/Tests/DependencyInjection/Fixtures/php/workflows.php index c52760656..69728496c 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows.php @@ -2,110 +2,110 @@ 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', - ), - ), - ), - 'pull_request' => array( + ], + ], + ], + 'pull_request' => [ 'type' => 'state_machine', - 'marking_store' => array( + 'marking_store' => [ 'type' => 'single_state', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), + ], 'initial_place' => 'start', - 'places' => array( + 'places' => [ 'start', 'coding', 'travis', 'review', 'merged', 'closed', - ), - 'transitions' => array( - 'submit' => array( + ], + 'transitions' => [ + 'submit' => [ 'from' => 'start', 'to' => 'travis', - ), - 'update' => array( - 'from' => array('coding', 'travis', 'review'), + ], + 'update' => [ + 'from' => ['coding', 'travis', 'review'], 'to' => 'travis', - ), - 'wait_for_review' => array( + ], + 'wait_for_review' => [ 'from' => 'travis', 'to' => 'review', - ), - 'request_change' => array( + ], + 'request_change' => [ 'from' => 'review', 'to' => 'coding', - ), - 'accept' => array( + ], + 'accept' => [ 'from' => 'review', 'to' => 'merged', - ), - 'reject' => array( + ], + 'reject' => [ 'from' => 'review', 'to' => 'closed', - ), - 'reopen' => array( + ], + 'reopen' => [ 'from' => 'closed', 'to' => 'review', - ), - ), - ), - 'service_marking_store_workflow' => array( + ], + ], + ], + 'service_marking_store_workflow' => [ 'type' => 'workflow', - 'marking_store' => array( + 'marking_store' => [ 'service' => 'workflow_service', - ), - 'supports' => array( + ], + 'supports' => [ FrameworkExtensionTest::class, - ), - 'places' => array( + ], + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( + ], + 'transitions' => [ + 'go' => [ 'from' => 'first', 'to' => 'last', - ), - ), - ), - ), -)); + ], + ], + ], + ], +]); diff --git a/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php b/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php index 9a2fe9136..eb1773194 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows_enabled.php @@ -1,5 +1,5 @@ loadFromExtension('framework', array( +$container->loadFromExtension('framework', [ 'workflows' => null, -)); +]); diff --git a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php index 16009b588..165d0daa1 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php index bd36d87fa..17055ec16 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php +++ b/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/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php b/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php index 63e83170f..4f25a7f80 100644 --- a/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php +++ b/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php @@ -2,25 +2,25 @@ use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; -$container->loadFromExtension('framework', array( - 'workflows' => array( - 'missing_type' => array( - 'marking_store' => array( +$container->loadFromExtension('framework', [ + 'workflows' => [ + 'missing_type' => [ + 'marking_store' => [ 'service' => 'workflow_service', - ), - 'supports' => array( + ], + 'supports' => [ \stdClass::class, - ), - 'places' => array( + ], + 'places' => [ 'first', 'last', - ), - 'transitions' => array( - 'go' => array( + ], + 'transitions' => [ + 'go' => [ 'from' => 'first', 'to' => 'last', - ), - ), - ), - ), -)); + ], + ], + ], + ], +]); diff --git a/Tests/DependencyInjection/FrameworkExtensionTest.php b/Tests/DependencyInjection/FrameworkExtensionTest.php index 01d395216..51b4ff152 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -48,7 +48,7 @@ abstract class FrameworkExtensionTest extends TestCase { - private static $containerCache = array(); + private static $containerCache = []; abstract protected function loadFromFile(ContainerBuilder $container, $file); @@ -90,13 +90,13 @@ public function testPropertyAccessCache() } $cache = $container->getDefinition('cache.property_access'); - $this->assertSame(array(PropertyAccessor::class, 'createCache'), $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode'); + $this->assertSame([PropertyAccessor::class, 'createCache'], $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode'); $this->assertSame(AdapterInterface::class, $cache->getClass()); } public function testPropertyAccessCacheWithDebug() { - $container = $this->createContainerFromFile('property_accessor', array('kernel.debug' => true)); + $container = $this->createContainerFromFile('property_accessor', ['kernel.debug' => true]); if (!method_exists(PropertyAccessor::class, 'createCache')) { return $this->assertFalse($container->hasDefinition('cache.property_access')); @@ -197,18 +197,18 @@ public function testWorkflows() $workflowDefinition = $container->getDefinition('workflow.article.definition'); $this->assertSame( - array( + [ 'draft', 'wait_for_journalist', 'approved_by_journalist', 'wait_for_spellchecker', 'approved_by_spellchecker', 'published', - ), + ], $workflowDefinition->getArgument(0), 'Places are passed to the workflow definition' ); - $this->assertSame(array('workflow.definition' => array(array('name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state'))), $workflowDefinition->getTags()); + $this->assertSame(['workflow.definition' => [['name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state']]], $workflowDefinition->getTags()); $this->assertTrue($container->hasDefinition('state_machine.pull_request'), 'State machine is registered as a service'); $this->assertTrue($container->hasDefinition('state_machine.pull_request.definition'), 'State machine definition is registered as a service'); @@ -218,18 +218,18 @@ public function testWorkflows() $stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition'); $this->assertSame( - array( + [ 'start', 'coding', 'travis', 'review', 'merged', 'closed', - ), + ], $stateMachineDefinition->getArgument(0), 'Places are passed to the state machine definition' ); - $this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags()); + $this->assertSame(['workflow.definition' => [['name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state']]], $stateMachineDefinition->getTags()); $this->assertCount(9, $stateMachineDefinition->getArgument(1)); $this->assertSame('start', $stateMachineDefinition->getArgument(2)); @@ -303,60 +303,60 @@ public function testWorkflowMultipleTransitionsWithSameName() $this->assertCount(5, $transitions); $this->assertSame('workflow.article.transition.0', (string) $transitions[0]); - $this->assertSame(array( + $this->assertSame([ 'request_review', - array( + [ 'draft', - ), - array( + ], + [ 'wait_for_journalist', 'wait_for_spellchecker', - ), - ), $container->getDefinition($transitions[0])->getArguments()); + ], + ], $container->getDefinition($transitions[0])->getArguments()); $this->assertSame('workflow.article.transition.1', (string) $transitions[1]); - $this->assertSame(array( + $this->assertSame([ 'journalist_approval', - array( + [ 'wait_for_journalist', - ), - array( + ], + [ 'approved_by_journalist', - ), - ), $container->getDefinition($transitions[1])->getArguments()); + ], + ], $container->getDefinition($transitions[1])->getArguments()); $this->assertSame('workflow.article.transition.2', (string) $transitions[2]); - $this->assertSame(array( + $this->assertSame([ 'spellchecker_approval', - array( + [ 'wait_for_spellchecker', - ), - array( + ], + [ 'approved_by_spellchecker', - ), - ), $container->getDefinition($transitions[2])->getArguments()); + ], + ], $container->getDefinition($transitions[2])->getArguments()); $this->assertSame('workflow.article.transition.3', (string) $transitions[3]); - $this->assertSame(array( + $this->assertSame([ 'publish', - array( + [ 'approved_by_journalist', 'approved_by_spellchecker', - ), - array( + ], + [ 'published', - ), - ), $container->getDefinition($transitions[3])->getArguments()); + ], + ], $container->getDefinition($transitions[3])->getArguments()); $this->assertSame('workflow.article.transition.4', (string) $transitions[4]); - $this->assertSame(array( + $this->assertSame([ 'publish', - array( + [ 'draft', - ), - array( + ], + [ 'published', - ), - ), $container->getDefinition($transitions[4])->getArguments()); + ], + ], $container->getDefinition($transitions[4])->getArguments()); } public function testGuardExpressions() @@ -367,12 +367,12 @@ public function testGuardExpressions() $this->assertTrue($container->hasParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter exists'); $this->assertTrue(true === $container->getParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter is enabled'); $guardDefinition = $container->getDefinition('workflow.article.listener.guard'); - $this->assertSame(array( - array( + $this->assertSame([ + [ 'event' => 'workflow.article.guard.publish', 'method' => 'onTransition', - ), - ), $guardDefinition->getTag('kernel.event_listener')); + ], + ], $guardDefinition->getTag('kernel.event_listener')); $guardsConfiguration = $guardDefinition->getArgument(0); $this->assertTrue(1 === \count($guardsConfiguration), 'Workflow guard configuration contains one element per transition name'); $transitionGuardExpressions = $guardsConfiguration['workflow.article.guard.publish']; @@ -438,7 +438,7 @@ public function testRouterRequiresResourceOption() { $container = $this->createContainer(); $loader = new FrameworkExtension(); - $loader->load(array(array('router' => true)), $container); + $loader->load([['router' => true]], $container); } public function testSession() @@ -480,7 +480,7 @@ public function testRequest() $this->assertTrue($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() loads request.xml'); $listenerDef = $container->getDefinition('request.add_request_formats_listener'); - $this->assertEquals(array('csv' => array('text/csv', 'text/plain'), 'pdf' => array('application/pdf')), $listenerDef->getArgument(0)); + $this->assertEquals(['csv' => ['text/csv', 'text/plain'], 'pdf' => ['application/pdf']], $listenerDef->getArgument(0)); } public function testEmptyRequestFormats() @@ -505,9 +505,9 @@ public function testTemplating() $this->assertEquals('%templating.loader.cache.path%', $container->getDefinition('templating.loader.cache')->getArgument(1)); $this->assertEquals('/path/to/cache', $container->getParameter('templating.loader.cache.path')); - $this->assertEquals(array('php', 'twig'), $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter'); + $this->assertEquals(['php', 'twig'], $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter'); - $this->assertEquals(array('FrameworkBundle:Form', 'theme1', 'theme2'), $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme'); + $this->assertEquals(['FrameworkBundle:Form', 'theme1', 'theme2'], $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme'); $this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template'); } @@ -525,7 +525,7 @@ public function testAssets() // default package $defaultPackage = $container->getDefinition((string) $packages->getArgument(0)); - $this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); + $this->assertUrlPackage($container, $defaultPackage, ['http://cdn.example.com'], 'SomeVersionScheme', '%%s?version=%%s'); // packages $packages = $packages->getArgument(1); @@ -535,13 +535,13 @@ public function testAssets() $this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['images']); - $this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s'); + $this->assertUrlPackage($container, $package, ['http://images1.example.com', 'http://images2.example.com'], '1.0.0', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['foo']); $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s'); $package = $container->getDefinition((string) $packages['bar']); - $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s'); + $this->assertUrlPackage($container, $package, ['https://bar2.example.com'], 'SomeVersionScheme', '%%s?version=%%s'); $package = $container->getDefinition((string) $packages['bar_version_strategy']); $this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1)); @@ -613,7 +613,7 @@ public function testTranslator() ); $calls = $container->getDefinition('translator.default')->getMethodCalls(); - $this->assertEquals(array('fr'), $calls[1][1][0]); + $this->assertEquals(['fr'], $calls[1][1][0]); } public function testTranslatorMultipleFallbacks() @@ -621,7 +621,7 @@ public function testTranslatorMultipleFallbacks() $container = $this->createContainerFromFile('translator_fallbacks'); $calls = $container->getDefinition('translator.default')->getMethodCalls(); - $this->assertEquals(array('en', 'fr'), $calls[1][1][0]); + $this->assertEquals(['en', 'fr'], $calls[1][1][0]); } public function testTranslatorHelperIsRegisteredWhenTranslatorIsEnabled() @@ -645,7 +645,7 @@ public function testTemplatingRequiresAtLeastOneEngine() { $container = $this->createContainer(); $loader = new FrameworkExtension(); - $loader->load(array(array('templating' => null)), $container); + $loader->load([['templating' => null]], $container); } public function testValidation() @@ -654,10 +654,10 @@ public function testValidation() $projectDir = $container->getParameter('kernel.project_dir'); $ref = new \ReflectionClass('Symfony\Component\Form\Form'); - $xmlMappings = array( + $xmlMappings = [ \dirname($ref->getFileName()).'/Resources/config/validation.xml', strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR), - ); + ]; $calls = $container->getDefinition('validator.builder')->getMethodCalls(); @@ -665,33 +665,33 @@ public function testValidation() $this->assertCount($annotations ? 7 : 6, $calls); $this->assertSame('setConstraintValidatorFactory', $calls[0][0]); - $this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]); + $this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]); $this->assertSame('setTranslator', $calls[1][0]); - $this->assertEquals(array(new Reference('translator')), $calls[1][1]); + $this->assertEquals([new Reference('translator')], $calls[1][1]); $this->assertSame('setTranslationDomain', $calls[2][0]); - $this->assertSame(array('%validator.translation_domain%'), $calls[2][1]); + $this->assertSame(['%validator.translation_domain%'], $calls[2][1]); $this->assertSame('addXmlMappings', $calls[3][0]); - $this->assertSame(array($xmlMappings), $calls[3][1]); + $this->assertSame([$xmlMappings], $calls[3][1]); $i = 3; if ($annotations) { $this->assertSame('enableAnnotationMapping', $calls[++$i][0]); } $this->assertSame('addMethodMapping', $calls[++$i][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[$i][1]); + $this->assertSame(['loadValidatorMetadata'], $calls[$i][1]); $this->assertSame('setMetadataCache', $calls[++$i][0]); - $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]); + $this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[$i][1]); } public function testValidationService() { - $container = $this->createContainerFromFile('validation_annotations', array('kernel.charset' => 'UTF-8'), false); + $container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false); $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); } public function testAnnotations() { - $container = $this->createContainerFromFile('full', array(), true, false); + $container = $this->createContainerFromFile('full', [], true, false); $container->addCompilerPass(new TestAnnotationsPass()); $container->compile(); @@ -718,11 +718,11 @@ public function testValidationAnnotations() $this->assertCount(7, $calls); $this->assertSame('enableAnnotationMapping', $calls[4][0]); - $this->assertEquals(array(new Reference('annotation_reader')), $calls[4][1]); + $this->assertEquals([new Reference('annotation_reader')], $calls[4][1]); $this->assertSame('addMethodMapping', $calls[5][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[5][1]); + $this->assertSame(['loadValidatorMetadata'], $calls[5][1]); $this->assertSame('setMetadataCache', $calls[6][0]); - $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[6][1]); + $this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[6][1]); // no cache this time } @@ -730,10 +730,10 @@ public function testValidationPaths() { require_once __DIR__.'/Fixtures/TestBundle/TestBundle.php'; - $container = $this->createContainerFromFile('validation_annotations', array( - 'kernel.bundles' => array('TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'), - 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/TestBundle')), - )); + $container = $this->createContainerFromFile('validation_annotations', [ + 'kernel.bundles' => ['TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'], + 'kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/TestBundle']], + ]); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); @@ -742,9 +742,9 @@ public function testValidationPaths() $this->assertSame('addYamlMappings', $calls[4][0]); $this->assertSame('enableAnnotationMapping', $calls[5][0]); $this->assertSame('addMethodMapping', $calls[6][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[6][1]); + $this->assertSame(['loadValidatorMetadata'], $calls[6][1]); $this->assertSame('setMetadataCache', $calls[7][0]); - $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[7][1]); + $this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[7][1]); $xmlMappings = $calls[3][1][0]; $this->assertCount(3, $xmlMappings); @@ -766,10 +766,10 @@ public function testValidationPathsUsingCustomBundlePath() { require_once __DIR__.'/Fixtures/CustomPathBundle/src/CustomPathBundle.php'; - $container = $this->createContainerFromFile('validation_annotations', array( - 'kernel.bundles' => array('CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'), - 'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/CustomPathBundle')), - )); + $container = $this->createContainerFromFile('validation_annotations', [ + 'kernel.bundles' => ['CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'], + 'kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/CustomPathBundle']], + ]); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); $xmlMappings = $calls[3][1][0]; @@ -804,7 +804,7 @@ public function testValidationNoStaticMethod() $this->assertSame('enableAnnotationMapping', $calls[++$i][0]); } $this->assertSame('setMetadataCache', $calls[++$i][0]); - $this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]); + $this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[$i][1]); // no cache, no annotations, no static methods } @@ -847,19 +847,19 @@ public function testFormsCanBeEnabledWithoutCsrfProtection() public function testStopwatchEnabledWithDebugModeEnabled() { - $container = $this->createContainerFromFile('default_config', array( + $container = $this->createContainerFromFile('default_config', [ 'kernel.container_class' => 'foo', 'kernel.debug' => true, - )); + ]); $this->assertTrue($container->has('debug.stopwatch')); } public function testStopwatchEnabledWithDebugModeDisabled() { - $container = $this->createContainerFromFile('default_config', array( + $container = $this->createContainerFromFile('default_config', [ 'kernel.container_class' => 'foo', - )); + ]); $this->assertTrue($container->has('debug.stopwatch')); } @@ -882,7 +882,7 @@ public function testSerializerEnabled() $this->assertNull($container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1)); $this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1)); $this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3)); - $this->assertEquals(array('setCircularReferenceHandler', array(new Reference('my.circular.reference.handler'))), $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]); + $this->assertEquals(['setCircularReferenceHandler', [new Reference('my.circular.reference.handler')]], $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]); } public function testRegisterSerializerExtractor() @@ -894,7 +894,7 @@ public function testRegisterSerializerExtractor() $this->assertEquals('serializer.mapping.class_metadata_factory', $serializerExtractorDefinition->getArgument(0)->__toString()); $this->assertFalse($serializerExtractorDefinition->isPublic()); $tag = $serializerExtractorDefinition->getTag('property_info.list_extractor'); - $this->assertEquals(array('priority' => -999), $tag[0]); + $this->assertEquals(['priority' => -999], $tag[0]); } public function testDataUriNormalizerRegistered() @@ -968,7 +968,7 @@ public function testSerializerCacheActivated() public function testSerializerCacheDisabled() { - $container = $this->createContainerFromFile('serializer_enabled', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); + $container = $this->createContainerFromFile('serializer_enabled', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); } @@ -978,7 +978,7 @@ public function testSerializerCacheDisabled() */ public function testDeprecatedSerializerCacheOption() { - $container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__)); + $container = $this->createContainerFromFile('serializer_legacy_cache', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]); $this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory')); $this->assertTrue($container->hasDefinition('serializer.mapping.class_metadata_factory')); @@ -989,19 +989,19 @@ public function testDeprecatedSerializerCacheOption() public function testSerializerMapping() { - $container = $this->createContainerFromFile('serializer_mapping', array('kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle', 'parent' => null)))); + $container = $this->createContainerFromFile('serializer_mapping', ['kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle', 'parent' => null]]]); $projectDir = $container->getParameter('kernel.project_dir'); $configDir = __DIR__.'/Fixtures/TestBundle/Resources/config'; - $expectedLoaders = array( - new Definition(AnnotationLoader::class, array(new Reference('annotation_reader'))), - new Definition(XmlFileLoader::class, array($configDir.'/serialization.xml')), - new Definition(YamlFileLoader::class, array($configDir.'/serialization.yml')), - new Definition(YamlFileLoader::class, array($projectDir.'/config/serializer/foo.yml')), - new Definition(XmlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.xml')), - new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.yml')), - new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yml')), - new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yaml')), - ); + $expectedLoaders = [ + new Definition(AnnotationLoader::class, [new Reference('annotation_reader')]), + new Definition(XmlFileLoader::class, [$configDir.'/serialization.xml']), + new Definition(YamlFileLoader::class, [$configDir.'/serialization.yml']), + new Definition(YamlFileLoader::class, [$projectDir.'/config/serializer/foo.yml']), + new Definition(XmlFileLoader::class, [$configDir.'/serializer_mapping/files/foo.xml']), + new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/files/foo.yml']), + new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/serialization.yml']), + new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/serialization.yaml']), + ]; foreach ($expectedLoaders as $definition) { if (is_file($arg = $definition->getArgument(0))) { @@ -1071,7 +1071,7 @@ public function testPropertyInfoEnabled() public function testEventDispatcherService() { - $container = $this->createContainer(array('kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret')); + $container = $this->createContainer(['kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret']); $container->registerExtension(new FrameworkExtension()); $this->loadFromFile($container, 'default_config'); $container @@ -1123,20 +1123,20 @@ public function testCachePoolServices() public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug() { - $container = $this->createContainer(array('kernel.debug' => true)); - (new FrameworkExtension())->load(array(), $container); + $container = $this->createContainer(['kernel.debug' => true]); + (new FrameworkExtension())->load([], $container); $this->assertCount(1, $container->getDefinition('config_cache_factory')->getArguments()); - $container = $this->createContainer(array('kernel.debug' => false)); - (new FrameworkExtension())->load(array(), $container); + $container = $this->createContainer(['kernel.debug' => false]); + (new FrameworkExtension())->load([], $container); $this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments()); } - protected function createContainer(array $data = array()) + protected function createContainer(array $data = []) { - return new ContainerBuilder(new ParameterBag(array_merge(array( - 'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'), - 'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)), + return new ContainerBuilder(new ParameterBag(array_merge([ + 'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'], + 'kernel.bundles_metadata' => ['FrameworkBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null]], 'kernel.cache_dir' => __DIR__, 'kernel.project_dir' => __DIR__, 'kernel.debug' => false, @@ -1147,10 +1147,10 @@ protected function createContainer(array $data = array()) 'container.build_hash' => 'Abc1234', 'container.build_id' => hash('crc32', 'Abc123423456789'), 'container.build_time' => 23456789, - ), $data))); + ], $data))); } - protected function createContainerFromFile($file, $data = array(), $resetCompilerPasses = true, $compile = true) + protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true) { $cacheKey = md5(\get_class($this).$file.serialize($data)); if ($compile && isset(self::$containerCache[$cacheKey])) { @@ -1161,11 +1161,11 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile $this->loadFromFile($container, $file); if ($resetCompilerPasses) { - $container->getCompilerPassConfig()->setOptimizationPasses(array()); - $container->getCompilerPassConfig()->setRemovingPasses(array()); + $container->getCompilerPassConfig()->setOptimizationPasses([]); + $container->getCompilerPassConfig()->setRemovingPasses([]); } - $container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader'))); - $container->getCompilerPassConfig()->setAfterRemovingPasses(array(new AddAnnotationsCachedReaderPass())); + $container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader')]); + $container->getCompilerPassConfig()->setAfterRemovingPasses([new AddAnnotationsCachedReaderPass()]); if (!$compile) { return $container; @@ -1175,15 +1175,15 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile return self::$containerCache[$cacheKey] = $container; } - protected function createContainerFromClosure($closure, $data = array()) + protected function createContainerFromClosure($closure, $data = []) { $container = $this->createContainer($data); $container->registerExtension(new FrameworkExtension()); $loader = new ClosureLoader($container); $loader->load($closure); - $container->getCompilerPassConfig()->setOptimizationPasses(array()); - $container->getCompilerPassConfig()->setRemovingPasses(array()); + $container->getCompilerPassConfig()->setOptimizationPasses([]); + $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); return $container; diff --git a/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index c554532c7..ec39372b1 100644 --- a/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -29,12 +29,12 @@ protected function loadFromFile(ContainerBuilder $container, $file) 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 @@ public function testAssetsCannotHavePathAndUrl() 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/Tests/EventListener/ResolveControllerNameSubscriberTest.php b/Tests/EventListener/ResolveControllerNameSubscriberTest.php index 338c1ec81..92211dc34 100644 --- a/Tests/EventListener/ResolveControllerNameSubscriberTest.php +++ b/Tests/EventListener/ResolveControllerNameSubscriberTest.php @@ -57,7 +57,7 @@ public function testSkipsOtherControllerFormats($controller) public function provideSkippedControllers() { - yield array('Other:format'); - yield array(function () {}); + yield ['Other:format']; + yield [function () {}]; } } diff --git a/Tests/Fixtures/templates.php b/Tests/Fixtures/templates.php index b97a6ba6a..c9a7ad7a1 100644 --- a/Tests/Fixtures/templates.php +++ b/Tests/Fixtures/templates.php @@ -1,5 +1,5 @@ __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine', -); +]; diff --git a/Tests/Functional/AnnotatedControllerTest.php b/Tests/Functional/AnnotatedControllerTest.php index 2fdbef883..51a3e7ee5 100644 --- a/Tests/Functional/AnnotatedControllerTest.php +++ b/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 @@ public function testAnnotatedController($path, $expectedValue) 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/Tests/Functional/AutowiringTypesTest.php b/Tests/Functional/AutowiringTypesTest.php index 1fba6d776..1db447ac6 100644 --- a/Tests/Functional/AutowiringTypesTest.php +++ b/Tests/Functional/AutowiringTypesTest.php @@ -24,7 +24,7 @@ class AutowiringTypesTest extends WebTestCase { public function testAnnotationReaderAutowiring() { - static::bootKernel(array('root_config' => 'no_annotations_cache.yml', 'environment' => 'no_annotations_cache')); + static::bootKernel(['root_config' => 'no_annotations_cache.yml', 'environment' => 'no_annotations_cache']); $container = static::$kernel->getContainer(); $annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader(); @@ -52,7 +52,7 @@ public function testTemplatingAutowiring() public function testEventDispatcherAutowiring() { - static::bootKernel(array('debug' => false)); + static::bootKernel(['debug' => false]); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); @@ -63,7 +63,7 @@ public function testEventDispatcherAutowiring() $this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled'); } - static::bootKernel(array('debug' => true)); + static::bootKernel(['debug' => true]); $container = static::$kernel->getContainer(); $autowiredServices = $container->get('test.autowiring_types.autowired_services'); @@ -79,8 +79,8 @@ public function testCacheAutowiring() $this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool()); } - protected static function createKernel(array $options = array()) + protected static function createKernel(array $options = []) { - return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); + return parent::createKernel(['test_case' => 'AutowiringTypes'] + $options); } } diff --git a/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index 88bd102a5..aa78c8719 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/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/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php b/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php index 1df462992..54ae9c19e 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php +++ b/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 @@ public function fragmentErrorAction() 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/Tests/Functional/Bundle/TestBundle/Controller/SubRequestServiceResolutionController.php b/Tests/Functional/Bundle/TestBundle/Controller/SubRequestServiceResolutionController.php index ae17f605a..7d7d6565c 100644 --- a/Tests/Functional/Bundle/TestBundle/Controller/SubRequestServiceResolutionController.php +++ b/Tests/Functional/Bundle/TestBundle/Controller/SubRequestServiceResolutionController.php @@ -26,7 +26,7 @@ public function indexAction() $request = $this->container->get('request_stack')->getCurrentRequest(); $path['_forwarded'] = $request->attributes; $path['_controller'] = 'TestBundle:SubRequestServiceResolution:fragment'; - $subRequest = $request->duplicate(array(), null, $path); + $subRequest = $request->duplicate([], null, $path); return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } diff --git a/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php b/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php index 66489374f..59670fdd1 100644 --- a/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php +++ b/Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php @@ -36,7 +36,7 @@ public function load(array $configs, ContainerBuilder $container) */ public function prepend(ContainerBuilder $container) { - $container->prependExtensionConfig('test', array('custom' => 'foo')); + $container->prependExtensionConfig('test', ['custom' => 'foo']); } /** diff --git a/Tests/Functional/CachePoolClearCommandTest.php b/Tests/Functional/CachePoolClearCommandTest.php index 384beebff..e3fd2dc4a 100644 --- a/Tests/Functional/CachePoolClearCommandTest.php +++ b/Tests/Functional/CachePoolClearCommandTest.php @@ -22,13 +22,13 @@ class CachePoolClearCommandTest extends WebTestCase { protected function setUp() { - static::bootKernel(array('test_case' => 'CachePoolClear', 'root_config' => 'config.yml')); + static::bootKernel(['test_case' => 'CachePoolClear', 'root_config' => 'config.yml']); } public function testClearPrivatePool() { $tester = $this->createCommandTester(); - $tester->execute(array('pools' => array('cache.private_pool')), array('decorated' => false)); + $tester->execute(['pools' => ['cache.private_pool']], ['decorated' => false]); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.private_pool', $tester->getDisplay()); @@ -38,7 +38,7 @@ public function testClearPrivatePool() public function testClearPublicPool() { $tester = $this->createCommandTester(); - $tester->execute(array('pools' => array('cache.public_pool')), array('decorated' => false)); + $tester->execute(['pools' => ['cache.public_pool']], ['decorated' => false]); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.public_pool', $tester->getDisplay()); @@ -48,7 +48,7 @@ public function testClearPublicPool() public function testClearPoolWithCustomClearer() { $tester = $this->createCommandTester(); - $tester->execute(array('pools' => array('cache.pool_with_clearer')), array('decorated' => false)); + $tester->execute(['pools' => ['cache.pool_with_clearer']], ['decorated' => false]); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay()); @@ -58,7 +58,7 @@ public function testClearPoolWithCustomClearer() public function testCallClearer() { $tester = $this->createCommandTester(); - $tester->execute(array('pools' => array('cache.app_clearer')), array('decorated' => false)); + $tester->execute(['pools' => ['cache.app_clearer']], ['decorated' => false]); $this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success'); $this->assertContains('Calling cache clearer: cache.app_clearer', $tester->getDisplay()); @@ -72,7 +72,7 @@ public function testCallClearer() public function testClearUnexistingPool() { $this->createCommandTester() - ->execute(array('pools' => array('unknown_pool')), array('decorated' => false)); + ->execute(['pools' => ['unknown_pool']], ['decorated' => false]); } /** @@ -86,7 +86,7 @@ public function testLegacyClearCommand() $tester = new CommandTester($application->find('cache:pool:clear')); - $tester->execute(array('pools' => array())); + $tester->execute(['pools' => []]); $this->assertContains('Cache was successfully cleared', $tester->getDisplay()); } diff --git a/Tests/Functional/CachePoolsTest.php b/Tests/Functional/CachePoolsTest.php index eafc798a4..2a6d43a9f 100644 --- a/Tests/Functional/CachePoolsTest.php +++ b/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 @@ public function testCachePools() 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 @@ public function testRedisCachePools() 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 @@ private function doTestCachePools($options, $adapterClass) $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/Tests/Functional/ConfigDebugCommandTest.php b/Tests/Functional/ConfigDebugCommandTest.php index a98879938..2c0a75481 100644 --- a/Tests/Functional/ConfigDebugCommandTest.php +++ b/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 @@ public function testDumpBundleName() 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 @@ public function testDumpBundleOption() 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 @@ public function testParametersValuesAreResolved() 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/Tests/Functional/ConfigDumpReferenceCommandTest.php b/Tests/Functional/ConfigDumpReferenceCommandTest.php index 3817afed1..a4cfd6cfa 100644 --- a/Tests/Functional/ConfigDumpReferenceCommandTest.php +++ b/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 @@ public function testDumpBundleName() 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 @@ public function testDumpAtPath() 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/Tests/Functional/ContainerDebugCommandTest.php b/Tests/Functional/ContainerDebugCommandTest.php index d19b08f73..0400efc25 100644 --- a/Tests/Functional/ContainerDebugCommandTest.php +++ b/Tests/Functional/ContainerDebugCommandTest.php @@ -21,7 +21,7 @@ class ContainerDebugCommandTest extends WebTestCase { public function testDumpContainerIfNotExists() { - 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); @@ -29,37 +29,37 @@ public function testDumpContainerIfNotExists() @unlink(static::$kernel->getContainer()->getParameter('debug.container.dump')); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'debug:container')); + $tester->run(['command' => 'debug:container']); $this->assertFileExists(static::$kernel->getContainer()->getParameter('debug.container.dump')); } public function testNoDebug() { - static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => false)); + static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => false]); $application = new Application(static::$kernel); $application->setAutoExit(false); $tester = new ApplicationTester($application); - $tester->run(array('command' => 'debug:container')); + $tester->run(['command' => 'debug:container']); $this->assertContains('public', $tester->getDisplay()); } public function testPrivateAlias() { - 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:container', '--show-private' => true)); + $tester->run(['command' => 'debug:container', '--show-private' => true]); $this->assertContains('public', $tester->getDisplay()); $this->assertContains('private_alias', $tester->getDisplay()); - $tester->run(array('command' => 'debug:container')); + $tester->run(['command' => 'debug:container']); $this->assertContains('public', $tester->getDisplay()); $this->assertNotContains('private_alias', $tester->getDisplay()); } diff --git a/Tests/Functional/ContainerDumpTest.php b/Tests/Functional/ContainerDumpTest.php index 423d673be..7c3128dc5 100644 --- a/Tests/Functional/ContainerDumpTest.php +++ b/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($client->getContainer()->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($client->getContainer()->has('serializer')); } diff --git a/Tests/Functional/DebugAutowiringCommandTest.php b/Tests/Functional/DebugAutowiringCommandTest.php index 0b7f9290a..7e41d3298 100644 --- a/Tests/Functional/DebugAutowiringCommandTest.php +++ b/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 @@ public function testBasicFunctionality() 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 @@ public function testSearchArgument() 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/Tests/Functional/FragmentTest.php b/Tests/Functional/FragmentTest.php index dff65d636..db550a231 100644 --- a/Tests/Functional/FragmentTest.php +++ b/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 @@ public function testFragment($insulate) public function getConfigs() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } } diff --git a/Tests/Functional/ProfilerTest.php b/Tests/Functional/ProfilerTest.php index 2d422b029..c5252c0d5 100644 --- a/Tests/Functional/ProfilerTest.php +++ b/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 @@ public function testProfilerIsDisabled($insulate) public function getConfigs() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } } diff --git a/Tests/Functional/PropertyInfoTest.php b/Tests/Functional/PropertyInfoTest.php index f98072ce7..832b45b81 100644 --- a/Tests/Functional/PropertyInfoTest.php +++ b/Tests/Functional/PropertyInfoTest.php @@ -17,10 +17,10 @@ class PropertyInfoTest extends WebTestCase { public function testPhpDocPriority() { - static::bootKernel(array('test_case' => 'Serializer')); + static::bootKernel(['test_case' => 'Serializer']); $container = static::$kernel->getContainer(); - $this->assertEquals(array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))), $container->get('test.property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes')); + $this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))], $container->get('test.property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes')); } } diff --git a/Tests/Functional/SerializerTest.php b/Tests/Functional/SerializerTest.php index bc7dc12eb..c2c53ef7b 100644 --- a/Tests/Functional/SerializerTest.php +++ b/Tests/Functional/SerializerTest.php @@ -18,7 +18,7 @@ class SerializerTest extends WebTestCase { public function testDeserializeArrayOfObject() { - static::bootKernel(array('test_case' => 'Serializer')); + static::bootKernel(['test_case' => 'Serializer']); $container = static::$kernel->getContainer(); $result = $container->get('serializer')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json'); @@ -29,7 +29,7 @@ public function testDeserializeArrayOfObject() $bar2->id = 2; $expected = new Foo(); - $expected->bars = array($bar1, $bar2); + $expected->bars = [$bar1, $bar2]; $this->assertEquals($expected, $result); } diff --git a/Tests/Functional/SessionTest.php b/Tests/Functional/SessionTest.php index 2e1634220..aad3d7794 100644 --- a/Tests/Functional/SessionTest.php +++ b/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 @@ public function testWelcome($config, $insulate) */ 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 @@ public function testFlash($config, $insulate) 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 @@ public function testTwoClients($config, $insulate) */ 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 @@ public function testCorrectCacheControlHeadersForCacheableAction($config, $insul 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/Tests/Functional/SubRequestsTest.php b/Tests/Functional/SubRequestsTest.php index 1a87ff928..9d040581d 100644 --- a/Tests/Functional/SubRequestsTest.php +++ b/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 @@ public function testStateAfterSubRequest() 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/Tests/Functional/WebTestCase.php b/Tests/Functional/WebTestCase.php index b25ab8e5a..3f7bb4c7e 100644 --- a/Tests/Functional/WebTestCase.php +++ b/Tests/Functional/WebTestCase.php @@ -49,7 +49,7 @@ protected static function getKernelClass() 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/Tests/Functional/app/AnnotatedController/bundles.php b/Tests/Functional/app/AnnotatedController/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/AnnotatedController/bundles.php +++ b/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/Tests/Functional/app/AppKernel.php b/Tests/Functional/app/AppKernel.php index e239bb533..11457f6a7 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -81,7 +81,7 @@ protected function build(ContainerBuilder $container) 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/Tests/Functional/app/AutowiringTypes/bundles.php b/Tests/Functional/app/AutowiringTypes/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/AutowiringTypes/bundles.php +++ b/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/Tests/Functional/app/CachePoolClear/bundles.php b/Tests/Functional/app/CachePoolClear/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/CachePoolClear/bundles.php +++ b/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/Tests/Functional/app/CachePools/bundles.php b/Tests/Functional/app/CachePools/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/CachePools/bundles.php +++ b/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/Tests/Functional/app/ConfigDump/bundles.php b/Tests/Functional/app/ConfigDump/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/ConfigDump/bundles.php +++ b/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/Tests/Functional/app/ContainerDebug/bundles.php b/Tests/Functional/app/ContainerDebug/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/ContainerDebug/bundles.php +++ b/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/Tests/Functional/app/ContainerDump/bundles.php b/Tests/Functional/app/ContainerDump/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/ContainerDump/bundles.php +++ b/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/Tests/Functional/app/ControllerServiceResolution/bundles.php b/Tests/Functional/app/ControllerServiceResolution/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/ControllerServiceResolution/bundles.php +++ b/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/Tests/Functional/app/Fragment/bundles.php b/Tests/Functional/app/Fragment/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/Fragment/bundles.php +++ b/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/Tests/Functional/app/Profiler/bundles.php b/Tests/Functional/app/Profiler/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/Profiler/bundles.php +++ b/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/Tests/Functional/app/Resources/views/fragment.html.php b/Tests/Functional/app/Resources/views/fragment.html.php index 8ea3c36f8..a474be431 100644 --- a/Tests/Functional/app/Resources/views/fragment.html.php +++ b/Tests/Functional/app/Resources/views/fragment.html.php @@ -1,13 +1,13 @@ -get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:inlined', array( - 'options' => array( +get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:inlined', [ + 'options' => [ 'bar' => $bar, 'eleven' => 11, - ), - ))); + ], + ])); ?>--get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customformat', array('_format' => 'html'))); + echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customformat', ['_format' => 'html'])); ?>--get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); + echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customlocale', ['_locale' => 'es'])); ?>--getRequest()->setLocale('fr'); echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:forwardlocale')); diff --git a/Tests/Functional/app/Serializer/bundles.php b/Tests/Functional/app/Serializer/bundles.php index 144db9023..13ab9fdde 100644 --- a/Tests/Functional/app/Serializer/bundles.php +++ b/Tests/Functional/app/Serializer/bundles.php @@ -11,6 +11,6 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -return array( +return [ new FrameworkBundle(), -); +]; diff --git a/Tests/Functional/app/Session/bundles.php b/Tests/Functional/app/Session/bundles.php index 422ffc917..15ff182c6 100644 --- a/Tests/Functional/app/Session/bundles.php +++ b/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/Tests/Kernel/ConcreteMicroKernel.php b/Tests/Kernel/ConcreteMicroKernel.php index 3c80e7022..c436d979c 100644 --- a/Tests/Kernel/ConcreteMicroKernel.php +++ b/Tests/Kernel/ConcreteMicroKernel.php @@ -49,9 +49,9 @@ public function dangerousAction() public function registerBundles() { - return array( + return [ new FrameworkBundle(), - ); + ]; } public function getCacheDir() @@ -79,9 +79,9 @@ protected function configureRoutes(RouteCollectionBuilder $routes) 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 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load */ public static function getSubscribedEvents() { - return array( + return [ KernelEvents::EXCEPTION => 'onKernelException', - ); + ]; } } diff --git a/Tests/Routing/RedirectableUrlMatcherTest.php b/Tests/Routing/RedirectableUrlMatcherTest.php index b5f7a3bd4..d87eee58c 100644 --- a/Tests/Routing/RedirectableUrlMatcherTest.php +++ b/Tests/Routing/RedirectableUrlMatcherTest.php @@ -26,7 +26,7 @@ public function testRedirectWhenNoSlash() $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 @@ public function testRedirectWhenNoSlash() 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', - ), + ], $matcher->match('/foo') ); } @@ -42,11 +42,11 @@ public function testRedirectWhenNoSlash() 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 @@ public function testSchemeRedirect() 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo', - ), + ], $matcher->match('/foo') ); } diff --git a/Tests/Routing/RouterTest.php b/Tests/Routing/RouterTest.php index ba5db7940..830909080 100644 --- a/Tests/Routing/RouterTest.php +++ b/Tests/Routing/RouterTest.php @@ -25,12 +25,12 @@ public function testGenerateWithServiceParam() $routes->add('foo', new Route( ' /{_locale}', - array( + [ '_locale' => '%locale%', - ), - array( + ], + [ '_locale' => 'en|es', - ), array(), '', array(), array(), '"%foo%" == "bar"' + ], [], '', [], [], '"%foo%" == "bar"' )); $sc = $this->getServiceContainer($routes); @@ -39,8 +39,8 @@ public function testGenerateWithServiceParam() $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()); } @@ -50,15 +50,15 @@ public function testDefaultsPlaceholders() $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->getServiceContainer($routes); @@ -72,13 +72,13 @@ public function testDefaultsPlaceholders() $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() ); } @@ -89,13 +89,13 @@ public function testRequirementsPlaceholders() $routes->add('foo', new Route( '/foo', - array( - ), - array( + [ + ], + [ 'foo' => 'before_%parameter.foo%', 'bar' => '%parameter.bar%_after', 'baz' => '%%escaped%%', - ) + ] )); $sc = $this->getServiceContainer($routes); @@ -106,11 +106,11 @@ public function testRequirementsPlaceholders() $route = $router->getRouteCollection()->get('foo'); $this->assertEquals( - array( + [ 'foo' => 'before_foo', 'bar' => 'bar_after', 'baz' => '%escaped%', - ), + ], $route->getRequirements() ); } @@ -207,7 +207,7 @@ public function testExceptionOnNonStringParameter() 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->getServiceContainer($routes); @@ -230,12 +230,12 @@ public function testGetRouteCollectionAddsContainerParametersResource() $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']], [[[]]]]; } /** @@ -251,7 +251,7 @@ private function getServiceContainer(RouteCollection $routes) ->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/Tests/Templating/DelegatingEngineTest.php b/Tests/Templating/DelegatingEngineTest.php index e3ff92b87..73983e47c 100644 --- a/Tests/Templating/DelegatingEngineTest.php +++ b/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 @@ public function testGetExistingEngine() { $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 @@ public function testGetInvalidEngine() { $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 @@ public function testRenderResponseWithFrameworkEngine() $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/Tests/Templating/GlobalVariablesTest.php b/Tests/Templating/GlobalVariablesTest.php index 348820b32..d6c6b299e 100644 --- a/Tests/Templating/GlobalVariablesTest.php +++ b/Tests/Templating/GlobalVariablesTest.php @@ -93,14 +93,14 @@ public function getUserProvider() $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/Tests/Templating/Helper/AssetsHelperTest.php b/Tests/Templating/Helper/AssetsHelperTest.php index 01fac959d..83df0640b 100644 --- a/Tests/Templating/Helper/AssetsHelperTest.php +++ b/Tests/Templating/Helper/AssetsHelperTest.php @@ -26,7 +26,7 @@ protected function setUp() $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/Tests/Templating/Helper/Fixtures/StubTranslator.php b/Tests/Templating/Helper/Fixtures/StubTranslator.php index 17d1fd4fc..53a77f24c 100644 --- a/Tests/Templating/Helper/Fixtures/StubTranslator.php +++ b/Tests/Templating/Helper/Fixtures/StubTranslator.php @@ -15,12 +15,12 @@ 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/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/Tests/Templating/Helper/FormHelperDivLayoutTest.php index e655250db..7e8d8f097 100644 --- a/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -35,19 +35,19 @@ protected function getExtensions() $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 @@ protected function tearDown() 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 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty() 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 @@ public function testMoneyWidgetInIso() $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); } @@ -108,27 +108,27 @@ protected function renderErrors(FormView $view) 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); } @@ -140,15 +140,15 @@ protected function setTheme(FormView $view, array $themes, $useDefaultThemes = t 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/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/Tests/Templating/Helper/FormHelperTableLayoutTest.php index 46c20110c..fc5e7d17f 100644 --- a/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/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 @@ public function testStartTagHasNoActionAttributeWhenActionIsEmpty() 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 @@ protected function getExtensions() $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 @@ protected function tearDown() 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); } @@ -97,27 +97,27 @@ protected function renderErrors(FormView $view) 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/Tests/Templating/Helper/RequestHelperTest.php b/Tests/Templating/Helper/RequestHelperTest.php index 6795bc1a5..a2068ae75 100644 --- a/Tests/Templating/Helper/RequestHelperTest.php +++ b/Tests/Templating/Helper/RequestHelperTest.php @@ -24,7 +24,7 @@ protected function setUp() { $this->requestStack = new RequestStack(); $request = new Request(); - $request->initialize(array('foobar' => 'bar')); + $request->initialize(['foobar' => 'bar']); $this->requestStack->push($request); } diff --git a/Tests/Templating/Helper/SessionHelperTest.php b/Tests/Templating/Helper/SessionHelperTest.php index c0fc0ba0b..06984095f 100644 --- a/Tests/Templating/Helper/SessionHelperTest.php +++ b/Tests/Templating/Helper/SessionHelperTest.php @@ -47,13 +47,13 @@ public function testFlash() $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/Tests/Templating/Loader/TemplateLocatorTest.php b/Tests/Templating/Loader/TemplateLocatorTest.php index 37ea5b484..3317b15d9 100644 --- a/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/Tests/Templating/Loader/TemplateLocatorTest.php @@ -90,8 +90,8 @@ protected function getFileLocator() { 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/Tests/Templating/TemplateFilenameParserTest.php b/Tests/Templating/TemplateFilenameParserTest.php index eedbcd27d..3c44612b8 100644 --- a/Tests/Templating/TemplateFilenameParserTest.php +++ b/Tests/Templating/TemplateFilenameParserTest.php @@ -45,12 +45,12 @@ public function testParseFromFilename($file, $ref) 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/Tests/Templating/TemplateNameParserTest.php b/Tests/Templating/TemplateNameParserTest.php index e5958e2dd..85e491754 100644 --- a/Tests/Templating/TemplateNameParserTest.php +++ b/Tests/Templating/TemplateNameParserTest.php @@ -27,7 +27,7 @@ protected function setUp() ->expects($this->any()) ->method('getBundle') ->will($this->returnCallback(function ($bundle) { - if (\in_array($bundle, array('SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'))) { + if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) { return true; } @@ -56,22 +56,22 @@ public function testParse($name, $logicalName, $path, $ref) public function parseProvider() { - return array( - array('FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')), - array('FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')), - array('FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')), - array('SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')), - array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')), - array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), - array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), - array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), - array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), - array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')), - array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')), - array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), - array('name', 'name', 'name', new BaseTemplateReference('name')), - array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')), - ); + return [ + ['FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')], + ['FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')], + ['FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')], + ['SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')], + ['SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')], + [':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')], + ['::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')], + ['index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')], + ['FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')], + ['@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')], + ['@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')], + ['name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')], + ['name', 'name', 'name', new BaseTemplateReference('name')], + ['default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')], + ]; } /** @@ -98,12 +98,12 @@ public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref) public function provideAbsolutePaths() { - return array( - array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')), - array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')), - array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')), - array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')), - array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), - ); + return [ + ['/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')], + ['C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')], + ['C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')], + ['\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')], + ['/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')], + ]; } } diff --git a/Tests/Templating/TemplateTest.php b/Tests/Templating/TemplateTest.php index 0321d0532..66872049a 100644 --- a/Tests/Templating/TemplateTest.php +++ b/Tests/Templating/TemplateTest.php @@ -26,11 +26,11 @@ public function testGetPathForTemplate($template, $path) 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/Tests/Translation/PhpExtractorTest.php b/Tests/Translation/PhpExtractorTest.php index ca45f4332..c19c1567d 100644 --- a/Tests/Translation/PhpExtractorTest.php +++ b/Tests/Translation/PhpExtractorTest.php @@ -42,8 +42,8 @@ public function testExtraction($resource) nowdoc key with whitespace and nonescaped \$\n sequences EOF; // Assert - $expectedCatalogue = array( - 'messages' => array( + $expectedCatalogue = [ + 'messages' => [ 'single-quoted key' => 'prefixsingle-quoted key', 'double-quoted key' => 'prefixdouble-quoted key', 'heredoc key' => 'prefixheredoc key', @@ -54,8 +54,8 @@ public function testExtraction($resource) $expectedHeredoc => 'prefix'.$expectedHeredoc, $expectedNowdoc => 'prefix'.$expectedNowdoc, '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', - ), - 'not_messages' => array( + ], + 'not_messages' => [ 'other-domain-test-no-params-short-array' => 'prefixother-domain-test-no-params-short-array', 'other-domain-test-no-params-long-array' => 'prefixother-domain-test-no-params-long-array', 'other-domain-test-params-short-array' => 'prefixother-domain-test-params-short-array', @@ -65,8 +65,8 @@ public function testExtraction($resource) 'typecast' => 'prefixtypecast', 'msg1' => 'prefixmsg1', 'msg2' => 'prefixmsg2', - ), - ); + ], + ]; $actualCatalogue = $catalogue->all(); $this->assertEquals($expectedCatalogue, $actualCatalogue); @@ -75,7 +75,7 @@ public function testExtraction($resource) public function resourcesProvider() { $directory = __DIR__.'/../Fixtures/Resources/views/'; - $splFiles = array(); + $splFiles = []; foreach (new \DirectoryIterator($directory) as $fileInfo) { if ($fileInfo->isDot()) { continue; @@ -86,13 +86,13 @@ public function resourcesProvider() $splFiles[] = $fileInfo->getFileInfo(); } - return array( - array($directory), - array($phpFile), - array(glob($directory.'*')), - array($splFiles), - array(new \ArrayObject(glob($directory.'*'))), - array(new \ArrayObject($splFiles)), - ); + return [ + [$directory], + [$phpFile], + [glob($directory.'*')], + [$splFiles], + [new \ArrayObject(glob($directory.'*'))], + [new \ArrayObject($splFiles)], + ]; } } diff --git a/Tests/Translation/TranslatorTest.php b/Tests/Translation/TranslatorTest.php index 08b4407a8..aff109368 100644 --- a/Tests/Translation/TranslatorTest.php +++ b/Tests/Translation/TranslatorTest.php @@ -49,9 +49,9 @@ protected function deleteTmpDir() */ public function testTransWithoutCachingOmittingLocale() { - $translator = $this->getTranslator($this->getLoader(), array(), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator = $this->getTranslator($this->getLoader(), [], 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -71,9 +71,9 @@ public function testTransWithoutCachingOmittingLocale() public function testTransWithCachingOmittingLocale() { // prime the cache - $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator = $this->getTranslator($this->getLoader(), ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -89,9 +89,9 @@ public function testTransWithCachingOmittingLocale() $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader->expects($this->never())->method('load'); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -112,7 +112,7 @@ public function testTransWithCachingOmittingLocale() public function testTransWithCachingWithInvalidLocaleOmittingLocale() { $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale', null); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale', null); $translator->trans('foo'); } @@ -124,13 +124,13 @@ public function testTransWithCachingWithInvalidLocaleOmittingLocale() public function testLoadResourcesWithoutCachingOmittingLocale() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); - $resourceFiles = array( - 'fr' => array( + $resourceFiles = [ + 'fr' => [ __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), - ); + ], + ]; - $translator = $this->getTranslator($loader, array('resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator = $this->getTranslator($loader, ['resource_files' => $resourceFiles], 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); $this->assertEquals('répertoire', $translator->trans('folder')); @@ -172,15 +172,15 @@ public function testGetDefaultLocaleOmittingLocaleWithPsrContainer() public function testWarmupOmittingLocale() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); - $resourceFiles = array( - 'fr' => array( + $resourceFiles = [ + 'fr' => [ __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), - ); + ], + ]; // prime the cache - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); - $translator->setFallbackLocales(array('fr')); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles], 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator->setFallbackLocales(['fr']); $translator->warmup($this->tmpDir); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); @@ -188,9 +188,9 @@ public function testWarmupOmittingLocale() ->expects($this->never()) ->method('load'); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles], 'yml', '\Symfony\Bundle\FrameworkBundle\Translation\Translator', null); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('fr')); + $translator->setFallbackLocales(['fr']); $this->assertEquals('répertoire', $translator->trans('folder')); } @@ -198,7 +198,7 @@ public function testTransWithoutCaching() { $translator = $this->getTranslator($this->getLoader()); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -214,9 +214,9 @@ public function testTransWithoutCaching() public function testTransWithCaching() { // prime the cache - $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir)); + $translator = $this->getTranslator($this->getLoader(), ['cache_dir' => $this->tmpDir]); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -232,9 +232,9 @@ public function testTransWithCaching() $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); $loader->expects($this->never())->method('load'); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); + $translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -254,7 +254,7 @@ public function testTransWithCaching() public function testTransWithCachingWithInvalidLocale() { $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale'); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale'); $translator->trans('foo'); } @@ -262,13 +262,13 @@ public function testTransWithCachingWithInvalidLocale() public function testLoadResourcesWithoutCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); - $resourceFiles = array( - 'fr' => array( + $resourceFiles = [ + 'fr' => [ __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), - ); + ], + ]; - $translator = $this->getTranslator($loader, array('resource_files' => $resourceFiles), 'yml'); + $translator = $this->getTranslator($loader, ['resource_files' => $resourceFiles], 'yml'); $translator->setLocale('fr'); $this->assertEquals('répertoire', $translator->trans('folder')); @@ -290,13 +290,13 @@ public function testInvalidOptions() { $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - (new Translator($container, new MessageFormatter(), 'en', array(), array('foo' => 'bar'))); + (new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar'])); } /** @dataProvider getDebugModeAndCacheDirCombinations */ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache) { - $someCatalogue = $this->getCatalogue('some_locale', array()); + $someCatalogue = $this->getCatalogue('some_locale', []); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); @@ -312,10 +312,10 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e ->with('second_resource.some_locale.loader', 'some_locale', 'messages') ->willReturn($someCatalogue); - $options = array( - 'resource_files' => array('some_locale' => array('messages.some_locale.loader')), + $options = [ + 'resource_files' => ['some_locale' => ['messages.some_locale.loader']], 'debug' => $debug, - ); + ]; if ($enableCache) { $options['cache_dir'] = $this->tmpDir; @@ -325,20 +325,20 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e $translator = $this->createTranslator($loader, $options); $translator->addResource('loader', 'second_resource.some_locale.loader', 'some_locale', 'messages'); - $translator->trans('some_message', array(), null, 'some_locale'); + $translator->trans('some_message', [], null, 'some_locale'); } public function getDebugModeAndCacheDirCombinations() { - return array( - array(false, false), - array(true, false), - array(false, true), - array(true, true), - ); + return [ + [false, false], + [true, false], + [false, true], + [true, true], + ]; } - protected function getCatalogue($locale, $messages, $resources = array()) + protected function getCatalogue($locale, $messages, $resources = []) { $catalogue = new MessageCatalogue($locale); foreach ($messages as $key => $translation) { @@ -357,53 +357,53 @@ protected function getLoader() $loader ->expects($this->at(0)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr', array( + ->will($this->returnValue($this->getCatalogue('fr', [ 'foo' => 'foo (FR)', - )))) + ]))) ; $loader ->expects($this->at(1)) ->method('load') - ->will($this->returnValue($this->getCatalogue('en', array( + ->will($this->returnValue($this->getCatalogue('en', [ 'foo' => 'foo (EN)', 'bar' => 'bar (EN)', 'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)', - )))) + ]))) ; $loader ->expects($this->at(2)) ->method('load') - ->will($this->returnValue($this->getCatalogue('es', array( + ->will($this->returnValue($this->getCatalogue('es', [ 'foobar' => 'foobar (ES)', - )))) + ]))) ; $loader ->expects($this->at(3)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt-PT', array( + ->will($this->returnValue($this->getCatalogue('pt-PT', [ 'foobarfoo' => 'foobarfoo (PT-PT)', - )))) + ]))) ; $loader ->expects($this->at(4)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt_BR', array( + ->will($this->returnValue($this->getCatalogue('pt_BR', [ 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', - )))) + ]))) ; $loader ->expects($this->at(5)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr.UTF-8', array( + ->will($this->returnValue($this->getCatalogue('fr.UTF-8', [ 'foobarbaz' => 'foobarbaz (fr.UTF-8)', - )))) + ]))) ; $loader ->expects($this->at(6)) ->method('load') - ->will($this->returnValue($this->getCatalogue('sr@latin', array( + ->will($this->returnValue($this->getCatalogue('sr@latin', [ 'foobarbax' => 'foobarbax (sr@latin)', - )))) + ]))) ; return $loader; @@ -421,7 +421,7 @@ protected function getContainer($loader) return $container; } - public function getTranslator($loader, $options = array(), $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en') + public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en') { $translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale); @@ -441,15 +441,15 @@ public function getTranslator($loader, $options = array(), $loaderFomat = 'loade public function testWarmup() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); - $resourceFiles = array( - 'fr' => array( + $resourceFiles = [ + 'fr' => [ __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), - ); + ], + ]; // prime the cache - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); - $translator->setFallbackLocales(array('fr')); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles], 'yml'); + $translator->setFallbackLocales(['fr']); $translator->warmup($this->tmpDir); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); @@ -457,9 +457,9 @@ public function testWarmup() ->expects($this->never()) ->method('load'); - $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml'); + $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles], 'yml'); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('fr')); + $translator->setFallbackLocales(['fr']); $this->assertEquals('répertoire', $translator->trans('folder')); } @@ -469,7 +469,7 @@ private function createTranslator($loader, $options, $translatorClass = '\Symfon return new $translatorClass( $this->getContainer($loader), new MessageFormatter(), - array($loaderFomat => array($loaderFomat)), + [$loaderFomat => [$loaderFomat]], $options ); } @@ -478,7 +478,7 @@ private function createTranslator($loader, $options, $translatorClass = '\Symfon $this->getContainer($loader), new MessageFormatter(), $defaultLocale, - array($loaderFomat => array($loaderFomat)), + [$loaderFomat => [$loaderFomat]], $options ); } diff --git a/Tests/Validator/ConstraintValidatorFactoryTest.php b/Tests/Validator/ConstraintValidatorFactoryTest.php index f82c3f450..864bd3c3b 100644 --- a/Tests/Validator/ConstraintValidatorFactoryTest.php +++ b/Tests/Validator/ConstraintValidatorFactoryTest.php @@ -55,7 +55,7 @@ public function testGetInstanceReturnsServiceWithAlias() $container = new Container(); $container->set('validator_constraint_service', $validator); - $factory = new ConstraintValidatorFactory($container, array('validator_constraint_alias' => 'validator_constraint_service')); + $factory = new ConstraintValidatorFactory($container, ['validator_constraint_alias' => 'validator_constraint_service']); $this->assertSame($validator, $factory->getInstance(new ConstraintAliasStub())); } diff --git a/Translation/Translator.php b/Translation/Translator.php index a1438f60e..b76a221c8 100644 --- a/Translation/Translator.php +++ b/Translation/Translator.php @@ -28,11 +28,11 @@ class Translator extends BaseTranslator implements WarmableInterface protected $container; protected $loaderIds; - protected $options = array( + protected $options = [ 'cache_dir' => null, 'debug' => false, - 'resource_files' => array(), - ); + 'resource_files' => [], + ]; /** * @var array @@ -45,7 +45,7 @@ class Translator extends BaseTranslator implements WarmableInterface * * @var array */ - private $resources = array(); + private $resources = []; /** * Constructor. @@ -64,7 +64,7 @@ class Translator extends BaseTranslator implements WarmableInterface * * @throws InvalidArgumentException */ - public function __construct(ContainerInterface $container, $formatter, $defaultLocale = null, array $loaderIds = array(), array $options = array()) + public function __construct(ContainerInterface $container, $formatter, $defaultLocale = null, array $loaderIds = [], array $options = []) { // BC 3.x, to be removed in 4.0 along with the $defaultLocale default value if (\is_array($defaultLocale) || 3 > \func_num_args()) { @@ -103,7 +103,7 @@ public function warmUp($cacheDir) return; } - $locales = array_merge($this->getFallbackLocales(), array($this->getLocale()), $this->resourceLocales); + $locales = array_merge($this->getFallbackLocales(), [$this->getLocale()], $this->resourceLocales); foreach (array_unique($locales) as $locale) { // reset catalogue in case it's already loaded during the dump of the other locales. if (isset($this->catalogues[$locale])) { @@ -116,7 +116,7 @@ public function warmUp($cacheDir) public function addResource($format, $resource, $locale, $domain = null) { - $this->resources[] = array($format, $resource, $locale, $domain); + $this->resources[] = [$format, $resource, $locale, $domain]; } /** @@ -134,7 +134,7 @@ protected function initialize() list($format, $resource, $locale, $domain) = $params; parent::addResource($format, $resource, $locale, $domain); } - $this->resources = array(); + $this->resources = []; foreach ($this->loaderIds as $id => $aliases) { foreach ($aliases as $alias) { diff --git a/Validator/ConstraintValidatorFactory.php b/Validator/ConstraintValidatorFactory.php index 78eb6b067..b862de487 100644 --- a/Validator/ConstraintValidatorFactory.php +++ b/Validator/ConstraintValidatorFactory.php @@ -47,7 +47,7 @@ class ConstraintValidatorFactory extends ContainerConstraintValidatorFactory protected $container; protected $validators; - public function __construct(ContainerInterface $container, array $validators = array()) + public function __construct(ContainerInterface $container, array $validators = []) { parent::__construct($container);