1 | <?php |
||
14 | abstract class NavigationItem implements Item, MatchableItem |
||
15 | { |
||
16 | /** @var Match[] */ |
||
17 | private $matches = []; |
||
18 | /** @var string */ |
||
19 | private $label; |
||
20 | /** @var NavigationItem */ |
||
21 | private $parent; |
||
22 | /** @var array */ |
||
23 | private $children = []; |
||
24 | |||
25 | public function __construct(string $label, Item $parent = null, array $children = []) |
||
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getLabel(): string |
||
42 | |||
43 | /** |
||
44 | * @param Item $parent |
||
45 | * @return NavigationItem |
||
46 | */ |
||
47 | public function setParent(Item $parent): NavigationItem |
||
53 | |||
54 | /** |
||
55 | * @return NavigationItem |
||
56 | */ |
||
57 | public function getParent(): NavigationItem |
||
61 | |||
62 | /** |
||
63 | * @param Item $item |
||
64 | * @return Item |
||
65 | */ |
||
66 | public function addChild(Item $item): Item |
||
72 | |||
73 | /** |
||
74 | * @return Item[] |
||
75 | */ |
||
76 | public function getChildren(): array |
||
80 | |||
81 | /** |
||
82 | * @param Match $match |
||
83 | * @return Item |
||
84 | */ |
||
85 | public function addMatch(Match $match): Item |
||
91 | |||
92 | /** |
||
93 | * @return Match[] |
||
94 | */ |
||
95 | public function getMatches(): array |
||
99 | |||
100 | /** |
||
101 | * @return Uri |
||
102 | */ |
||
103 | abstract public function getUri(): Uri; |
||
104 | } |
||
105 |
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.