1 | <?php |
||
16 | trait ArgumentsAwareTrait |
||
17 | { |
||
18 | protected $arguments = []; |
||
19 | |||
20 | 20 | public function buildArguments() |
|
21 | { |
||
22 | 20 | $sourceArguments = empty($this->data['args']) ? [] : $this->data['args']; |
|
|
|||
23 | 20 | foreach ($sourceArguments as $argumentName => $argumentInfo) { |
|
24 | 11 | $this->addArgument($argumentName, $argumentInfo['type'], $argumentInfo); |
|
25 | 20 | } |
|
26 | 20 | } |
|
27 | |||
28 | 12 | public function addArgument($name, $type, $config = []) |
|
41 | |||
42 | /** |
||
43 | * @param $name |
||
44 | * |
||
45 | * @return InputField |
||
46 | */ |
||
47 | 5 | public function getArgument($name) |
|
51 | |||
52 | /** |
||
53 | * @param $name |
||
54 | * |
||
55 | * @return bool |
||
56 | */ |
||
57 | 5 | public function hasArgument($name) |
|
61 | |||
62 | /** |
||
63 | * @return InputField[] |
||
64 | */ |
||
65 | 13 | public function getArguments() |
|
69 | |||
70 | public function removeArgument($name) |
||
76 | |||
77 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: