From 3f2c19679b4146ed07ce696751914df22d01406c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 10 May 2023 10:52:57 +0200 Subject: [PATCH] Consistently use var $container to reference the container builder+configurator --- .../Command/BuildDebugContainerTrait.php | 8 +-- .../Command/ContainerDebugCommand.php | 22 +++---- .../Command/ContainerLintCommand.php | 8 +-- .../Command/DebugAutowiringCommand.php | 18 +++--- .../Console/Descriptor/Descriptor.php | 36 +++++------ .../Console/Descriptor/JsonDescriptor.php | 50 +++++++-------- .../Console/Descriptor/MarkdownDescriptor.php | 36 +++++------ .../Console/Descriptor/TextDescriptor.php | 34 +++++----- .../Console/Descriptor/XmlDescriptor.php | 64 +++++++++---------- .../Functional/WebProfilerBundleKernel.php | 6 +- .../ResolveParameterPlaceHoldersPassTest.php | 50 +++++++-------- .../config/services_with_enumeration.php | 6 +- .../Tests/Loader/XmlFileLoaderTest.php | 6 +- 13 files changed, 172 insertions(+), 172 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php index 0b1038e1cb424..04e3c3c456194 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php @@ -26,7 +26,7 @@ */ trait BuildDebugContainerTrait { - protected $containerBuilder; + protected ContainerBuilder $container; /** * Loads the ContainerBuilder from the cache. @@ -35,8 +35,8 @@ trait BuildDebugContainerTrait */ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilder { - if ($this->containerBuilder) { - return $this->containerBuilder; + if (isset($this->container)) { + return $this->container; } if (!$kernel->isDebug() || !$kernel->getContainer()->getParameter('debug.container.dump') || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) { @@ -59,6 +59,6 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde $container->getCompilerPassConfig()->setBeforeRemovingPasses([]); } - return $this->containerBuilder = $container; + return $this->container = $container; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index 300fae1b8aa79..cd1af0d5d43c0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -261,15 +261,15 @@ protected function validateInput(InputInterface $input): void } } - private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $name, bool $showHidden): string + private function findProperServiceName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $container, string $name, bool $showHidden): string { $name = ltrim($name, '\\'); - if ($builder->has($name) || !$input->isInteractive()) { + if ($container->has($name) || !$input->isInteractive()) { return $name; } - $matchingServices = $this->findServiceIdsContaining($builder, $name, $showHidden); + $matchingServices = $this->findServiceIdsContaining($container, $name, $showHidden); if (!$matchingServices) { throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name)); } @@ -281,13 +281,13 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io, return $io->choice('Select one of the following services to display its information', $matchingServices); } - private function findProperTagName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $builder, string $tagName): string + private function findProperTagName(InputInterface $input, SymfonyStyle $io, ContainerBuilder $container, string $tagName): string { - if (\in_array($tagName, $builder->findTags(), true) || !$input->isInteractive()) { + if (\in_array($tagName, $container->findTags(), true) || !$input->isInteractive()) { return $tagName; } - $matchingTags = $this->findTagsContaining($builder, $tagName); + $matchingTags = $this->findTagsContaining($container, $tagName); if (!$matchingTags) { throw new InvalidArgumentException(sprintf('No tags found that match "%s".', $tagName)); } @@ -299,15 +299,15 @@ private function findProperTagName(InputInterface $input, SymfonyStyle $io, Cont return $io->choice('Select one of the following tags to display its information', $matchingTags); } - private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden): array + private function findServiceIdsContaining(ContainerBuilder $container, string $name, bool $showHidden): array { - $serviceIds = $builder->getServiceIds(); + $serviceIds = $container->getServiceIds(); $foundServiceIds = $foundServiceIdsIgnoringBackslashes = []; foreach ($serviceIds as $serviceId) { if (!$showHidden && str_starts_with($serviceId, '.')) { continue; } - if (!$showHidden && $builder->hasDefinition($serviceId) && $builder->getDefinition($serviceId)->hasTag('container.excluded')) { + if (!$showHidden && $container->hasDefinition($serviceId) && $container->getDefinition($serviceId)->hasTag('container.excluded')) { continue; } if (false !== stripos(str_replace('\\', '', $serviceId), $name)) { @@ -321,9 +321,9 @@ private function findServiceIdsContaining(ContainerBuilder $builder, string $nam return $foundServiceIds ?: $foundServiceIdsIgnoringBackslashes; } - private function findTagsContaining(ContainerBuilder $builder, string $tagName): array + private function findTagsContaining(ContainerBuilder $container, string $tagName): array { - $tags = $builder->findTags(); + $tags = $container->findTags(); $foundTags = []; foreach ($tags as $tag) { if (str_contains($tag, $tagName)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php index 0d71e6985e206..188c56585f97d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php @@ -31,7 +31,7 @@ #[AsCommand(name: 'lint:container', description: 'Ensure that arguments injected into services match type declarations')] final class ContainerLintCommand extends Command { - private ContainerBuilder $containerBuilder; + private ContainerBuilder $container; protected function configure(): void { @@ -70,8 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function getContainerBuilder(): ContainerBuilder { - if (isset($this->containerBuilder)) { - return $this->containerBuilder; + if (isset($this->container)) { + return $this->container; } $kernel = $this->getApplication()->getKernel(); @@ -108,6 +108,6 @@ private function getContainerBuilder(): ContainerBuilder $container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100); - return $this->containerBuilder = $container; + return $this->container = $container; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index 185278a662e1c..8c47cb12c586b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -70,8 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io = new SymfonyStyle($input, $output); $errorIo = $io->getErrorStyle(); - $builder = $this->getContainerBuilder($this->getApplication()->getKernel()); - $serviceIds = $builder->getServiceIds(); + $container = $this->getContainerBuilder($this->getApplication()->getKernel()); + $serviceIds = $container->getServiceIds(); $serviceIds = array_filter($serviceIds, $this->filterToServiceTypes(...)); if ($search = $input->getArgument('search')) { @@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $previousId = '-'; $serviceIdsNb = 0; foreach ($serviceIds as $serviceId) { - if ($builder->hasDefinition($serviceId) && $builder->getDefinition($serviceId)->hasTag('container.excluded')) { + if ($container->hasDefinition($serviceId) && $container->getDefinition($serviceId)->hasTag('container.excluded')) { continue; } $text = []; @@ -119,11 +119,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $serviceLine = sprintf('%s', $fileLink, $serviceId); } - if ($builder->hasAlias($serviceId)) { + if ($container->hasAlias($serviceId)) { $hasAlias[$serviceId] = true; - $serviceAlias = $builder->getAlias($serviceId); + $serviceAlias = $container->getAlias($serviceId); - if ($builder->hasDefinition($serviceAlias) && $decorated = $builder->getDefinition($serviceAlias)->getTag('container.decorator')) { + if ($container->hasDefinition($serviceAlias) && $decorated = $container->getDefinition($serviceAlias)->getTag('container.decorator')) { $serviceLine .= ' ('.$decorated[0]['id'].')'; } else { $serviceLine .= ' ('.$serviceAlias.')'; @@ -135,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } elseif (!$all) { ++$serviceIdsNb; continue; - } elseif ($builder->getDefinition($serviceId)->isDeprecated()) { + } elseif ($container->getDefinition($serviceId)->isDeprecated()) { $serviceLine .= ' - deprecated'; } $text[] = $serviceLine; @@ -169,9 +169,9 @@ private function getFileLink(string $class): string public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { if ($input->mustSuggestArgumentValuesFor('search')) { - $builder = $this->getContainerBuilder($this->getApplication()->getKernel()); + $container = $this->getContainerBuilder($this->getApplication()->getKernel()); - $suggestions->suggestValues(array_filter($builder->getServiceIds(), $this->filterToServiceTypes(...))); + $suggestions->suggestValues(array_filter($container->getServiceIds(), $this->filterToServiceTypes(...))); } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index 24b1545f104bf..f4de2f09192da 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -84,7 +84,7 @@ abstract protected function describeRoute(Route $route, array $options = []): vo abstract protected function describeContainerParameters(ParameterBag $parameters, array $options = []): void; - abstract protected function describeContainerTags(ContainerBuilder $builder, array $options = []): void; + abstract protected function describeContainerTags(ContainerBuilder $container, array $options = []): void; /** * Describes a container service by its name. @@ -94,7 +94,7 @@ abstract protected function describeContainerTags(ContainerBuilder $builder, arr * * @param Definition|Alias|object $service */ - abstract protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null): void; + abstract protected function describeContainerService(object $service, array $options = [], ContainerBuilder $container = null): void; /** * Describes container services. @@ -102,13 +102,13 @@ abstract protected function describeContainerService(object $service, array $opt * Common options are: * * tag: filters described services by given tag */ - abstract protected function describeContainerServices(ContainerBuilder $builder, array $options = []): void; + abstract protected function describeContainerServices(ContainerBuilder $container, array $options = []): void; - abstract protected function describeContainerDeprecations(ContainerBuilder $builder, array $options = []): void; + abstract protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void; - abstract protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $builder = null): void; + abstract protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void; - abstract protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null): void; + abstract protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void; abstract protected function describeContainerParameter(mixed $parameter, array $options = []): void; @@ -170,15 +170,15 @@ protected function formatParameter(mixed $value): string return (string) $value; } - protected function resolveServiceDefinition(ContainerBuilder $builder, string $serviceId): mixed + protected function resolveServiceDefinition(ContainerBuilder $container, string $serviceId): mixed { - if ($builder->hasDefinition($serviceId)) { - return $builder->getDefinition($serviceId); + if ($container->hasDefinition($serviceId)) { + return $container->getDefinition($serviceId); } // Some service IDs don't have a Definition, they're aliases - if ($builder->hasAlias($serviceId)) { - return $builder->getAlias($serviceId); + if ($container->hasAlias($serviceId)) { + return $container->getAlias($serviceId); } if ('service_container' === $serviceId) { @@ -186,18 +186,18 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, string $s } // the service has been injected in some special way, just return the service - return $builder->get($serviceId); + return $container->get($serviceId); } - protected function findDefinitionsByTag(ContainerBuilder $builder, bool $showHidden): array + protected function findDefinitionsByTag(ContainerBuilder $container, bool $showHidden): array { $definitions = []; - $tags = $builder->findTags(); + $tags = $container->findTags(); asort($tags); foreach ($tags as $tag) { - foreach ($builder->findTaggedServiceIds($tag) as $serviceId => $attributes) { - $definition = $this->resolveServiceDefinition($builder, $serviceId); + foreach ($container->findTaggedServiceIds($tag) as $serviceId => $attributes) { + $definition = $this->resolveServiceDefinition($container, $serviceId); if ($showHidden xor '.' === ($serviceId[0] ?? null)) { continue; @@ -334,12 +334,12 @@ private function getContainerEnvVars(ContainerBuilder $container): array return array_values($envs); } - protected function getServiceEdges(ContainerBuilder $builder, string $serviceId): array + protected function getServiceEdges(ContainerBuilder $container, string $serviceId): array { try { return array_values(array_unique(array_map( fn (ServiceReferenceGraphEdge $edge) => $edge->getSourceNode()->getId(), - $builder->getCompiler()->getServiceReferenceGraph()->getNode($serviceId)->getInEdges() + $container->getCompiler()->getServiceReferenceGraph()->getNode($serviceId)->getInEdges() ))); } catch (InvalidArgumentException $exception) { return []; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 5806fd32f8ad8..09e975ad4a3d7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -52,41 +52,41 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ $this->writeData($this->sortParameters($parameters), $options); } - protected function describeContainerTags(ContainerBuilder $builder, array $options = []): void + protected function describeContainerTags(ContainerBuilder $container, array $options = []): void { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; $data = []; - foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) { + foreach ($this->findDefinitionsByTag($container, $showHidden) as $tag => $definitions) { $data[$tag] = []; foreach ($definitions as $definition) { - $data[$tag][] = $this->getContainerDefinitionData($definition, true, false, $builder, $options['id'] ?? null); + $data[$tag][] = $this->getContainerDefinitionData($definition, true, false, $container, $options['id'] ?? null); } } $this->writeData($data, $options); } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerService(object $service, array $options = [], ContainerBuilder $container = null): void { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } if ($service instanceof Alias) { - $this->describeContainerAlias($service, $options, $builder); + $this->describeContainerAlias($service, $options, $container); } elseif ($service instanceof Definition) { - $this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $builder, $options['id']), $options); + $this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, $options['id']), $options); } else { $this->writeData($service::class, $options); } } - protected function describeContainerServices(ContainerBuilder $builder, array $options = []): void + protected function describeContainerServices(ContainerBuilder $container, array $options = []): void { $serviceIds = isset($options['tag']) && $options['tag'] - ? $this->sortTaggedServicesByPriority($builder->findTaggedServiceIds($options['tag'])) - : $this->sortServiceIds($builder->getServiceIds()); + ? $this->sortTaggedServicesByPriority($container->findTaggedServiceIds($options['tag'])) + : $this->sortServiceIds($container->getServiceIds()); $showHidden = isset($options['show_hidden']) && $options['show_hidden']; $omitTags = isset($options['omit_tags']) && $options['omit_tags']; $showArguments = isset($options['show_arguments']) && $options['show_arguments']; @@ -97,7 +97,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } foreach ($serviceIds as $serviceId) { - $service = $this->resolveServiceDefinition($builder, $serviceId); + $service = $this->resolveServiceDefinition($container, $serviceId); if ($showHidden xor '.' === ($serviceId[0] ?? null)) { continue; @@ -106,7 +106,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o if ($service instanceof Alias) { $data['aliases'][$serviceId] = $this->getContainerAliasData($service); } elseif ($service instanceof Definition) { - $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments, $builder, $serviceId); + $data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments, $container, $serviceId); } else { $data['services'][$serviceId] = $service::class; } @@ -115,21 +115,21 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $this->writeData($data, $options); } - protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void { - $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $builder, $options['id'] ?? null), $options); + $this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, $options['id'] ?? null), $options); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void { - if (!$builder) { + if (!$container) { $this->writeData($this->getContainerAliasData($alias), $options); return; } $this->writeData( - [$this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $builder, (string) $alias)], + [$this->getContainerAliasData($alias), $this->getContainerDefinitionData($container->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container, (string) $alias)], array_merge($options, ['id' => (string) $alias]) ); } @@ -156,9 +156,9 @@ protected function describeContainerEnvVars(array $envs, array $options = []): v throw new LogicException('Using the JSON format to debug environment variables is not supported.'); } - protected function describeContainerDeprecations(ContainerBuilder $builder, array $options = []): void + protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void { - $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $builder->getParameter('kernel.build_dir'), $builder->getParameter('kernel.container_class')); + $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $container->getParameter('kernel.build_dir'), $container->getParameter('kernel.container_class')); if (!file_exists($containerDeprecationFilePath)) { throw new RuntimeException('The deprecation file does not exist, please try warming the cache first.'); } @@ -217,7 +217,7 @@ protected function getRouteData(Route $route): array return $data; } - private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false, ContainerBuilder $builder = null, string $id = null): array + private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false, ContainerBuilder $container = null, string $id = null): array { $data = [ 'class' => (string) $definition->getClass(), @@ -242,7 +242,7 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa } if ($showArguments) { - $data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $showArguments, $builder, $id); + $data['arguments'] = $this->describeValue($definition->getArguments(), $omitTags, $showArguments, $container, $id); } $data['file'] = $definition->getFile(); @@ -279,7 +279,7 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa } } - $data['usages'] = null !== $builder && null !== $id ? $this->getServiceEdges($builder, $id) : []; + $data['usages'] = null !== $container && null !== $id ? $this->getServiceEdges($container, $id) : []; return $data; } @@ -390,12 +390,12 @@ private function getCallableData(mixed $callable): array throw new \InvalidArgumentException('Callable is not describable.'); } - private function describeValue($value, bool $omitTags, bool $showArguments, ContainerBuilder $builder = null, string $id = null): mixed + private function describeValue($value, bool $omitTags, bool $showArguments, ContainerBuilder $container = null, string $id = null): mixed { if (\is_array($value)) { $data = []; foreach ($value as $k => $v) { - $data[$k] = $this->describeValue($v, $omitTags, $showArguments, $builder, $id); + $data[$k] = $this->describeValue($v, $omitTags, $showArguments, $container, $id); } return $data; @@ -417,11 +417,11 @@ private function describeValue($value, bool $omitTags, bool $showArguments, Cont } if ($value instanceof ArgumentInterface) { - return $this->describeValue($value->getValues(), $omitTags, $showArguments, $builder, $id); + return $this->describeValue($value->getValues(), $omitTags, $showArguments, $container, $id); } if ($value instanceof Definition) { - return $this->getContainerDefinitionData($value, $omitTags, $showArguments, $builder, $id); + return $this->getContainerDefinitionData($value, $omitTags, $showArguments, $container, $id); } return $value; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 4581e0e198b99..1289c8ded9303 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -74,21 +74,21 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ } } - protected function describeContainerTags(ContainerBuilder $builder, array $options = []): void + protected function describeContainerTags(ContainerBuilder $container, array $options = []): void { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; $this->write("Container tags\n=============="); - foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) { + foreach ($this->findDefinitionsByTag($container, $showHidden) as $tag => $definitions) { $this->write("\n\n".$tag."\n".str_repeat('-', \strlen($tag))); foreach ($definitions as $serviceId => $definition) { $this->write("\n\n"); - $this->describeContainerDefinition($definition, ['omit_tags' => true, 'id' => $serviceId], $builder); + $this->describeContainerDefinition($definition, ['omit_tags' => true, 'id' => $serviceId], $container); } } } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerService(object $service, array $options = [], ContainerBuilder $container = null): void { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); @@ -97,17 +97,17 @@ protected function describeContainerService(object $service, array $options = [] $childOptions = array_merge($options, ['id' => $options['id'], 'as_array' => true]); if ($service instanceof Alias) { - $this->describeContainerAlias($service, $childOptions, $builder); + $this->describeContainerAlias($service, $childOptions, $container); } elseif ($service instanceof Definition) { - $this->describeContainerDefinition($service, $childOptions, $builder); + $this->describeContainerDefinition($service, $childOptions, $container); } else { $this->write(sprintf('**`%s`:** `%s`', $options['id'], $service::class)); } } - protected function describeContainerDeprecations(ContainerBuilder $builder, array $options = []): void + protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void { - $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $builder->getParameter('kernel.build_dir'), $builder->getParameter('kernel.container_class')); + $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $container->getParameter('kernel.build_dir'), $container->getParameter('kernel.container_class')); if (!file_exists($containerDeprecationFilePath)) { throw new RuntimeException('The deprecation file does not exist, please try warming the cache first.'); } @@ -132,7 +132,7 @@ protected function describeContainerDeprecations(ContainerBuilder $builder, arra } } - protected function describeContainerServices(ContainerBuilder $builder, array $options = []): void + protected function describeContainerServices(ContainerBuilder $container, array $options = []): void { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; @@ -143,8 +143,8 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $this->write($title."\n".str_repeat('=', \strlen($title))); $serviceIds = isset($options['tag']) && $options['tag'] - ? $this->sortTaggedServicesByPriority($builder->findTaggedServiceIds($options['tag'])) - : $this->sortServiceIds($builder->getServiceIds()); + ? $this->sortTaggedServicesByPriority($container->findTaggedServiceIds($options['tag'])) + : $this->sortServiceIds($container->getServiceIds()); $showArguments = isset($options['show_arguments']) && $options['show_arguments']; $services = ['definitions' => [], 'aliases' => [], 'services' => []]; @@ -153,7 +153,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } foreach ($serviceIds as $serviceId) { - $service = $this->resolveServiceDefinition($builder, $serviceId); + $service = $this->resolveServiceDefinition($container, $serviceId); if ($showHidden xor '.' === ($serviceId[0] ?? null)) { continue; @@ -172,7 +172,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, ['id' => $id, 'show_arguments' => $showArguments], $builder); + $this->describeContainerDefinition($service, ['id' => $id, 'show_arguments' => $showArguments], $container); } } @@ -193,7 +193,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } } - protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void { $output = ''; @@ -257,13 +257,13 @@ protected function describeContainerDefinition(Definition $definition, array $op } } - $inEdges = null !== $builder && isset($options['id']) ? $this->getServiceEdges($builder, $options['id']) : []; + $inEdges = null !== $container && isset($options['id']) ? $this->getServiceEdges($container, $options['id']) : []; $output .= "\n".'- Usages: '.($inEdges ? implode(', ', $inEdges) : 'none'); $this->write(isset($options['id']) ? sprintf("### %s\n\n%s\n", $options['id'], $output) : $output); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void { $output = '- Service: `'.$alias.'`' ."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no'); @@ -276,12 +276,12 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con $this->write(sprintf("### %s\n\n%s\n", $options['id'], $output)); - if (!$builder) { + if (!$container) { return; } $this->write("\n"); - $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]), $builder); + $this->describeContainerDefinition($container->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]), $container); } protected function describeContainerParameter(mixed $parameter, array $options = []): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index f555e7220901c..519d99f3a97cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -125,7 +125,7 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ $options['output']->table($tableHeaders, $tableRows); } - protected function describeContainerTags(ContainerBuilder $builder, array $options = []): void + protected function describeContainerTags(ContainerBuilder $container, array $options = []): void { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; @@ -135,22 +135,22 @@ protected function describeContainerTags(ContainerBuilder $builder, array $optio $options['output']->title('Symfony Container Tags'); } - foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) { + foreach ($this->findDefinitionsByTag($container, $showHidden) as $tag => $definitions) { $options['output']->section(sprintf('"%s" tag', $tag)); $options['output']->listing(array_keys($definitions)); } } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerService(object $service, array $options = [], ContainerBuilder $container = null): void { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } if ($service instanceof Alias) { - $this->describeContainerAlias($service, $options, $builder); + $this->describeContainerAlias($service, $options, $container); } elseif ($service instanceof Definition) { - $this->describeContainerDefinition($service, $options, $builder); + $this->describeContainerDefinition($service, $options, $container); } else { $options['output']->title(sprintf('Information for Service "%s"', $options['id'])); $options['output']->table( @@ -162,7 +162,7 @@ protected function describeContainerService(object $service, array $options = [] } } - protected function describeContainerServices(ContainerBuilder $builder, array $options = []): void + protected function describeContainerServices(ContainerBuilder $container, array $options = []): void { $showHidden = isset($options['show_hidden']) && $options['show_hidden']; $showTag = $options['tag'] ?? null; @@ -180,8 +180,8 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $options['output']->title($title); $serviceIds = isset($options['tag']) && $options['tag'] - ? $this->sortTaggedServicesByPriority($builder->findTaggedServiceIds($options['tag'])) - : $this->sortServiceIds($builder->getServiceIds()); + ? $this->sortTaggedServicesByPriority($container->findTaggedServiceIds($options['tag'])) + : $this->sortServiceIds($container->getServiceIds()); $maxTags = []; if (isset($options['filter'])) { @@ -189,7 +189,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o } foreach ($serviceIds as $key => $serviceId) { - $definition = $this->resolveServiceDefinition($builder, $serviceId); + $definition = $this->resolveServiceDefinition($container, $serviceId); // filter out hidden services unless shown explicitly if ($showHidden xor '.' === ($serviceId[0] ?? null)) { @@ -221,7 +221,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $tableRows = []; $rawOutput = isset($options['raw_text']) && $options['raw_text']; foreach ($serviceIds as $serviceId) { - $definition = $this->resolveServiceDefinition($builder, $serviceId); + $definition = $this->resolveServiceDefinition($container, $serviceId); $styledServiceId = $rawOutput ? $serviceId : sprintf('%s', OutputFormatter::escape($serviceId)); if ($definition instanceof Definition) { @@ -251,7 +251,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o $options['output']->table($tableHeaders, $tableRows); } - protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void { if (isset($options['id'])) { $options['output']->title(sprintf('Information for Service "%s"', $options['id'])); @@ -358,15 +358,15 @@ protected function describeContainerDefinition(Definition $definition, array $op $tableRows[] = ['Arguments', implode("\n", $argumentsInformation)]; } - $inEdges = null !== $builder && isset($options['id']) ? $this->getServiceEdges($builder, $options['id']) : []; + $inEdges = null !== $container && isset($options['id']) ? $this->getServiceEdges($container, $options['id']) : []; $tableRows[] = ['Usages', $inEdges ? implode(\PHP_EOL, $inEdges) : 'none']; $options['output']->table($tableHeaders, $tableRows); } - protected function describeContainerDeprecations(ContainerBuilder $builder, array $options = []): void + protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void { - $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $builder->getParameter('kernel.build_dir'), $builder->getParameter('kernel.container_class')); + $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $container->getParameter('kernel.build_dir'), $container->getParameter('kernel.container_class')); if (!file_exists($containerDeprecationFilePath)) { $options['output']->warning('The deprecation file does not exist, please try warming the cache first.'); @@ -390,7 +390,7 @@ protected function describeContainerDeprecations(ContainerBuilder $builder, arra $options['output']->listing($formattedLogs); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void { if ($alias->isPublic() && !$alias->isPrivate()) { $options['output']->comment(sprintf('This service is a public alias for the service %s', (string) $alias)); @@ -398,11 +398,11 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con $options['output']->comment(sprintf('This service is a private alias for the service %s', (string) $alias)); } - if (!$builder) { + if (!$container) { return; } - $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]), $builder); + $this->describeContainerDefinition($container->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]), $container); } protected function describeContainerParameter(mixed $parameter, array $options = []): void diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 17870bb96a69b..79253d53f1b5f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -48,42 +48,42 @@ protected function describeContainerParameters(ParameterBag $parameters, array $ $this->writeDocument($this->getContainerParametersDocument($parameters)); } - protected function describeContainerTags(ContainerBuilder $builder, array $options = []): void + protected function describeContainerTags(ContainerBuilder $container, array $options = []): void { - $this->writeDocument($this->getContainerTagsDocument($builder, isset($options['show_hidden']) && $options['show_hidden'])); + $this->writeDocument($this->getContainerTagsDocument($container, isset($options['show_hidden']) && $options['show_hidden'])); } - protected function describeContainerService(object $service, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerService(object $service, array $options = [], ContainerBuilder $container = null): void { if (!isset($options['id'])) { throw new \InvalidArgumentException('An "id" option must be provided.'); } - $this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder, isset($options['show_arguments']) && $options['show_arguments'])); + $this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $container, isset($options['show_arguments']) && $options['show_arguments'])); } - protected function describeContainerServices(ContainerBuilder $builder, array $options = []): void + protected function describeContainerServices(ContainerBuilder $container, array $options = []): void { - $this->writeDocument($this->getContainerServicesDocument($builder, $options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden'], isset($options['show_arguments']) && $options['show_arguments'], $options['filter'] ?? null, $options['id'] ?? null)); + $this->writeDocument($this->getContainerServicesDocument($container, $options['tag'] ?? null, isset($options['show_hidden']) && $options['show_hidden'], isset($options['show_arguments']) && $options['show_arguments'], $options['filter'] ?? null, $options['id'] ?? null)); } - protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerDefinition(Definition $definition, array $options = [], ContainerBuilder $container = null): void { - $this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $builder)); + $this->writeDocument($this->getContainerDefinitionDocument($definition, $options['id'] ?? null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'], $container)); } - protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null): void + protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $container = null): void { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, $options['id'] ?? null)->childNodes->item(0), true)); - if (!$builder) { + if (!$container) { $this->writeDocument($dom); return; } - $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $alias), (string) $alias, false, false, $builder)->childNodes->item(0), true)); + $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $alias), (string) $alias, false, false, $container)->childNodes->item(0), true)); $this->writeDocument($dom); } @@ -108,9 +108,9 @@ protected function describeContainerEnvVars(array $envs, array $options = []): v throw new LogicException('Using the XML format to debug environment variables is not supported.'); } - protected function describeContainerDeprecations(ContainerBuilder $builder, array $options = []): void + protected function describeContainerDeprecations(ContainerBuilder $container, array $options = []): void { - $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $builder->getParameter('kernel.build_dir'), $builder->getParameter('kernel.container_class')); + $containerDeprecationFilePath = sprintf('%s/%sDeprecations.log', $container->getParameter('kernel.build_dir'), $container->getParameter('kernel.container_class')); if (!file_exists($containerDeprecationFilePath)) { throw new RuntimeException('The deprecation file does not exist, please try warming the cache first.'); } @@ -236,17 +236,17 @@ private function getContainerParametersDocument(ParameterBag $parameters): \DOMD return $dom; } - private function getContainerTagsDocument(ContainerBuilder $builder, bool $showHidden = false): \DOMDocument + private function getContainerTagsDocument(ContainerBuilder $container, bool $showHidden = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); - foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) { + foreach ($this->findDefinitionsByTag($container, $showHidden) as $tag => $definitions) { $containerXML->appendChild($tagXML = $dom->createElement('tag')); $tagXML->setAttribute('name', $tag); foreach ($definitions as $serviceId => $definition) { - $definitionXML = $this->getContainerDefinitionDocument($definition, $serviceId, true, false, $builder); + $definitionXML = $this->getContainerDefinitionDocument($definition, $serviceId, true, false, $container); $tagXML->appendChild($dom->importNode($definitionXML->childNodes->item(0), true)); } } @@ -254,17 +254,17 @@ private function getContainerTagsDocument(ContainerBuilder $builder, bool $showH return $dom; } - private function getContainerServiceDocument(object $service, string $id, ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument + private function getContainerServiceDocument(object $service, string $id, ContainerBuilder $container = null, bool $showArguments = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); if ($service instanceof Alias) { $dom->appendChild($dom->importNode($this->getContainerAliasDocument($service, $id)->childNodes->item(0), true)); - if ($builder) { - $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service, false, $showArguments, $builder)->childNodes->item(0), true)); + if ($container) { + $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($container->getDefinition((string) $service), (string) $service, false, $showArguments, $container)->childNodes->item(0), true)); } } elseif ($service instanceof Definition) { - $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments, $builder)->childNodes->item(0), true)); + $dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments, $container)->childNodes->item(0), true)); } else { $dom->appendChild($serviceXML = $dom->createElement('service')); $serviceXML->setAttribute('id', $id); @@ -274,20 +274,20 @@ private function getContainerServiceDocument(object $service, string $id, Contai return $dom; } - private function getContainerServicesDocument(ContainerBuilder $builder, string $tag = null, bool $showHidden = false, bool $showArguments = false, callable $filter = null, string $id = null): \DOMDocument + private function getContainerServicesDocument(ContainerBuilder $container, string $tag = null, bool $showHidden = false, bool $showArguments = false, callable $filter = null, string $id = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); $serviceIds = $tag - ? $this->sortTaggedServicesByPriority($builder->findTaggedServiceIds($tag)) - : $this->sortServiceIds($builder->getServiceIds()); + ? $this->sortTaggedServicesByPriority($container->findTaggedServiceIds($tag)) + : $this->sortServiceIds($container->getServiceIds()); if ($filter) { $serviceIds = array_filter($serviceIds, $filter); } foreach ($serviceIds as $serviceId) { - $service = $this->resolveServiceDefinition($builder, $serviceId); + $service = $this->resolveServiceDefinition($container, $serviceId); if ($showHidden xor '.' === ($serviceId[0] ?? null)) { continue; @@ -300,7 +300,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, string return $dom; } - private function getContainerDefinitionDocument(Definition $definition, string $id = null, bool $omitTags = false, bool $showArguments = false, ContainerBuilder $builder = null): \DOMDocument + private function getContainerDefinitionDocument(Definition $definition, string $id = null, bool $omitTags = false, bool $showArguments = false, ContainerBuilder $container = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($serviceXML = $dom->createElement('definition')); @@ -361,7 +361,7 @@ private function getContainerDefinitionDocument(Definition $definition, string $ } if ($showArguments) { - foreach ($this->getArgumentNodes($definition->getArguments(), $dom, $builder) as $node) { + foreach ($this->getArgumentNodes($definition->getArguments(), $dom, $container) as $node) { $serviceXML->appendChild($node); } } @@ -383,8 +383,8 @@ private function getContainerDefinitionDocument(Definition $definition, string $ } } - if (null !== $builder && null !== $id) { - $edges = $this->getServiceEdges($builder, $id); + if (null !== $container && null !== $id) { + $edges = $this->getServiceEdges($container, $id); if ($edges) { $serviceXML->appendChild($usagesXML = $dom->createElement('usages')); foreach ($edges as $edge) { @@ -400,7 +400,7 @@ private function getContainerDefinitionDocument(Definition $definition, string $ /** * @return \DOMNode[] */ - private function getArgumentNodes(array $arguments, \DOMDocument $dom, ContainerBuilder $builder = null): array + private function getArgumentNodes(array $arguments, \DOMDocument $dom, ContainerBuilder $container = null): array { $nodes = []; @@ -421,18 +421,18 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom, Container } elseif ($argument instanceof IteratorArgument || $argument instanceof ServiceLocatorArgument) { $argumentXML->setAttribute('type', $argument instanceof IteratorArgument ? 'iterator' : 'service_locator'); - foreach ($this->getArgumentNodes($argument->getValues(), $dom, $builder) as $childArgumentXML) { + foreach ($this->getArgumentNodes($argument->getValues(), $dom, $container) as $childArgumentXML) { $argumentXML->appendChild($childArgumentXML); } } elseif ($argument instanceof Definition) { - $argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true, $builder)->childNodes->item(0), true)); + $argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true, $container)->childNodes->item(0), true)); } elseif ($argument instanceof AbstractArgument) { $argumentXML->setAttribute('type', 'abstract'); $argumentXML->appendChild(new \DOMText($argument->getText())); } elseif (\is_array($argument)) { $argumentXML->setAttribute('type', 'collection'); - foreach ($this->getArgumentNodes($argument, $dom, $builder) as $childArgumentXML) { + foreach ($this->getArgumentNodes($argument, $dom, $container) as $childArgumentXML) { $argumentXML->appendChild($childArgumentXML); } } elseif ($argument instanceof \UnitEnum) { diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php index 78395c4b75a2d..0c98636536771 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Functional/WebProfilerBundleKernel.php @@ -48,7 +48,7 @@ protected function configureRoutes(RoutingConfigurator $routes): void $routes->add('_', '/')->controller('kernel::homepageController'); } - protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { $config = [ 'http_method_override' => false, @@ -58,9 +58,9 @@ protected function configureContainer(ContainerBuilder $containerBuilder, Loader 'router' => ['utf8' => true], ]; - $containerBuilder->loadFromExtension('framework', $config); + $container->loadFromExtension('framework', $config); - $containerBuilder->loadFromExtension('web_profiler', [ + $container->loadFromExtension('web_profiler', [ 'toolbar' => true, 'intercept_redirects' => false, ]); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php index 96c45205459df..2f4a8e1d94141 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php @@ -77,55 +77,55 @@ public function testParameterNotFoundExceptionsIsThrown() $this->expectException(ParameterNotFoundException::class); $this->expectExceptionMessage('The service "baz_service_id" has a dependency on a non-existent parameter "non_existent_param".'); - $containerBuilder = new ContainerBuilder(); - $definition = $containerBuilder->register('baz_service_id'); + $container = new ContainerBuilder(); + $definition = $container->register('baz_service_id'); $definition->setArgument(0, '%non_existent_param%'); $pass = new ResolveParameterPlaceHoldersPass(); - $pass->process($containerBuilder); + $pass->process($container); } public function testParameterNotFoundExceptionsIsNotThrown() { - $containerBuilder = new ContainerBuilder(); - $definition = $containerBuilder->register('baz_service_id'); + $container = new ContainerBuilder(); + $definition = $container->register('baz_service_id'); $definition->setArgument(0, '%non_existent_param%'); $pass = new ResolveParameterPlaceHoldersPass(true, false); - $pass->process($containerBuilder); + $pass->process($container); $this->assertCount(1, $definition->getErrors()); } public function testOnlyProxyTagIsResolved() { - $containerBuilder = new ContainerBuilder(); - $containerBuilder->setParameter('a_param', 'here_you_go'); - $definition = $containerBuilder->register('def'); + $container = new ContainerBuilder(); + $container->setParameter('a_param', 'here_you_go'); + $definition = $container->register('def'); $definition->addTag('foo', ['bar' => '%a_param%']); $definition->addTag('proxy', ['interface' => '%a_param%']); $pass = new ResolveParameterPlaceHoldersPass(true, false); - $pass->process($containerBuilder); + $pass->process($container); $this->assertSame(['foo' => [['bar' => '%a_param%']], 'proxy' => [['interface' => 'here_you_go']]], $definition->getTags()); } private function createContainerBuilder(): ContainerBuilder { - $containerBuilder = new ContainerBuilder(); - - $containerBuilder->setParameter('foo.class', 'Foo'); - $containerBuilder->setParameter('foo.factory.class', 'FooFactory'); - $containerBuilder->setParameter('foo.arg1', 'bar'); - $containerBuilder->setParameter('foo.arg2', ['%foo.arg1%' => 'baz']); - $containerBuilder->setParameter('foo.method', 'foobar'); - $containerBuilder->setParameter('foo.property.name', 'bar'); - $containerBuilder->setParameter('foo.property.value', 'baz'); - $containerBuilder->setParameter('foo.file', 'foo.php'); - $containerBuilder->setParameter('alias.id', 'bar'); - - $fooDefinition = $containerBuilder->register('foo', '%foo.class%'); + $container = new ContainerBuilder(); + + $container->setParameter('foo.class', 'Foo'); + $container->setParameter('foo.factory.class', 'FooFactory'); + $container->setParameter('foo.arg1', 'bar'); + $container->setParameter('foo.arg2', ['%foo.arg1%' => 'baz']); + $container->setParameter('foo.method', 'foobar'); + $container->setParameter('foo.property.name', 'bar'); + $container->setParameter('foo.property.value', 'baz'); + $container->setParameter('foo.file', 'foo.php'); + $container->setParameter('alias.id', 'bar'); + + $fooDefinition = $container->register('foo', '%foo.class%'); $fooDefinition->setFactory(['%foo.factory.class%', 'getFoo']); $fooDefinition->setArguments(['%foo.arg1%', ['%foo.arg1%' => 'baz']]); $fooDefinition->addMethodCall('%foo.method%', ['%foo.arg1%', '%foo.arg2%']); @@ -133,8 +133,8 @@ private function createContainerBuilder(): ContainerBuilder $fooDefinition->setFile('%foo.file%'); $fooDefinition->setBindings(['$baz' => '%env(BAZ)%']); - $containerBuilder->setAlias('%alias.id%', 'foo'); + $container->setAlias('%alias.id%', 'foo'); - return $containerBuilder; + return $container; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services_with_enumeration.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services_with_enumeration.php index 6499081f248d5..2261f39732130 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services_with_enumeration.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services_with_enumeration.php @@ -6,12 +6,12 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; -return function (ContainerConfigurator $containerConfigurator) { - $containerConfigurator->parameters() +return function (ContainerConfigurator $container) { + $container->parameters() ->set('unit_enum', FooUnitEnum::BAR) ->set('enum_array', [FooUnitEnum::BAR, FooUnitEnum::FOO]); - $services = $containerConfigurator->services(); + $services = $container->services(); $services->defaults()->public(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 8d5954d3846f4..44ac44a25b791 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -112,11 +112,11 @@ public function testParseFile() public function testLoadWithExternalEntitiesDisabled() { - $containerBuilder = new ContainerBuilder(); - $loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml')); + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('services2.xml'); - $this->assertGreaterThan(0, $containerBuilder->getParameterBag()->all(), 'Parameters can be read from the config file.'); + $this->assertGreaterThan(0, $container->getParameterBag()->all(), 'Parameters can be read from the config file.'); } public function testLoadParameters()