PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / http-kernel / ControllerMetadata / ArgumentMetadata.php
matomo / app / vendor / prefixed / symfony / http-kernel / ControllerMetadata Last commit date
ArgumentMetadata.php 1 year ago ArgumentMetadataFactory.php 2 years ago ArgumentMetadataFactoryInterface.php 2 years ago
ArgumentMetadata.php
145 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\HttpKernel\ControllerMetadata;
12
13 use Matomo\Dependencies\Symfony\Component\HttpKernel\Attribute\ArgumentInterface;
14 /**
15 * Responsible for storing metadata of an argument.
16 *
17 * @author Iltar van der Berg <kjarli@gmail.com>
18 */
19 class ArgumentMetadata
20 {
21 public const IS_INSTANCEOF = 2;
22 private $name;
23 private $type;
24 private $isVariadic;
25 private $hasDefaultValue;
26 private $defaultValue;
27 private $isNullable;
28 private $attributes;
29 /**
30 * @param object[] $attributes
31 */
32 public function __construct(string $name, ?string $type, bool $isVariadic, bool $hasDefaultValue, $defaultValue, bool $isNullable = \false, $attributes = [])
33 {
34 $this->name = $name;
35 $this->type = $type;
36 $this->isVariadic = $isVariadic;
37 $this->hasDefaultValue = $hasDefaultValue;
38 $this->defaultValue = $defaultValue;
39 $this->isNullable = $isNullable || null === $type || $hasDefaultValue && null === $defaultValue;
40 if (null === $attributes || $attributes instanceof ArgumentInterface) {
41 trigger_deprecation('symfony/http-kernel', '5.3', 'The "%s" constructor expects an array of PHP attributes as last argument, %s given.', __CLASS__, get_debug_type($attributes));
42 $attributes = $attributes ? [$attributes] : [];
43 }
44 $this->attributes = $attributes;
45 }
46 /**
47 * Returns the name as given in PHP, $foo would yield "foo".
48 *
49 * @return string
50 */
51 public function getName()
52 {
53 return $this->name;
54 }
55 /**
56 * Returns the type of the argument.
57 *
58 * The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
59 *
60 * @return string|null
61 */
62 public function getType()
63 {
64 return $this->type;
65 }
66 /**
67 * Returns whether the argument is defined as "...$variadic".
68 *
69 * @return bool
70 */
71 public function isVariadic()
72 {
73 return $this->isVariadic;
74 }
75 /**
76 * Returns whether the argument has a default value.
77 *
78 * Implies whether an argument is optional.
79 *
80 * @return bool
81 */
82 public function hasDefaultValue()
83 {
84 return $this->hasDefaultValue;
85 }
86 /**
87 * Returns whether the argument accepts null values.
88 *
89 * @return bool
90 */
91 public function isNullable()
92 {
93 return $this->isNullable;
94 }
95 /**
96 * Returns the default value of the argument.
97 *
98 * @return mixed
99 *
100 * @throws \LogicException if no default value is present; {@see self::hasDefaultValue()}
101 */
102 public function getDefaultValue()
103 {
104 if (!$this->hasDefaultValue) {
105 throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__));
106 }
107 return $this->defaultValue;
108 }
109 /**
110 * Returns the attribute (if any) that was set on the argument.
111 */
112 public function getAttribute() : ?ArgumentInterface
113 {
114 trigger_deprecation('symfony/http-kernel', '5.3', 'Method "%s()" is deprecated, use "getAttributes()" instead.', __METHOD__);
115 if (!$this->attributes) {
116 return null;
117 }
118 return $this->attributes[0] instanceof ArgumentInterface ? $this->attributes[0] : null;
119 }
120 /**
121 * @return object[]
122 */
123 public function getAttributes(?string $name = null, int $flags = 0) : array
124 {
125 if (!$name) {
126 return $this->attributes;
127 }
128 $attributes = [];
129 if ($flags & self::IS_INSTANCEOF) {
130 foreach ($this->attributes as $attribute) {
131 if ($attribute instanceof $name) {
132 $attributes[] = $attribute;
133 }
134 }
135 } else {
136 foreach ($this->attributes as $attribute) {
137 if (\get_class($attribute) === $name) {
138 $attributes[] = $attribute;
139 }
140 }
141 }
142 return $attributes;
143 }
144 }
145