1 | <?php |
||
18 | class TargetCollection implements TargetInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var Target[] |
||
22 | */ |
||
23 | protected $targets; |
||
24 | |||
25 | protected $ids; |
||
26 | |||
27 | protected $types; |
||
28 | |||
29 | 3 | public function __construct(array $targets) |
|
41 | |||
42 | /** |
||
43 | * @return int |
||
44 | */ |
||
45 | 1 | public function getId() |
|
46 | { |
||
47 | 1 | return $this->getTarget()->getId(); |
|
48 | } |
||
49 | |||
50 | public function getIds() |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | 1 | public function getType() |
|
59 | { |
||
60 | 1 | return $this->getTarget()->getType(); |
|
61 | } |
||
62 | |||
63 | public function getTypes() |
||
67 | |||
68 | 1 | public function getTarget() |
|
69 | { |
||
72 | |||
73 | 1 | public function getTargets() |
|
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | 1 | public function getUniqueId() |
|
85 | |||
86 | /** |
||
87 | * @return bool |
||
88 | */ |
||
89 | 1 | public function matches(TargetInterface $other): bool |
|
93 | |||
94 | 1 | public function checkMatches(TargetInterface $other): bool |
|
104 | |||
105 | public static function takeIds(TargetInterface $other) |
||
109 | |||
110 | public static function takeTypes(TargetInterface $other) |
||
114 | |||
115 | public function jsonSerialize() |
||
119 | } |
||
120 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: