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 | 2 | 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 | /** |
||
74 | * @return string |
||
75 | */ |
||
76 | 1 | public function getUniqueId() |
|
80 | |||
81 | /** |
||
82 | * @return bool |
||
83 | */ |
||
84 | 1 | public function matches(TargetInterface $other): bool |
|
88 | |||
89 | 1 | public function checkMatches(TargetInterface $other): bool |
|
99 | |||
100 | public static function takeIds(TargetInterface $other) |
||
104 | |||
105 | public static function takeTypes(TargetInterface $other) |
||
109 | |||
110 | public function jsonSerialize() |
||
114 | } |
||
115 |
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: