1 | <?php |
||
13 | class Command extends BaseCommand |
||
14 | { |
||
15 | /** |
||
16 | * Configure the command options. |
||
17 | *a |
||
18 | * |
||
19 | * @return void |
||
20 | */ |
||
21 | protected function configure() |
||
27 | |||
28 | /** |
||
29 | * Execute the command. |
||
30 | * |
||
31 | * @param InputInterface $input |
||
32 | * @param OutputInterface $output |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | protected function execute(InputInterface $input, OutputInterface $output) |
||
52 | |||
53 | /** |
||
54 | * Displays the no meetups near you message. |
||
55 | * |
||
56 | * @param \LaravelMeetups\Contracts\Config $config |
||
57 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
58 | * |
||
59 | * @return $this |
||
60 | */ |
||
61 | private function noMeetupsNearYou(ConfigContract $config, OutputInterface $output) |
||
72 | } |
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: