Skip to content

Commit a59343c

Browse files
minor symfony#57814 [Cache][Config][Console][DependencyInjection][FrameworkBundle] Remove unused code and useless casts (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [Cache][Config][Console][DependencyInjection][FrameworkBundle] Remove unused code and useless casts | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Commits ------- 24d7bc4 [Cache][Config][Console][DependencyInjection][FrameworkBundle] Remove dead code and useless casts
2 parents e15c5ac + 24d7bc4 commit a59343c

File tree

16 files changed

+35
-52
lines changed

16 files changed

+35
-52
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
5858
*/
5959
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
6060
{
61-
return (array) $phpArrayAdapter->warmUp($values);
61+
return $phpArrayAdapter->warmUp($values);
6262
}
6363

6464
/**

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function describeContainerService(object $service, array $options = []
6464

6565
protected function describeContainerServices(ContainerBuilder $container, array $options = []): void
6666
{
67-
$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));
67+
$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));
6868
}
6969

7070
protected function describeContainerDefinition(Definition $definition, array $options = [], ?ContainerBuilder $container = null): void
@@ -288,7 +288,7 @@ private function getContainerServiceDocument(object $service, string $id, ?Conta
288288
return $dom;
289289
}
290290

291-
private function getContainerServicesDocument(ContainerBuilder $container, ?string $tag = null, bool $showHidden = false, bool $showArguments = false, ?callable $filter = null, ?string $id = null): \DOMDocument
291+
private function getContainerServicesDocument(ContainerBuilder $container, ?string $tag = null, bool $showHidden = false, bool $showArguments = false, ?callable $filter = null): \DOMDocument
292292
{
293293
$dom = new \DOMDocument('1.0', 'UTF-8');
294294
$dom->appendChild($containerXML = $dom->createElement('container'));

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function load(array $configs, ContainerBuilder $container): void
498498
if (!$messengerEnabled) {
499499
throw new LogicException('Scheduler support cannot be enabled as the Messenger component is not '.(interface_exists(MessageBusInterface::class) ? 'enabled.' : 'installed. Try running "composer require symfony/messenger".'));
500500
}
501-
$this->registerSchedulerConfiguration($config['scheduler'], $container, $loader);
501+
$this->registerSchedulerConfiguration($container, $loader);
502502
} else {
503503
$container->removeDefinition('cache.scheduler');
504504
$container->removeDefinition('console.command.scheduler_debug');
@@ -570,7 +570,7 @@ public function load(array $configs, ContainerBuilder $container): void
570570
}
571571

572572
if ($this->readConfigEnabled('remote-event', $container, $config['remote-event'])) {
573-
$this->registerRemoteEventConfiguration($config['remote-event'], $container, $loader);
573+
$this->registerRemoteEventConfiguration($loader);
574574
}
575575

576576
if ($this->readConfigEnabled('html_sanitizer', $container, $config['html_sanitizer'])) {
@@ -2073,7 +2073,7 @@ private function registerSemaphoreConfiguration(array $config, ContainerBuilder
20732073
}
20742074
}
20752075

2076-
private function registerSchedulerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
2076+
private function registerSchedulerConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void
20772077
{
20782078
if (!class_exists(SchedulerTransportFactory::class)) {
20792079
throw new LogicException('Scheduler support cannot be enabled as the Scheduler component is not installed. Try running "composer require symfony/scheduler".');
@@ -2940,7 +2940,7 @@ private function registerWebhookConfiguration(array $config, ContainerBuilder $c
29402940
$controller->replaceArgument(1, new Reference($config['message_bus']));
29412941
}
29422942

2943-
private function registerRemoteEventConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
2943+
private function registerRemoteEventConfiguration(PhpFileLoader $loader): void
29442944
{
29452945
if (!class_exists(RemoteEvent::class)) {
29462946
throw new LogicException('RemoteEvent support cannot be enabled as the component is not installed. Try running "composer require symfony/remote-event".');

src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function commit(): bool
186186
$e = $this->doSave($values, $lifetime, $addTagData, $removeTagData);
187187
} catch (\Exception $e) {
188188
}
189-
if (true === $e || [] === $e) {
189+
if ([] === $e) {
190190
continue;
191191
}
192192
if (\is_array($e) || 1 === \count($values)) {
@@ -213,7 +213,7 @@ public function commit(): bool
213213
$e = $this->doSave($values, $lifetime, $addTagData, $removeTagData);
214214
} catch (\Exception $e) {
215215
}
216-
if (true === $e || [] === $e) {
216+
if ([] === $e) {
217217
continue;
218218
}
219219
$ok = false;

src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ private function writeArray(array $array, int $depth, bool $asComment = false):
193193
} else {
194194
$val = $value;
195195
}
196-
$prefix = $asComment ? '# ' : '';
197196

198197
$prefix = $asComment ? '# ' : '';
199198

src/Symfony/Component/Config/Definition/PrototypedArrayNode.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,8 @@ protected function normalizeValue(mixed $value): mixed
217217
$valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
218218
$valuePrototype->parent = $this;
219219
$originalClosures = $this->prototype->normalizationClosures;
220-
if (\is_array($originalClosures)) {
221-
$valuePrototypeClosures = $valuePrototype->normalizationClosures;
222-
$valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
223-
}
220+
$valuePrototypeClosures = $valuePrototype->normalizationClosures;
221+
$valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
224222
$this->valuePrototypes[$k] = $valuePrototype;
225223
}
226224
}

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function parse(string $content, string|callable|null $schemaOrCall
8080
$valid = false;
8181
}
8282
} elseif (is_file($schemaOrCallable)) {
83-
$schemaSource = (new Filesystem())->readFile((string) $schemaOrCallable);
83+
$schemaSource = (new Filesystem())->readFile($schemaOrCallable);
8484
$valid = @$dom->schemaValidateSource($schemaSource);
8585
} else {
8686
libxml_use_internal_errors($internalErrors);
@@ -156,7 +156,7 @@ public static function loadFile(string $file, string|callable|null $schemaOrCall
156156
*/
157157
public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = true): mixed
158158
{
159-
$prefix = (string) $element->prefix;
159+
$prefix = $element->prefix;
160160
$empty = true;
161161
$config = [];
162162
foreach ($element->attributes as $name => $node) {
@@ -174,7 +174,7 @@ public static function convertDomElementToArray(\DOMElement $element, bool $chec
174174
$nodeValue = trim($node->nodeValue);
175175
$empty = false;
176176
}
177-
} elseif ($checkPrefix && $prefix != (string) $node->prefix) {
177+
} elseif ($checkPrefix && $prefix != $node->prefix) {
178178
continue;
179179
} elseif (!$node instanceof \DOMComment) {
180180
$value = static::convertDomElementToArray($node, $checkPrefix);

src/Symfony/Component/Console/Command/CompleteCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9898
'',
9999
'<comment>'.date('Y-m-d H:i:s').'</>',
100100
'<info>Input:</> <comment>("|" indicates the cursor position)</>',
101-
' '.(string) $completionInput,
101+
' '.$completionInput,
102102
'<info>Command:</>',
103-
' '.(string) implode(' ', $_SERVER['argv']),
103+
' '.implode(' ', $_SERVER['argv']),
104104
'<info>Messages:</>',
105105
]);
106106

107-
$command = $this->findCommand($completionInput, $output);
107+
$command = $this->findCommand($completionInput);
108108
if (null === $command) {
109109
$this->log(' No command found, completing using the Application class.');
110110

@@ -185,7 +185,7 @@ private function createCompletionInput(InputInterface $input): CompletionInput
185185
return $completionInput;
186186
}
187187

188-
private function findCommand(CompletionInput $completionInput, OutputInterface $output): ?Command
188+
private function findCommand(CompletionInput $completionInput): ?Command
189189
{
190190
try {
191191
$inputName = $completionInput->getFirstArgument();

src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function describeInputOption(InputOption $option, array $options = [])
9292
protected function describeInputDefinition(InputDefinition $definition, array $options = []): void
9393
{
9494
if ($showArguments = ((bool) $definition->getArguments())) {
95-
$this->write("Arguments\n".str_repeat($this->subsubsectionChar, 9))."\n\n";
95+
$this->write("Arguments\n".str_repeat($this->subsubsectionChar, 9));
9696
foreach ($definition->getArguments() as $argument) {
9797
$this->write("\n\n");
9898
$this->describeInputArgument($argument);

src/Symfony/Component/Console/Descriptor/XmlDescriptor.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,9 @@ private function getInputOptionDocument(InputOption $option): \DOMDocument
208208
$defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? [var_export($option->getDefault(), true)] : ($option->getDefault() ? [$option->getDefault()] : []));
209209
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
210210

211-
if ($defaults) {
212-
foreach ($defaults as $default) {
213-
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
214-
$defaultXML->appendChild($dom->createTextNode($default));
215-
}
211+
foreach ($defaults as $default) {
212+
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
213+
$defaultXML->appendChild($dom->createTextNode($default));
216214
}
217215
}
218216

0 commit comments

Comments
 (0)