| 1 | <?php namespace Modules\Core\Console\Installers\Scripts; |
||
| 6 | class ModuleMigrator implements SetupScript |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | protected $modules = [ |
||
| 12 | 'Setting', |
||
| 13 | 'Menu', |
||
| 14 | 'Media', |
||
| 15 | 'Page', |
||
| 16 | 'Dashboard', |
||
| 17 | 'Translation', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Fire the install script |
||
| 22 | * @param Command $command |
||
| 23 | * @return mixed |
||
| 24 | */ |
||
| 25 | public function fire(Command $command) |
||
| 39 | } |
||
| 40 |
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: