1 | <?php declare(strict_types = 1); |
||
13 | class ClassGenerator extends AbstractGenerator |
||
14 | { |
||
15 | use AbstractFinalTrait; |
||
16 | |||
17 | /** OOP public visibility */ |
||
18 | const VISIBILITY_PUBLIC = 'public'; |
||
19 | |||
20 | /** OOP protected visibility */ |
||
21 | const VISIBILITY_PROTECTED = 'protected'; |
||
22 | |||
23 | /** OOP private visibility */ |
||
24 | const VISIBILITY_PRIVATE = 'private'; |
||
25 | |||
26 | /** @var string Class name */ |
||
27 | protected $className; |
||
28 | |||
29 | /** @var string Class namespace */ |
||
30 | protected $namespace; |
||
31 | |||
32 | /** @var array Collection of class uses */ |
||
33 | protected $uses = []; |
||
34 | |||
35 | /** @var string Multiline file description */ |
||
36 | protected $fileDescription; |
||
37 | |||
38 | /** @var array Class constants */ |
||
39 | protected $constants; |
||
40 | |||
41 | /** @var array Class static properties */ |
||
42 | protected $staticProperties; |
||
43 | |||
44 | /** @var array Class static methods */ |
||
45 | protected $staticMethods; |
||
46 | |||
47 | /** @var array Class properties */ |
||
48 | protected $properties; |
||
49 | |||
50 | /** @var array Class methods */ |
||
51 | protected $methods; |
||
52 | |||
53 | /** |
||
54 | * ClassGenerator constructor. |
||
55 | * |
||
56 | * @param string $className Class name |
||
57 | * @param GenericGenerator $parent Parent generator |
||
58 | */ |
||
59 | public function __construct(string $className, GenericGenerator $parent = null) |
||
65 | |||
66 | /** |
||
67 | * Set class file description. |
||
68 | * |
||
69 | * @param array $description Collection of class file description lines |
||
70 | * |
||
71 | * @return ClassGenerator |
||
72 | */ |
||
73 | public function defDescription(array $description) : ClassGenerator |
||
84 | |||
85 | /** |
||
86 | * Set class namespace. |
||
87 | * |
||
88 | * @param string $namespace |
||
89 | * |
||
90 | * @return ClassGenerator |
||
91 | */ |
||
92 | public function defNamespace(string $namespace) : ClassGenerator |
||
98 | |||
99 | /** |
||
100 | * Set class use. |
||
101 | * |
||
102 | * @param string $use |
||
103 | * |
||
104 | * @return ClassGenerator |
||
105 | */ |
||
106 | public function defUse(string $use) : ClassGenerator |
||
112 | |||
113 | /** |
||
114 | * Set protected class property. |
||
115 | * |
||
116 | * @param string $name Property name |
||
117 | * @param string $type Property type |
||
118 | * @param mixed $value Property value |
||
119 | * @param string $description Property description |
||
120 | * |
||
121 | * @return PropertyGenerator |
||
122 | */ |
||
123 | public function defProtectedProperty(string $name, string $type, $value, string $description = null) : PropertyGenerator |
||
127 | |||
128 | /** |
||
129 | * Set class property. |
||
130 | * |
||
131 | * @param string $name Property name |
||
132 | * @param string $type Property type |
||
133 | * @param mixed $value Property value |
||
134 | * @param string $description Property description |
||
135 | * |
||
136 | * @return PropertyGenerator |
||
137 | */ |
||
138 | public function defProperty(string $name, string $type, $value, string $description = null) : PropertyGenerator |
||
146 | |||
147 | /** |
||
148 | * Set protected static class property. |
||
149 | * |
||
150 | * @param string $name Property name |
||
151 | * @param string $type Property type |
||
152 | * @param mixed $value Property value |
||
153 | * @param string $description Property description |
||
154 | * |
||
155 | * @return PropertyGenerator |
||
156 | */ |
||
157 | public function defProtectedStaticProperty(string $name, string $type, $value, string $description = null) : PropertyGenerator |
||
161 | |||
162 | /** |
||
163 | * Set static class property. |
||
164 | * |
||
165 | * @param string $name Property name |
||
166 | * @param string $type Property type |
||
167 | * @param mixed $value Property value |
||
168 | * @param string $description Property description |
||
169 | * |
||
170 | * @return PropertyGenerator |
||
171 | */ |
||
172 | public function defStaticProperty(string $name, string $type, $value, string $description = null) : PropertyGenerator |
||
176 | |||
177 | /** |
||
178 | * Set protected class method. |
||
179 | * |
||
180 | * @param string $name Method name |
||
181 | * |
||
182 | * @return MethodGenerator |
||
183 | */ |
||
184 | public function defProtectedMethod(string $name) : MethodGenerator |
||
188 | |||
189 | /** |
||
190 | * Set public class method. |
||
191 | * |
||
192 | * @param string $name Method name |
||
193 | * |
||
194 | * @return MethodGenerator |
||
195 | */ |
||
196 | public function defMethod(string $name) : MethodGenerator |
||
200 | |||
201 | /** |
||
202 | * Set protected static class method. |
||
203 | * |
||
204 | * @param string $name Method name |
||
205 | * |
||
206 | * @return MethodGenerator |
||
207 | */ |
||
208 | public function defProtectedStaticMethod(string $name) : MethodGenerator |
||
212 | |||
213 | /** |
||
214 | * Set public static class method. |
||
215 | * |
||
216 | * @param string $name Method name |
||
217 | * |
||
218 | * @return MethodGenerator |
||
219 | */ |
||
220 | public function defStaticMethod(string $name) : MethodGenerator |
||
224 | |||
225 | /** |
||
226 | * {@inheritdoc} |
||
227 | * @throws \InvalidArgumentException |
||
228 | */ |
||
229 | public function code(int $indentation = 0) : string |
||
275 | |||
276 | /** |
||
277 | * Build function definition. |
||
278 | * |
||
279 | * @return string Function definition |
||
280 | */ |
||
281 | protected function buildDefinition() |
||
288 | } |
||
289 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: