| 1 | <?php |
||
| 20 | class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface |
||
| 21 | 1 | { |
|
| 22 | public function isSuccessful() |
||
| 26 | 1 | ||
| 27 | public function isRedirect() |
||
| 31 | 1 | ||
| 32 | public function getRedirectUrl() |
||
| 36 | 1 | ||
| 37 | public function getRedirectMethod() |
||
| 41 | 1 | ||
| 42 | public function getRedirectData() |
||
| 46 | } |
||
| 47 |
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: