1 | <?php |
||
15 | class ImagemagickCropEffect extends AbstractCropEffect |
||
16 | { |
||
17 | /** |
||
18 | * @param integer $width The crop width. |
||
19 | * @param integer $height The crop height. |
||
20 | * @param integer $x The x-position (in pixel) of the crop. |
||
21 | * @param integer $y The y-position (in pixel) of the crop. |
||
22 | * @return void |
||
23 | */ |
||
24 | protected function doCrop($width, $height, $x, $y) |
||
44 | } |
||
45 |
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: