1 | <?php |
||
8 | class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface |
||
9 | { |
||
10 | |||
11 | 3 | public function isSuccessful() |
|
15 | |||
16 | 3 | public function isRedirect() |
|
20 | |||
21 | 3 | public function getRedirectUrl() |
|
25 | |||
26 | 3 | public function getRedirectMethod() |
|
30 | |||
31 | public function getRedirectData() |
||
35 | } |
||
36 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: