Skip to content

Commit 1f08ed9

Browse files
committed
[DependencyInjection] Improve missing package/version deprecation
1 parent 6a6791e commit 1f08ed9

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Loader/XmlFileLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ private function parseDefinition(\DOMElement $service, string $file, Definition
205205
$version = $deprecated[0]->getAttribute('version') ?: '';
206206

207207
if (!$deprecated[0]->hasAttribute('package')) {
208-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" is deprecated.');
208+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.', $file);
209209
}
210210

211211
if (!$deprecated[0]->hasAttribute('version')) {
212-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" is deprecated.');
212+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" in "%s" is deprecated.', $file);
213213
}
214214

215215
$alias->setDeprecated($package, $version, $message);
@@ -265,11 +265,11 @@ private function parseDefinition(\DOMElement $service, string $file, Definition
265265
$version = $deprecated[0]->getAttribute('version') ?: '';
266266

267267
if ('' === $package) {
268-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" is deprecated.');
268+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.', $file);
269269
}
270270

271271
if ('' === $version) {
272-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" is deprecated.');
272+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the node "deprecated" in "%s" is deprecated.', $file);
273273
}
274274

275275
$definition->setDeprecated($package, $version, $message);

Loader/YamlFileLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,11 @@ private function parseDefinition(string $id, $service, string $file, array $defa
409409
$deprecation = \is_array($value) ? $value : ['message' => $value];
410410

411411
if (!isset($deprecation['package'])) {
412-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option is deprecated.');
412+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.', $file);
413413
}
414414

415415
if (!isset($deprecation['version'])) {
416-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option is deprecated.');
416+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.', $file);
417417
}
418418

419419
$alias->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);
@@ -478,11 +478,11 @@ private function parseDefinition(string $id, $service, string $file, array $defa
478478
$deprecation = \is_array($service['deprecated']) ? $service['deprecated'] : ['message' => $service['deprecated']];
479479

480480
if (!isset($deprecation['package'])) {
481-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option is deprecated.');
481+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.', $file);
482482
}
483483

484484
if (!isset($deprecation['version'])) {
485-
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option is deprecated.');
485+
trigger_deprecation('symfony/dependency-injection', '5.1', 'Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.', $file);
486486
}
487487

488488
$definition->setDeprecated($deprecation['package'] ?? '', $deprecation['version'] ?? '', $deprecation['message']);

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function testDeprecated()
409409
*/
410410
public function testDeprecatedWithoutPackageAndVersion()
411411
{
412-
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
412+
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.');
413413

414414
$container = new ContainerBuilder();
415415
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
@@ -442,7 +442,7 @@ public function testDeprecatedAliases()
442442
*/
443443
public function testDeprecatedAliaseWithoutPackageAndVersion()
444444
{
445-
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
445+
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" in "%s" is deprecated.');
446446

447447
$container = new ContainerBuilder();
448448
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ public function testDeprecatedAliases()
238238
*/
239239
public function testDeprecatedAliasesWithoutPackageAndVersion()
240240
{
241-
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option is deprecated.');
242-
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option is deprecated.');
241+
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option in "%s" is deprecated.');
242+
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option in "%s" is deprecated.');
243243

244244
$container = new ContainerBuilder();
245245
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));

0 commit comments

Comments
 (0)