1 | <?php |
||
9 | class EventCopied extends AbstractEvent |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $originalEventId; |
||
15 | |||
16 | /** |
||
17 | * @var CalendarInterface|Calendar |
||
18 | */ |
||
19 | private $calendar; |
||
20 | |||
21 | /** |
||
22 | * EventCopied constructor. |
||
23 | * @param string $eventId |
||
24 | * @param string $originalEventId |
||
25 | * @param CalendarInterface $calendar |
||
26 | */ |
||
27 | public function __construct( |
||
28 | $eventId, |
||
29 | $originalEventId, |
||
30 | CalendarInterface $calendar |
||
31 | ) { |
||
32 | parent::__construct($eventId); |
||
33 | |||
34 | if (!is_string($originalEventId)) { |
||
35 | throw new \InvalidArgumentException( |
||
36 | 'Expected originalEventId to be a string, received ' . gettype($originalEventId) |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | $this->originalEventId = $originalEventId; |
||
41 | $this->calendar = $calendar; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | public function getOriginalEventId() |
||
51 | |||
52 | /** |
||
53 | * @return CalendarInterface |
||
54 | */ |
||
55 | public function getCalendar() |
||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | public function serialize() |
||
70 | |||
71 | /** |
||
72 | * @inheritdoc |
||
73 | */ |
||
74 | public static function deserialize(array $data) |
||
82 | } |
||
83 |
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: