Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e724fbd

Browse filesBrowse files
author
Anthony MARTIN
committed
[DependencyInjection] Added information about deprecated aliases in debug:autowiring
| Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | n/a Fix and improves a bit PR #29968 and #29995
1 parent 2cad97b commit e724fbd
Copy full SHA for e724fbd

File tree

7 files changed

+22
-5
lines changed
Filter options

7 files changed

+22
-5
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CHANGELOG
1212
PHP's native `serialize()` and `unserialize()` functions. To use the
1313
original serialization method, set the `framework.messenger.serializer.id`
1414
config option to `messenger.transport.symfony_serializer`.
15+
* Added information about deprecated aliases in `debug:autowiring`
1516

1617
4.2.0
1718
-----

‎src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
104104
$serviceLine = sprintf('<fg=yellow>%s</>', $serviceId);
105105
if ($builder->hasAlias($serviceId)) {
106106
$hasAlias[$serviceId] = true;
107-
$serviceLine .= ' <fg=cyan>('.$builder->getAlias($serviceId).')</>';
107+
$serviceAlias = $builder->getAlias($serviceId);
108+
$serviceLine .= ' <fg=cyan>('.$serviceAlias.')</>';
109+
110+
if ($serviceAlias->isDeprecated()) {
111+
$serviceLine .= ' - <fg=magenta>deprecated</>';
112+
}
108113
} elseif (!$all) {
109114
continue;
110115
}

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* added `%env(trim:...)%` processor to trim a string value
88
* added `%env(default:...)%` processor to fallback to a default value
9+
* added support for deprecating aliases
910

1011
4.2.0
1112
-----

‎src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ private function addServiceAlias($alias, Alias $id, \DOMElement $parent)
227227
if (!$id->isPrivate()) {
228228
$service->setAttribute('public', $id->isPublic() ? 'true' : 'false');
229229
}
230+
231+
if ($id->isDeprecated()) {
232+
$deprecated = $this->document->createElement('deprecated');
233+
$deprecated->appendChild($this->document->createTextNode($id->getDeprecationMessage('%alias_id%')));
234+
235+
$service->appendChild($deprecated);
236+
}
237+
230238
$parent->appendChild($service);
231239
}
232240

‎src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ private function addService(string $id, Definition $definition): string
155155

156156
private function addServiceAlias(string $alias, Alias $id): string
157157
{
158+
$deprecated = $id->isDeprecated() ? sprintf(" deprecated: %s\n", $id->getDeprecationMessage('%alias_id%')) : '';
159+
158160
if ($id->isPrivate()) {
159-
return sprintf(" %s: '@%s'\n", $alias, $id);
161+
return sprintf(" %s: '@%s'\n%s", $alias, $id, $deprecated);
160162
}
161163

162-
return sprintf(" %s:\n alias: %s\n public: %s\n", $alias, $id, $id->isPublic() ? 'true' : 'false');
164+
return sprintf(" %s:\n alias: %s\n public: %s\n%s", $alias, $id, $id->isPublic() ? 'true' : 'false', $deprecated);
163165
}
164166

165167
private function addServices(): string

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ private function parseDefinition($id, $service, $file, array $defaults)
354354
}
355355

356356
if ('deprecated' === $key) {
357-
$alias->setDeprecated(true, $value);
357+
$alias->setDeprecated(true, true === $value ? null : $value);
358358
}
359359
}
360360

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/deprecated_alias_definitions.xml

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/deprecated_alias_definitions.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<service id="foo" class="Foo">
55
</service>
66
<service id="alias_for_foo" alias="foo">
7-
<deprecated />
7+
<deprecated>The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.</deprecated>
88
</service>
99
<service id="alias_for_foobar" alias="foobar">
1010
<deprecated>The "%alias_id%" service alias is deprecated.</deprecated>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.