Argument
2 years ago
Attribute
2 years ago
Exception
2 years ago
ParameterBag
3 years ago
Alias.php
4 years ago
ChildDefinition.php
4 years ago
Container.php
2 years ago
ContainerAwareInterface.php
2 years ago
ContainerAwareTrait.php
2 years ago
ContainerBuilder.php
2 years ago
ContainerInterface.php
4 years ago
Definition.php
2 years ago
EnvVarLoaderInterface.php
4 years ago
EnvVarProcessor.php
2 years ago
EnvVarProcessorInterface.php
4 years ago
ExpressionLanguage.php
2 years ago
ExpressionLanguageProvider.php
2 years ago
Parameter.php
4 years ago
Reference.php
4 years ago
ReverseContainer.php
2 years ago
ServiceLocator.php
2 years ago
TaggedContainerInterface.php
4 years ago
TypedReference.php
2 years ago
Variable.php
4 years ago
index.php
3 years ago
Alias.php
80 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\DependencyInjection; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
| 5 | class Alias |
| 6 | { |
| 7 | 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.'; |
| 8 | private $id; |
| 9 | private $public; |
| 10 | private $deprecation = []; |
| 11 | public function __construct(string $id, bool $public = \false) |
| 12 | { |
| 13 | $this->id = $id; |
| 14 | $this->public = $public; |
| 15 | } |
| 16 | public function isPublic() |
| 17 | { |
| 18 | return $this->public; |
| 19 | } |
| 20 | public function setPublic(bool $boolean) |
| 21 | { |
| 22 | $this->public = $boolean; |
| 23 | return $this; |
| 24 | } |
| 25 | public function setPrivate(bool $boolean) |
| 26 | { |
| 27 | trigger_deprecation('symfony/dependency-injection', '5.2', 'The "%s()" method is deprecated, use "setPublic()" instead.', __METHOD__); |
| 28 | return $this->setPublic(!$boolean); |
| 29 | } |
| 30 | public function isPrivate() |
| 31 | { |
| 32 | return !$this->public; |
| 33 | } |
| 34 | public function setDeprecated() |
| 35 | { |
| 36 | $args = \func_get_args(); |
| 37 | if (\func_num_args() < 3) { |
| 38 | trigger_deprecation('symfony/dependency-injection', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__); |
| 39 | $status = $args[0] ?? \true; |
| 40 | if (!$status) { |
| 41 | trigger_deprecation('symfony/dependency-injection', '5.1', 'Passing a null message to un-deprecate a node is deprecated.'); |
| 42 | } |
| 43 | $message = (string) ($args[1] ?? null); |
| 44 | $package = $version = ''; |
| 45 | } else { |
| 46 | $status = \true; |
| 47 | $package = (string) $args[0]; |
| 48 | $version = (string) $args[1]; |
| 49 | $message = (string) $args[2]; |
| 50 | } |
| 51 | if ('' !== $message) { |
| 52 | if (\preg_match('#[\\r\\n]|\\*/#', $message)) { |
| 53 | throw new InvalidArgumentException('Invalid characters found in deprecation template.'); |
| 54 | } |
| 55 | if (!\str_contains($message, '%alias_id%')) { |
| 56 | throw new InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.'); |
| 57 | } |
| 58 | } |
| 59 | $this->deprecation = $status ? ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE] : []; |
| 60 | return $this; |
| 61 | } |
| 62 | public function isDeprecated() : bool |
| 63 | { |
| 64 | return (bool) $this->deprecation; |
| 65 | } |
| 66 | public function getDeprecationMessage(string $id) : string |
| 67 | { |
| 68 | trigger_deprecation('symfony/dependency-injection', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__); |
| 69 | return $this->getDeprecation($id)['message']; |
| 70 | } |
| 71 | public function getDeprecation(string $id) : array |
| 72 | { |
| 73 | return ['package' => $this->deprecation['package'], 'version' => $this->deprecation['version'], 'message' => \str_replace('%alias_id%', $id, $this->deprecation['message'])]; |
| 74 | } |
| 75 | public function __toString() |
| 76 | { |
| 77 | return $this->id; |
| 78 | } |
| 79 | } |
| 80 |