1 | <?php |
||
10 | class Moo_EditableFieldDate extends Moo_EditableField |
||
11 | { |
||
12 | private static $singular_name = 'Date Field'; |
||
13 | private static $plural_name = 'Date Fields'; |
||
14 | protected $customSettingsFields = [ |
||
15 | 'DefaultToToday', |
||
16 | ]; |
||
17 | public function getFieldConfiguration() |
||
26 | |||
27 | public function populateFromPostData($data) |
||
37 | |||
38 | protected function initFormField() |
||
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 sub-classes 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 parent class: