1 | <?php namespace Modules\Core\Console\Installers\Scripts; |
||
7 | class ConfigureUserProvider implements SetupScript |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $drivers = [ |
||
13 | 'Sentinel', |
||
14 | ]; |
||
15 | |||
16 | /** |
||
17 | * @var |
||
18 | */ |
||
19 | private $application; |
||
20 | |||
21 | /** |
||
22 | * @param Application $application |
||
23 | */ |
||
24 | public function __construct(Application $application) |
||
28 | |||
29 | /** |
||
30 | * Fire the install script |
||
31 | * @param Command $command |
||
32 | * @return mixed |
||
33 | */ |
||
34 | public function fire(Command $command) |
||
40 | |||
41 | /** |
||
42 | * @param $driver |
||
43 | * @param $command |
||
44 | * @return mixed |
||
45 | */ |
||
46 | protected function configure($driver, $command) |
||
52 | |||
53 | /** |
||
54 | * @param $driver |
||
55 | * @return mixed |
||
56 | */ |
||
57 | protected function factory($driver) |
||
63 | } |
||
64 |
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: