Skip to content

Commit

Permalink
Merge branch '4.1' into 4.2
Browse files Browse the repository at this point in the history
* 4.1:
  fixed tests
  fixed CS
  fixed CS
  fixed CS
  fixed short array CS in comments
  fixed CS in ExpressionLanguage fixtures
  fixed CS in generated files
  fixed CS on generated container files
  fixed CS on Form PHP templates
  fixed CS on YAML fixtures
  fixed fixtures
  switched array() to []
  • Loading branch information
fabpot committed Jan 16, 2019
2 parents 22522df + 0e2b81a commit 29063f2
Show file tree
Hide file tree
Showing 221 changed files with 1,407 additions and 1,407 deletions.
4 changes: 2 additions & 2 deletions CacheWarmer/AbstractPhpFileCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,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
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/RouterCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function isOptional()
*/
public static function getSubscribedServices()
{
return array(
return [
'router' => RouterInterface::class,
);
];
}
}
2 changes: 1 addition & 1 deletion CacheWarmer/SerializerCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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) {
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/TemplateFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -72,7 +72,7 @@ public function findAllTemplates()
*/
private function findTemplatesInFolder($dir)
{
$templates = array();
$templates = [];

if (is_dir($dir)) {
$finder = new Finder();
Expand Down
2 changes: 1 addition & 1 deletion CacheWarmer/TemplatePathsCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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), '/');
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/TranslationsCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function isOptional()
*/
public static function getSubscribedServices()
{
return array(
return [
'translator' => TranslatorInterface::class,
);
];
}
}
2 changes: 1 addition & 1 deletion CacheWarmer/ValidatorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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) {
Expand Down
2 changes: 1 addition & 1 deletion Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions Command/AbstractConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions Command/AssetsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function __construct(Filesystem $filesystem)
protected function configure()
{
$this
->setDefinition(array(
->setDefinition([
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', null),
))
])
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
->addOption('no-cleanup', null, InputOption::VALUE_NONE, 'Do not remove the assets of the bundles that no longer exist')
Expand Down Expand Up @@ -125,10 +125,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')) {
Expand Down Expand Up @@ -161,13 +161,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($method === $expectedMethod) {
$rows[] = array(sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method);
$rows[] = [sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method];
} else {
$rows[] = array(sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method);
$rows[] = [sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method];
}
} catch (\Exception $e) {
$exitCode = 1;
$rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage());
$rows[] = [sprintf('<fg=red;options=bold>%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
Expand All @@ -177,7 +177,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) {
Expand Down
8 changes: 4 additions & 4 deletions Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function __construct(CacheClearerInterface $cacheClearer, Filesystem $fil
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 <info>%command.name%</info> command clears the application cache for a given environment
Expand Down Expand Up @@ -137,7 +137,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).'/';
Expand Down Expand Up @@ -195,7 +195,7 @@ private function warmup(string $warmupDir, string $realCacheDir, bool $enableOpt
}

// 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);
Expand Down
8 changes: 4 additions & 4 deletions Command/CachePoolClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function __construct(Psr6CacheClearer $poolClearer)
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 <info>%command.name%</info> command clears the given cache pools or cache pool clearers.
Expand All @@ -64,8 +64,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)) {
Expand Down
4 changes: 2 additions & 2 deletions Command/CachePoolDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function __construct(Psr6CacheClearer $poolClearer)
protected function configure()
{
$this
->setDefinition(array(
->setDefinition([
new InputArgument('pool', InputArgument::REQUIRED, 'The cache pool from which to delete an item'),
new InputArgument('key', InputArgument::REQUIRED, 'The cache key to delete from the pool'),
))
])
->setDescription('Deletes an item from a cache pool')
->setHelp(<<<'EOF'
The <info>%command.name%</info> deletes an item from a given cache pool.
Expand Down
4 changes: 2 additions & 2 deletions Command/CacheWarmupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public function __construct(CacheWarmerAggregate $cacheWarmer)
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 <info>%command.name%</info> command warms up the cache.
Expand Down
6 changes: 3 additions & 3 deletions Command/ConfigDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class ConfigDebugCommand extends AbstractConfigCommand
protected function configure()
{
$this
->setDefinition(array(
->setDefinition([
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
))
])
->setDescription('Dumps the current configuration for an extension')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command dumps the current configuration for an
Expand Down Expand Up @@ -95,7 +95,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;
}
Expand Down
10 changes: 5 additions & 5 deletions Command/ConfigDumpReferenceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <info>%command.name%</info> command dumps the default configuration for an
Expand Down Expand Up @@ -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. <comment>config:dump-reference FrameworkBundle</comment>)',
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
));
]);

return;
}

$extension = $this->findExtension($name);

$configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
$configuration = $extension->getConfiguration([], $this->getContainerBuilder());

$this->validateConfiguration($extension, $configuration);

Expand Down
8 changes: 4 additions & 4 deletions Command/EventDispatcherDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public function __construct(EventDispatcherInterface $dispatcher)
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 <info>%command.name%</info> command displays all configured listeners:
Expand All @@ -73,15 +73,15 @@ 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));

return;
}

$options = array('event' => $event);
$options = ['event' => $event];
}

$helper = new DescriptorHelper();
Expand Down
14 changes: 7 additions & 7 deletions Command/RouterDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public function __construct(RouterInterface $router)
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 <info>%command.name%</info> displays the configured routes:
Expand Down Expand Up @@ -88,25 +88,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
}

$helper->describe($io, $route, array(
$helper->describe($io, $route, [
'format' => $input->getOption('format'),
'raw_text' => $input->getOption('raw'),
'name' => $name,
'output' => $io,
));
]);
} else {
$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,
));
]);
}
}

private function findRouteNameContaining(string $name, RouteCollection $routes): array
{
$foundRoutesNames = array();
$foundRoutesNames = [];
foreach ($routes as $routeName => $route) {
if (false !== stripos($routeName, $name)) {
$foundRoutesNames[] = $routeName;
Expand Down
Loading

0 comments on commit 29063f2

Please sign in to comment.