Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Add service and alias deprecation message to debug:…
…container <name> output
  • Loading branch information
94noni committed Jul 21, 2022
commit 82054bc1eb8a9261344aa006fd9fbec4308ba203
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGELOG
`Symfony\Component\Serializer\Normalizer\PropertyNormalizer` autowiring aliases, type-hint against
`Symfony\Component\Serializer\Normalizer\NormalizerInterface` or implement `NormalizerAwareInterface` instead
* Add service usages list to the `debug:container` command output
* Add service and alias deprecation message to `debug:container [<name>]` output

6.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
try {
$helper->describe($io, $object, $options);

if ('txt' === $options['format'] && isset($options['id'])) {
if ($object->hasDefinition($options['id'])) {
$definition = $object->getDefinition($options['id']);
if ($definition->isDeprecated()) {
$errorIo->warning($definition->getDeprecation($options['id'])['message'] ?? sprintf('The "%s" service is deprecated.', $options['id']));
}
}
if ($object->hasAlias($options['id'])) {
$alias = $object->getAlias($options['id']);
if ($alias->isDeprecated()) {
$errorIo->warning($alias->getDeprecation($options['id'])['message'] ?? sprintf('The "%s" alias is deprecated.', $options['id']));
}
}
}

if (isset($options['id']) && isset($kernel->getContainer()->getRemovedIds()[$options['id']])) {
$errorIo->note(sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ private function getContainerDefinitionData(Definition $definition, bool $omitTa
'autoconfigure' => $definition->isAutoconfigured(),
];

if ($definition->isDeprecated()) {
$data['deprecated'] = true;
$data['deprecation_message'] = $definition->getDeprecation($id)['message'];
} else {
$data['deprecated'] = false;
}

if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$data['description'] = $classDescription;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Autoconfigured: '.($definition->isAutoconfigured() ? 'yes' : 'no')
;

if ($definition->isDeprecated()) {
$output .= "\n".'- Deprecated: yes';
$output .= "\n".'- Deprecation message: '.$definition->getDeprecation($options['id'])['message'];
} else {
$output .= "\n".'- Deprecated: no';
}

if (isset($options['show_arguments']) && $options['show_arguments']) {
$output .= "\n".'- Arguments: '.($definition->getArguments() ? 'yes' : 'no');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ private function getContainerDefinitionDocument(Definition $definition, string $
$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');
$serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false');
$serviceXML->setAttribute('autoconfigured', $definition->isAutoconfigured() ? 'true' : 'false');
if ($definition->isDeprecated()) {
$serviceXML->setAttribute('deprecated', 'true');
$serviceXML->setAttribute('deprecation_message', $definition->getDeprecation($id)['message']);
} else {
$serviceXML->setAttribute('deprecated', 'false');
}
$serviceXML->setAttribute('file', $definition->getFile() ?? '');

$calls = $definition->getMethodCalls();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures;

/**
* @deprecated
*/
class DeprecatedClass
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"abstract": true,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Abstract: yes
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
- Usages: alias_1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<alias id="alias_1" service="service_1" public="true"/>
<definition id="service_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file="">
<definition id="service_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" deprecated="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
<usages>
<usage>alias_1</usage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<alias id=".alias_2" service=".service_2" public="false"/>
<definition id=".service_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<definition id=".service_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"abstract": true,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"arguments": [
{
"type": "service",
Expand All @@ -24,6 +25,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"arguments": [
"arg1",
"arg2"
Expand All @@ -47,6 +49,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"arguments": [],
"file": null,
"tags": [],
Expand Down Expand Up @@ -83,6 +86,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"arguments": [],
"file": null,
"tags": [],
Expand All @@ -97,6 +101,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"description": "ContainerInterface is the interface implemented by service container classes.",
"arguments": [],
"file": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Definitions
- Abstract: yes
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Arguments: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Expand All @@ -29,6 +30,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Arguments: no
- Usages: none

Expand All @@ -43,6 +45,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Arguments: no
- Usages: none

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<alias id="alias_1" service="service_1" public="true"/>
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file="">
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" deprecated="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
<argument type="service" id=".definition_2"/>
<argument>%parameter%</argument>
<argument>
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="">
<argument>arg1</argument>
<argument>arg2</argument>
</definition>
Expand All @@ -15,7 +15,7 @@
<argument>foo</argument>
<argument type="service" id=".definition_2"/>
<argument>
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
<definition class="inline_service" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file=""/>
</argument>
</argument>
<argument type="iterator">
Expand All @@ -24,8 +24,8 @@
</argument>
<argument type="abstract">placeholder</argument>
</definition>
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="">
<description><![CDATA[ContainerInterface is the interface implemented by service container classes.]]></description>
</definition>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"abstract": true,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
Expand All @@ -24,6 +25,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": null,
"tags": [],
"usages": []
Expand All @@ -37,6 +39,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"description": "ContainerInterface is the interface implemented by service container classes.",
"file": null,
"tags": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Definitions
- Abstract: yes
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
- Usages: none
Expand All @@ -28,6 +29,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Usages: none

### service_container
Expand All @@ -41,6 +43,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- Usages: none


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<alias id="alias_1" service="service_1" public="true"/>
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file="">
<definition id="definition_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" deprecated="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="">
<definition id="definition_without_class" class="" public="false" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file=""/>
<definition id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="">
<description><![CDATA[ContainerInterface is the interface implemented by service container classes.]]></description>
</definition>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<alias id=".alias_2" service=".service_2" public="false"/>
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Definitions
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
Expand All @@ -28,6 +29,7 @@
"abstract": false,
"autowire": false,
"autoconfigure": false,
"deprecated": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tag1
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand All @@ -34,6 +35,7 @@ tag2
- Abstract: no
- Autowired: no
- Autoconfigured: no
- Deprecated: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<tag name="tag1">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
</calls>
</definition>
</tag>
<tag name="tag2">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" file="/path/to/file">
<definition id=".definition_2" class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" autoconfigured="false" deprecated="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
Expand Down
Loading