1 | <?php |
||
14 | class VoteBuilder |
||
15 | { |
||
16 | protected $user; |
||
17 | |||
18 | protected $voteable; |
||
19 | |||
20 | protected $uniqueVoteForUsers = true; |
||
21 | |||
22 | public function __construct() |
||
32 | |||
33 | /** |
||
34 | * @param Model|int $user |
||
35 | * |
||
36 | * @return VoteBuilder |
||
37 | * |
||
38 | * @throws \Throwable |
||
39 | */ |
||
40 | public function user($user) |
||
48 | |||
49 | /** |
||
50 | * @param Model $voteable |
||
51 | * |
||
52 | * @return VoteBuilder |
||
53 | * |
||
54 | * @throws \Throwable |
||
55 | */ |
||
56 | public function voteable(Model $voteable) |
||
64 | |||
65 | /** |
||
66 | * @param bool $unique |
||
67 | * |
||
68 | * @return VoteBuilder |
||
69 | */ |
||
70 | public function uniqueVoteForUsers(bool $unique) |
||
76 | |||
77 | /** |
||
78 | * @param int $amount |
||
79 | * |
||
80 | * @return Vote |
||
81 | * |
||
82 | * @throws \Throwable |
||
83 | */ |
||
84 | public function amount(int $amount) |
||
106 | |||
107 | /** |
||
108 | * @return Vote |
||
109 | * |
||
110 | * @throws \Throwable |
||
111 | */ |
||
112 | public function voteUp() |
||
116 | |||
117 | /** |
||
118 | * @return Vote |
||
119 | * |
||
120 | * @throws \Throwable |
||
121 | */ |
||
122 | public function voteDown() |
||
126 | } |
||
127 |
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: