1 | <?php |
||
9 | class CleanuPTestDatabasesTask extends BuildTask { |
||
10 | protected $title = 'Deletes all temporary test databases'; |
||
11 | |||
12 | protected $description = 'Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)'; |
||
13 | |||
14 | public function init() { |
||
21 | |||
22 | public function run() { |
||
25 | |||
26 | } |
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: