| 1 | <?php |
||
| 15 | class ImagemagickResizeEffect extends AbstractResizeEffect |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @param integer $width The target width. |
||
| 19 | * @param integer $height The target height. |
||
| 20 | * @param boolean $bestFit The "best_fit" flag. |
||
| 21 | * @return void |
||
| 22 | */ |
||
| 23 | protected function doResize($width, $height, $bestFit = false) |
||
| 51 | } |
||
| 52 |
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: