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       | https://github.com/symfony/symfony/pull/41928#discussion_r662277447
| License       | MIT
| Doc PR        | N/A

Commits
-------

936e399ff9 [DependencyInjection] Turn $defaultDeprecationTemplate into a constant
This commit is contained in:
Fabien Potencier 2021-07-02 12:20:15 +02:00
commit 2f7bad905c
2 changed files with 6 additions and 6 deletions

View File

@ -15,14 +15,14 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
class Alias class Alias
{ {
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.';
private $id; private $id;
private $public; private $public;
private $private; private $private;
private $deprecated; private $deprecated;
private $deprecationTemplate; private $deprecationTemplate;
private static $defaultDeprecationTemplate = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
public function __construct(string $id, bool $public = true) public function __construct(string $id, bool $public = true)
{ {
$this->id = $id; $this->id = $id;
@ -122,7 +122,7 @@ class Alias
public function getDeprecationMessage(string $id): string public function getDeprecationMessage(string $id): string
{ {
return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate); return str_replace('%alias_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE);
} }
/** /**

View File

@ -22,6 +22,8 @@ use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
*/ */
class Definition class Definition
{ {
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
private $class; private $class;
private $file; private $file;
private $factory; private $factory;
@ -47,8 +49,6 @@ class Definition
protected $arguments = []; protected $arguments = [];
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
/** /**
* @internal * @internal
* *
@ -799,7 +799,7 @@ class Definition
*/ */
public function getDeprecationMessage($id) public function getDeprecationMessage($id)
{ {
return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate); return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::DEFAULT_DEPRECATION_TEMPLATE);
} }
/** /**