1 | <?php |
||
49 | abstract class AbstractArgsDefinition extends AbstractDefinition |
||
50 | { |
||
51 | /** |
||
52 | * List of arguments |
||
53 | * @var array<mixed> |
||
54 | */ |
||
55 | protected $arguments = array(); |
||
56 | |||
57 | /** |
||
58 | * Constructor |
||
59 | * |
||
60 | * @param mixed $arg Mixed argument |
||
61 | * @param array<mixed> $arguments List of arguments |
||
62 | * |
||
63 | * @abstract |
||
64 | * @return void |
||
|
|||
65 | */ |
||
66 | abstract public function __construct($arg, array $arguments = array()); |
||
67 | |||
68 | /** |
||
69 | * Return the list of arguments |
||
70 | * |
||
71 | * @return array<mixed> |
||
72 | */ |
||
73 | public function getArguments() |
||
77 | |||
78 | /** |
||
79 | * Adds an argument to the Definition. |
||
80 | * |
||
81 | * For a ClassDefinition these arguments are passed to the constructor. |
||
82 | * |
||
83 | * @param string|InvokableInterface $argument The Argument |
||
84 | * |
||
85 | * @return self |
||
86 | */ |
||
87 | 9 | public function addArgument($argument) |
|
93 | |||
94 | /** |
||
95 | * Add multiples arguments (merge) |
||
96 | * |
||
97 | * @param array<mixed> $arguments List of new arguments |
||
98 | * |
||
99 | * @return self |
||
100 | */ |
||
101 | public function addArguments(array $arguments) |
||
107 | |||
108 | /** |
||
109 | * Returns all arguments (computed) |
||
110 | * |
||
111 | * @param Container $container The Di Container |
||
112 | * @param null|string $definition Name of the current definition (if any) |
||
113 | * |
||
114 | * @return array<mixed> |
||
115 | */ |
||
116 | 15 | protected function getConstructorArguments(Container $container, |
|
129 | |||
130 | /** |
||
131 | * Transform arguments to their real value if they are instance of InvokableInterface |
||
132 | * or a @reference. |
||
133 | * |
||
134 | * @param array<mixed> $args List of arguments |
||
135 | * @param Container $container The Di Container |
||
136 | * @param null|string $definition Name of the current definition (if any) |
||
137 | * |
||
138 | * @return array<mixed> |
||
139 | * @throws Exceptions\InvalidArgumentException |
||
140 | */ |
||
141 | 12 | protected function propertizeArguments(array $args, Container $container, |
|
169 | |||
170 | /** |
||
171 | * Transforms a string to a type, if known: |
||
172 | * |
||
173 | * - boolean: true / false |
||
174 | * - null: null |
||
175 | * |
||
176 | * @param string $value The initial string value |
||
177 | * |
||
178 | * @return mixed |
||
179 | */ |
||
180 | 12 | protected function transformValueType($value) |
|
197 | |||
198 | /** |
||
199 | * Factory method |
||
200 | * |
||
201 | * @param mixed $arg Mixed argument |
||
202 | * @param array<mixed> $arguments List of arguments |
||
203 | * |
||
204 | * @return self |
||
205 | * @static |
||
206 | */ |
||
207 | 32 | public static function factory($arg, array $arguments = array()) |
|
211 | } |
||
212 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.