1 | <?php |
||
24 | class Menu extends \hiqdev\yii2\collection\BaseObject implements \yii\base\ViewContextInterface |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | protected $_itemClass = self::class; |
||
30 | |||
31 | public $label; |
||
32 | public $url; |
||
33 | public $icon; |
||
34 | public $active; |
||
35 | public $visible; |
||
36 | public $options = []; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $_add; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $_merge; |
||
47 | |||
48 | /** |
||
49 | * @var string parent menu |
||
50 | */ |
||
51 | public $_parent; |
||
52 | |||
53 | /** |
||
54 | * Getter for addTo. |
||
55 | * @return string add to |
||
56 | */ |
||
57 | public function getParent() |
||
61 | |||
62 | /** |
||
63 | * Adds $items to the Menu. |
||
64 | * |
||
65 | * @param array $items |
||
66 | * @see addItems() |
||
67 | */ |
||
68 | public function addMenus(array $items) |
||
81 | |||
82 | /** |
||
83 | * Merges $items to the Menu. |
||
84 | * |
||
85 | * @param array $items |
||
86 | * @see mergeItems() |
||
87 | */ |
||
88 | public function mergeMenus(array $items) |
||
95 | |||
96 | /** |
||
97 | * Returns default items defined in class. |
||
98 | * @return array |
||
99 | */ |
||
100 | public function items() |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | * Implements adding and merging. |
||
108 | */ |
||
109 | public function init() |
||
123 | |||
124 | public $widgetConfig = [ |
||
125 | 'class' => MenuWidget::class, |
||
126 | ]; |
||
127 | |||
128 | public static function widget($menuConfig = [], $widgetConfig = []) |
||
134 | |||
135 | /** |
||
136 | * Renders menu widget with given config. |
||
137 | * @param mixed $config |
||
138 | * @return string rendered menu |
||
139 | */ |
||
140 | public function run($config = []) |
||
156 | |||
157 | /** |
||
158 | * Creates menu and sets $config. |
||
159 | * @param array $config |
||
160 | * @return static |
||
161 | */ |
||
162 | public static function create(array $config = []) |
||
168 | |||
169 | /** |
||
170 | * Renders a view. |
||
171 | * @param string $view the view name |
||
172 | * @param array $params the parameters (name-value pairs) to be available in the view |
||
173 | * @return string the rendering result |
||
174 | */ |
||
175 | public function render($view, $params = []) |
||
179 | |||
180 | /** |
||
181 | * @var View the view object to be used to render views |
||
182 | */ |
||
183 | private $_view; |
||
184 | |||
185 | /** |
||
186 | * Returns the view object to be used to render views or view files. |
||
187 | * If not set, it will default to the "view" application component. |
||
188 | * @return View|\yii\web\View the view object to be used to render views |
||
189 | */ |
||
190 | public function getView() |
||
197 | |||
198 | /** |
||
199 | * Sets the view object to be used by this menu. |
||
200 | * @param View $view the view object to be used to render views |
||
201 | */ |
||
202 | public function setView($view) |
||
206 | |||
207 | /** |
||
208 | * @var string the root directory that contains view files for this menu |
||
209 | */ |
||
210 | protected $_viewPath; |
||
211 | |||
212 | /** |
||
213 | * Sets the directory that contains the view files. |
||
214 | * @param string $path the root directory of view files |
||
215 | */ |
||
216 | public function setViewPath($path) |
||
220 | |||
221 | /** |
||
222 | * Returns the directory containing view files for this menu. |
||
223 | * The default implementation returns `views/menus` in the current module. |
||
224 | * @return string the directory containing the view files for this controller |
||
225 | */ |
||
226 | public function getViewPath() |
||
234 | |||
235 | /** |
||
236 | * @return mixed |
||
237 | */ |
||
238 | public function getAdd() |
||
242 | |||
243 | /** |
||
244 | * @param mixed $add |
||
245 | */ |
||
246 | public function setAdd($add) |
||
250 | |||
251 | /** |
||
252 | * @return mixed |
||
253 | */ |
||
254 | public function getMerge() |
||
258 | |||
259 | /** |
||
260 | * @param mixed $merge |
||
261 | */ |
||
262 | public function setMerge($merge) |
||
266 | } |
||
267 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.