Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function execute(InputInterface $input, OutputInterface $output) |
||
35 | { |
||
36 | $question = new ConfirmationQuestion("Confirm to reset repository configurations? ", false); |
||
37 | $output->write(PHP_EOL); |
||
38 | if (!$this->getHelper('question')->ask($input, $output, $question)) { |
||
|
|||
39 | return; |
||
40 | } |
||
41 | Utils::getFilesystem()->copy(ConfigPath::getDefaultConfigFile(), ConfigPath::getUserConfigFile(), true); |
||
42 | |||
43 | $output->writeln("<info>Reset registry configurations success</info>"); |
||
44 | } |
||
45 | } |
||
46 |
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: