Skip to content

Commit 91e76cf

Browse files
[DependencyInjection] Ignore unused bindings defined by attribute
1 parent 8148fdd commit 91e76cf

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Symfony/Component/DependencyInjection/Compiler/RegisterAutoconfigureAttributesPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ private static function registerForAutoconfiguration(ContainerBuilder $container
8282
],
8383
],
8484
],
85-
$class->getFileName()
85+
$class->getFileName(),
86+
false
8687
);
8788
};
8889

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private function parseImports(array $content, string $file)
220220
}
221221
}
222222

223-
private function parseDefinitions(array $content, string $file)
223+
private function parseDefinitions(array $content, string $file, bool $trackBindings = true)
224224
{
225225
if (!isset($content['services'])) {
226226
return;
@@ -253,7 +253,7 @@ private function parseDefinitions(array $content, string $file)
253253
$this->isLoadingInstanceof = false;
254254
$defaults = $this->parseDefaults($content, $file);
255255
foreach ($content['services'] as $id => $service) {
256-
$this->parseDefinition($id, $service, $file, $defaults);
256+
$this->parseDefinition($id, $service, $file, $defaults, false, $trackBindings);
257257
}
258258
}
259259

@@ -342,7 +342,7 @@ private function isUsingShortSyntax(array $service): bool
342342
*
343343
* @throws InvalidArgumentException When tags are invalid
344344
*/
345-
private function parseDefinition(string $id, $service, string $file, array $defaults, bool $return = false)
345+
private function parseDefinition(string $id, $service, string $file, array $defaults, bool $return = false, bool $trackBindings = true)
346346
{
347347
if (preg_match('/^_[a-zA-Z0-9_]*$/', $id)) {
348348
throw new InvalidArgumentException(sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id));
@@ -666,7 +666,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa
666666
$bindingType = $this->isLoadingInstanceof ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING;
667667
foreach ($bindings as $argument => $value) {
668668
if (!$value instanceof BoundArgument) {
669-
$bindings[$argument] = new BoundArgument($value, true, $bindingType, $file);
669+
$bindings[$argument] = new BoundArgument($value, $trackBindings, $bindingType, $file);
670670
}
671671
}
672672
}

0 commit comments

Comments
 (0)