1 | <?php |
||
13 | class Menu { |
||
14 | |||
15 | /** |
||
16 | * Menu ID. |
||
17 | * |
||
18 | * @var int |
||
19 | */ |
||
20 | public $ID; |
||
21 | |||
22 | /** |
||
23 | * Menu title. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | public $title; |
||
28 | |||
29 | /** |
||
30 | * Items. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $items; |
||
35 | |||
36 | /** |
||
37 | * Main constructor. Tries to find menu id based on provided arg (or not) and inits menu. |
||
38 | * |
||
39 | * @param string $arg It can be menu id, slug or full name. |
||
40 | */ |
||
41 | public function __construct( $arg = null ) { |
||
62 | |||
63 | /** |
||
64 | * Init menu. |
||
65 | */ |
||
66 | protected function init() { |
||
88 | |||
89 | /** |
||
90 | * Returns first menu id or false if there are no menus. |
||
91 | * |
||
92 | * @return int|bool |
||
93 | */ |
||
94 | protected function get_first_menu_id() { |
||
105 | |||
106 | /** |
||
107 | * Performs menu id lookup inside navigation Menus. |
||
108 | * |
||
109 | * @param array $locations locations that are returned by get_nav_menu_locations(). |
||
110 | * @param int|string $arg navigation id. |
||
111 | * @return int |
||
112 | */ |
||
113 | protected function get_locations_menu_id( $locations, $arg ) { |
||
124 | |||
125 | /** |
||
126 | * Checks if the provided menu id exists. |
||
127 | * |
||
128 | * @param int $menu_id Menu ID. |
||
129 | * |
||
130 | * @return int|boolean |
||
131 | */ |
||
132 | protected function check_menu_id( $menu_id ) { |
||
145 | |||
146 | /** |
||
147 | * Returns menu id by menu name/slug. |
||
148 | * |
||
149 | * @param string $slug Menu's name. |
||
150 | * |
||
151 | * @return int|bool |
||
152 | */ |
||
153 | protected function get_menu_id_by_name( $slug = null ) { |
||
166 | |||
167 | /** |
||
168 | * Returns menu name by menu id. |
||
169 | * |
||
170 | * @param string $name Menu's name. |
||
171 | * |
||
172 | * @return int|bool |
||
173 | */ |
||
174 | protected function get_menu_name_by_id( $id = null ) { |
||
185 | |||
186 | |||
187 | /** |
||
188 | * Returns menu items. |
||
189 | * |
||
190 | * @return array |
||
191 | */ |
||
192 | public function get_items() { |
||
195 | } |
||
196 |
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.