1 | <?php |
||
14 | class SplitItem implements MenuItemInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $items; |
||
20 | |||
21 | /** |
||
22 | * @var int|null |
||
23 | */ |
||
24 | private $selectedItemIndex; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $canBeSelected = true; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $margin = 2; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private static $blacklistedItems = [ |
||
40 | \PhpSchool\CliMenu\MenuItem\AsciiArtItem::class, |
||
41 | \PhpSchool\CliMenu\MenuItem\LineBreakItem::class, |
||
42 | \PhpSchool\CliMenu\MenuItem\SplitItem::class, |
||
43 | ]; |
||
44 | |||
45 | public function __construct(array $items = []) |
||
51 | |||
52 | public function addMenuItem(MenuItemInterface $item) : self |
||
63 | |||
64 | public function addMenuItems(array $items) : self |
||
71 | |||
72 | public function setItems(array $items) : self |
||
78 | |||
79 | /** |
||
80 | * Select default item |
||
81 | */ |
||
82 | private function setDefaultSelectedItem() : void |
||
95 | |||
96 | /** |
||
97 | * The output text for the item |
||
98 | */ |
||
99 | public function getRows(MenuStyle $style, bool $selected = false) : array |
||
166 | |||
167 | public function setSelectedItemIndex(int $index) : void |
||
171 | |||
172 | public function getSelectedItemIndex() : ?int |
||
176 | |||
177 | public function getSelectedItem() : MenuItemInterface |
||
183 | |||
184 | public function getItems() : array |
||
188 | |||
189 | /** |
||
190 | * Can the item be selected |
||
191 | * In this case, it indicates if at least 1 item inside the SplitItem can be selected |
||
192 | */ |
||
193 | public function canSelect() : bool |
||
197 | |||
198 | /** |
||
199 | * Execute the items callable if required |
||
200 | */ |
||
201 | public function getSelectAction() : ?callable |
||
205 | |||
206 | /** |
||
207 | * Whether or not the menu item is showing the menustyle extra value |
||
208 | */ |
||
209 | public function showsItemExtra() : bool |
||
213 | |||
214 | /** |
||
215 | * Enable showing item extra |
||
216 | */ |
||
217 | public function showItemExtra() : void |
||
221 | |||
222 | /** |
||
223 | * Disable showing item extra |
||
224 | */ |
||
225 | public function hideItemExtra() : void |
||
229 | |||
230 | /** |
||
231 | * Nothing to return with SplitItem |
||
232 | */ |
||
233 | public function getText() : string |
||
237 | } |
||
238 |
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.