| 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 | /** @var array */ |
||
| 25 | private $attributes = []; |
||
| 26 | /** @var string|array */ |
||
| 27 | private $roles = []; |
||
| 28 | |||
| 29 | public function __construct( |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | public function getLabel(): string |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return array |
||
| 56 | */ |
||
| 57 | public function getAttributes(): array |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return array |
||
| 64 | */ |
||
| 65 | public function getRoles(): array |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param Item $parent |
||
| 72 | * @return NavigationItem |
||
| 73 | */ |
||
| 74 | public function setParent(Item $parent): NavigationItem |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return NavigationItem |
||
| 83 | */ |
||
| 84 | public function getParent(): NavigationItem |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @param Item $item |
||
| 91 | * @return Item |
||
| 92 | */ |
||
| 93 | public function addChild(Item $item): Item |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return Item[] |
||
| 102 | */ |
||
| 103 | public function getChildren(): array |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @param Match $match |
||
| 110 | * @return Item |
||
| 111 | */ |
||
| 112 | public function addMatch(Match $match): Item |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @return Match[] |
||
| 121 | */ |
||
| 122 | public function getMatches(): array |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @return Uri |
||
| 129 | */ |
||
| 130 | abstract public function getUri(): Uri; |
||
| 131 | } |
||
| 132 |
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
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. 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.