1 | <?php |
||
26 | class Exporter |
||
27 | { |
||
28 | /** |
||
29 | * Get PHP code string from a closure of function as string |
||
30 | * |
||
31 | * @param array<string,array|string|integer> $context current compile context |
||
32 | * @param object $closure Closure object |
||
33 | * |
||
34 | * @return string |
||
35 | * |
||
36 | * @expect 'function($a) {return;}' when input array('flags' => array('standalone' => 0)), function ($a) {return;} |
||
37 | * @expect 'function($a) {return;}' when input array('flags' => array('standalone' => 0)), function ($a) {return;} |
||
38 | */ |
||
39 | 73 | protected static function closure($context, $closure) { |
|
49 | |||
50 | /** |
||
51 | * Export required custom helper functions |
||
52 | * |
||
53 | * @param array<string,array|string|integer> $context current compile context |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 675 | public static function helpers($context) { |
|
72 | |||
73 | /** |
||
74 | * Replace SafeString class with alias class name |
||
75 | * |
||
76 | * @param array<string,array|string|integer> $context current compile context |
||
77 | * @param string $str the PHP code to be replaced |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 573 | protected static function replaceSafeString($context, $str) { |
|
84 | |||
85 | /** |
||
86 | * Get methods from ReflectionClass |
||
87 | * |
||
88 | * @param array<string,array|string|integer> $context current compile context |
||
89 | * @param object $class instance of the ReflectionClass |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | 513 | public static function getClassMethods($context, $class) { |
|
103 | |||
104 | /** |
||
105 | * Get statics code from ReflectionClass |
||
106 | * |
||
107 | * @param object $class instance of the ReflectionClass |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 336 | public static function getClassStatics($class) { |
|
120 | |||
121 | |||
122 | |||
123 | |||
124 | |||
125 | /** |
||
126 | * Get metadata from ReflectionObject |
||
127 | * |
||
128 | * @param object $refobj instance of the ReflectionObject |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | 573 | public static function getMeta($refobj) { |
|
146 | |||
147 | /** |
||
148 | * Export SafeString class as string |
||
149 | * |
||
150 | * @param array<string,array|string|integer> $context current compile context |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 336 | public static function safestring($context) { |
|
161 | |||
162 | /** |
||
163 | * Export required standalone Runtime methods |
||
164 | * |
||
165 | * @param array<string,array|string|integer> $context current compile context |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | 513 | public static function runtime($context) { |
|
197 | |||
198 | /** |
||
199 | * Export Runtime constants |
||
200 | * |
||
201 | * @param array<string,array|string|integer> $context current compile context |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | 675 | public static function constants($context) { |
|
219 | |||
220 | /** |
||
221 | * Scan for required standalone functions |
||
222 | * |
||
223 | * @param array<string,array|string|integer> $context current compile context |
||
224 | * @param string $code PHP code string of the method |
||
225 | * |
||
226 | * @return array<string|array> list of converted code and children array |
||
227 | */ |
||
228 | 513 | protected static function scanDependency($context, $code) { |
|
248 | } |
||
249 | |||
250 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.