1 | <?php |
||
19 | class GenericViewHelper |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Instance of view controller |
||
24 | * @var ViewController $view |
||
25 | */ |
||
26 | private $view; |
||
27 | |||
28 | /** |
||
29 | * The block name |
||
30 | * @var string $blockName |
||
31 | */ |
||
32 | private $blockName; |
||
33 | |||
34 | /** |
||
35 | * The block content |
||
36 | * @var string $blockContent |
||
37 | */ |
||
38 | private $blockContent; |
||
39 | |||
40 | /** |
||
41 | * ViewFunctions constructor. |
||
42 | * @param ViewController $view |
||
43 | */ |
||
44 | public function __construct(ViewController $view) |
||
48 | |||
49 | /** |
||
50 | * Render view |
||
51 | * @param string $template |
||
52 | * @param array $variables |
||
53 | * @return string |
||
54 | */ |
||
55 | public function render(string $template = "", array $variables = []) |
||
62 | |||
63 | /** |
||
64 | * Set parent template |
||
65 | * @param string $template |
||
66 | */ |
||
67 | public function extendsTemplate(string $template) |
||
73 | |||
74 | /** |
||
75 | * Set block |
||
76 | * @param string $name The block name |
||
77 | */ |
||
78 | public function block(string $name = "") |
||
95 | |||
96 | /** |
||
97 | * Return block contents |
||
98 | * @param string $name The block name |
||
99 | * @param string $default The default value |
||
100 | * @return string |
||
101 | */ |
||
102 | public function renderBlock(string $name, string $default = "") |
||
109 | |||
110 | /** |
||
111 | * Strip slashes from value |
||
112 | * @param string $string |
||
113 | * @return string |
||
114 | */ |
||
115 | public function escape(string $string) |
||
119 | |||
120 | /** |
||
121 | * Get assets by type |
||
122 | * @param $type |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getAssets($type) |
||
150 | |||
151 | /** |
||
152 | * Generate a CSRF token |
||
153 | * @return string |
||
154 | */ |
||
155 | public function generateCsrfToken() |
||
159 | |||
160 | /** |
||
161 | * Get form error by input field |
||
162 | * @param $field |
||
163 | * @return bool|string |
||
164 | */ |
||
165 | public function getFormError($field) |
||
185 | |||
186 | /** |
||
187 | * Check if form error exists |
||
188 | * @param $field |
||
189 | * @return boolean |
||
190 | */ |
||
191 | public function hasFormError($field) |
||
195 | |||
196 | /** |
||
197 | * Get form data for specific input field |
||
198 | * @param $key |
||
199 | * @return array|null|string |
||
200 | */ |
||
201 | public function getFormData($key) |
||
205 | |||
206 | /** |
||
207 | * @param string $name |
||
208 | * @return string |
||
209 | * @throws \Exception |
||
210 | */ |
||
211 | public function route($name) |
||
227 | |||
228 | /** |
||
229 | * Translate key |
||
230 | * @param string $string The key which holds the translated value |
||
231 | * @param array $value The variable content for the placeholder |
||
232 | * @return string |
||
233 | */ |
||
234 | public function translate($string, $value = []) |
||
239 | |||
240 | } |
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.