[DependencyInjection] Improve missing package/version deprecation
This commit is contained in:
parent
2af156d6fe
commit
f603317363
@ -205,11 +205,11 @@ class XmlFileLoader extends FileLoader
|
|||||||
$version = $deprecated[0]->getAttribute('version') ?: '';
|
$version = $deprecated[0]->getAttribute('version') ?: '';
|
||||||
|
|
||||||
if (!$deprecated[0]->hasAttribute('package')) {
|
if (!$deprecated[0]->hasAttribute('package')) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$deprecated[0]->hasAttribute('version')) {
|
if (!$deprecated[0]->hasAttribute('version')) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$alias->setDeprecated($package, $version, $message);
|
$alias->setDeprecated($package, $version, $message);
|
||||||
@ -265,11 +265,11 @@ class XmlFileLoader extends FileLoader
|
|||||||
$version = $deprecated[0]->getAttribute('version') ?: '';
|
$version = $deprecated[0]->getAttribute('version') ?: '';
|
||||||
|
|
||||||
if ('' === $package) {
|
if ('' === $package) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('' === $version) {
|
if ('' === $version) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition->setDeprecated($package, $version, $message);
|
$definition->setDeprecated($package, $version, $message);
|
||||||
|
@ -409,11 +409,11 @@ class YamlFileLoader extends FileLoader
|
|||||||
$deprecation = \is_array($value) ? $value : ['message' => $value];
|
$deprecation = \is_array($value) ? $value : ['message' => $value];
|
||||||
|
|
||||||
if (!isset($deprecation['package'])) {
|
if (!isset($deprecation['package'])) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($deprecation['version'])) {
|
if (!isset($deprecation['version'])) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$alias->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);
|
$alias->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);
|
||||||
@ -478,11 +478,11 @@ class YamlFileLoader extends FileLoader
|
|||||||
$deprecation = \is_array($service['deprecated']) ? $service['deprecated'] : ['message' => $service['deprecated']];
|
$deprecation = \is_array($service['deprecated']) ? $service['deprecated'] : ['message' => $service['deprecated']];
|
||||||
|
|
||||||
if (!isset($deprecation['package'])) {
|
if (!isset($deprecation['package'])) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($deprecation['version'])) {
|
if (!isset($deprecation['version'])) {
|
||||||
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option is deprecated.');
|
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.', $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);
|
$definition->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);
|
||||||
|
@ -409,7 +409,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecatedWithoutPackageAndVersion()
|
public function testDeprecatedWithoutPackageAndVersion()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.');
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||||
@ -442,7 +442,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecatedAliaseWithoutPackageAndVersion()
|
public function testDeprecatedAliaseWithoutPackageAndVersion()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.');
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||||
|
@ -238,8 +238,8 @@ class YamlFileLoaderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeprecatedAliasesWithoutPackageAndVersion()
|
public function testDeprecatedAliasesWithoutPackageAndVersion()
|
||||||
{
|
{
|
||||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option is deprecated.');
|
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.');
|
||||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option is deprecated.');
|
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.');
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||||
|
Reference in New Issue
Block a user