1 | <?php |
||
44 | abstract class AbstractDefinition |
||
45 | { |
||
46 | /** |
||
47 | * List of arguments |
||
48 | * @var array<mixed> |
||
49 | */ |
||
50 | protected $arguments = array(); |
||
51 | |||
52 | /** |
||
53 | * Constructor |
||
54 | * |
||
55 | * @param mixed $arg Mixed argument |
||
56 | * @param array<mixed> $arguments List of arguments |
||
57 | * |
||
58 | * @abstract |
||
59 | * @return void |
||
|
|||
60 | */ |
||
61 | abstract public function __construct($arg, array $arguments = array()); |
||
62 | |||
63 | /** |
||
64 | * Return the list of arguments |
||
65 | * |
||
66 | * @return array<mixed> |
||
67 | */ |
||
68 | public function getArguments() |
||
72 | |||
73 | /** |
||
74 | * Adds an argument to the Definition. |
||
75 | * |
||
76 | * For a ClassDefinition these arguments are passed to the constructor. |
||
77 | * |
||
78 | * @param string|Invokable $argument The Argument |
||
79 | * |
||
80 | * @return Definition |
||
81 | */ |
||
82 | 9 | public function addArgument($argument) |
|
88 | |||
89 | /** |
||
90 | * Add multiples arguments (merge) |
||
91 | * |
||
92 | * @param array<mixed> $arguments List of new arguments |
||
93 | * |
||
94 | * @return Definition |
||
95 | */ |
||
96 | public function addArguments(array $arguments) |
||
102 | |||
103 | /** |
||
104 | * Returns all arguments (computed) |
||
105 | * |
||
106 | * @param Container $container The Di Container |
||
107 | * @param null|string $definition Name of the current definition (if any) |
||
108 | * |
||
109 | * @return array<mixed> |
||
110 | */ |
||
111 | 10 | protected function getConstructorArguments(Container $container, |
|
120 | |||
121 | /** |
||
122 | * Transform arguments to their real value if they are instance of Invokable |
||
123 | * or a @reference. |
||
124 | * |
||
125 | * @param array<mixed> $args List of arguments |
||
126 | * @param Container $container The Di Container |
||
127 | * @param null|string $definition Name of the current definition (if any) |
||
128 | * |
||
129 | * @return array<mixed> |
||
130 | * @throws Exceptions\InvalidArgument |
||
131 | */ |
||
132 | 12 | protected function propertizeArguments(array $args, Container $container, |
|
160 | |||
161 | /** |
||
162 | * Transforms a string to a type, if known: |
||
163 | * |
||
164 | * - boolean: true / false |
||
165 | * - null: null |
||
166 | * |
||
167 | * @param string $value The initial string value |
||
168 | * |
||
169 | * @return mixed |
||
170 | */ |
||
171 | 11 | protected function transformValueType($value) |
|
188 | |||
189 | /** |
||
190 | * Factory method |
||
191 | * |
||
192 | * @param mixed $arg Mixed argument |
||
193 | * @param array<mixed> $arguments List of arguments |
||
194 | * |
||
195 | * @return Definition |
||
196 | * @static |
||
197 | */ |
||
198 | 2 | public static function factory($arg, array $arguments = array()) |
|
202 | } |
||
203 |
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.