Skip to content

Commit 7b1145e

Browse files
committed
minor #41933 [DependencyInjection] Turn $defaultDeprecationTemplate into a constant (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Turn $defaultDeprecationTemplate into a constant | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | symfony/symfony#41928 (comment) | License | MIT | Doc PR | N/A Commits ------- 936e399ff9 [DependencyInjection] Turn $defaultDeprecationTemplate into a constant
2 parents 7847565 + 1effa8f commit 7b1145e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Alias.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515

1616
class Alias
1717
{
18+
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
19+
1820
private $id;
1921
private $public;
2022
private $private;
2123
private $deprecated;
2224
private $deprecationTemplate;
2325

24-
private static $defaultDeprecationTemplate = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
25-
2626
public function __construct(string $id, bool $public = true)
2727
{
2828
$this->id = $id;
@@ -122,7 +122,7 @@ public function isDeprecated(): bool
122122

123123
public function getDeprecationMessage(string $id): string
124124
{
125-
return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate);
125+
return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE);
126126
}
127127

128128
/**

Definition.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
class Definition
2424
{
25+
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
26+
2527
private $class;
2628
private $file;
2729
private $factory;
@@ -47,8 +49,6 @@ class Definition
4749

4850
protected $arguments = [];
4951

50-
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
51-
5252
/**
5353
* @internal
5454
*
@@ -799,7 +799,7 @@ public function isDeprecated()
799799
*/
800800
public function getDeprecationMessage($id)
801801
{
802-
return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate);
802+
return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE);
803803
}
804804

805805
/**

0 commit comments

Comments
 (0)