1 | <?php |
||
14 | class Notification |
||
15 | { |
||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $id; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $subject; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $body; |
||
30 | |||
31 | /** |
||
32 | * @var NotificationAttachment|Collection |
||
33 | */ |
||
34 | private $attachments; |
||
35 | |||
36 | /** |
||
37 | * @var DateTime |
||
38 | */ |
||
39 | private $recordedAt; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $recipientClass; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $recipientId; |
||
50 | |||
51 | /** |
||
52 | * @var DateTime|null |
||
53 | */ |
||
54 | private $deliveredAt; |
||
55 | |||
56 | /** |
||
57 | * @param string $subject |
||
58 | * @param string $body |
||
59 | * @param IdentifierRecipientInterface $recipient |
||
60 | */ |
||
61 | 3 | public function __construct($subject, $body, IdentifierRecipientInterface $recipient) |
|
71 | |||
72 | /** |
||
73 | * @return integer |
||
74 | */ |
||
75 | 1 | public function getId() |
|
79 | |||
80 | /** |
||
81 | * @return string |
||
82 | */ |
||
83 | 2 | public function getSubject() |
|
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | 2 | public function getBody() |
|
95 | |||
96 | /** |
||
97 | * @return NotificationAttachment[] |
||
98 | */ |
||
99 | public function getAttachments() |
||
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | 2 | public function getRecipientClass() |
|
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | 2 | public function getRecipientId() |
|
119 | |||
120 | /** |
||
121 | * @return DateTime |
||
122 | */ |
||
123 | 1 | public function getRecordedAt() |
|
127 | |||
128 | /** |
||
129 | * @return bool |
||
130 | */ |
||
131 | 1 | public function isDelivered() |
|
135 | |||
136 | /** |
||
137 | * @return DateTime|null |
||
138 | */ |
||
139 | 2 | public function getDeliveredAt() |
|
143 | |||
144 | /** |
||
145 | */ |
||
146 | 2 | public function setDelivered() |
|
154 | |||
155 | /** |
||
156 | * @param NotificationAttachment $attachment |
||
157 | */ |
||
158 | public function addNotificationAttachment(NotificationAttachment $attachment) |
||
162 | } |
||
163 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: