1 | <?php |
||
7 | class FieldTextarea extends Abstract_\FormFieldDefault { |
||
8 | |||
9 | public function __construct($name, $title) { |
||
12 | |||
13 | /** |
||
14 | * |
||
15 | * @return \hemio\form\Abstract_\TemplateFormField |
||
16 | */ |
||
17 | public function fill() { |
||
28 | |||
29 | public function describe() { |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * @param boolean $required |
||
36 | */ |
||
37 | public function setRequired($required = true) { |
||
42 | |||
43 | } |
||
44 |
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: