| Conditions | 3 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 31 | { |
||
| 32 | $updater = new Updater(null, false, Updater::STRATEGY_GITHUB); |
||
| 33 | $updater->getStrategy()->setPackageName('friendsofphp/pickle'); |
||
|
|
|||
| 34 | $updater->getStrategy()->setPharName(self::PHAR_NAME); |
||
| 35 | $updater->getStrategy()->setCurrentLocalVersion($this->getApplication()->getVersion()); |
||
| 36 | |||
| 37 | if ($input->getOption('unstable')) { |
||
| 38 | $updater->getStrategy()->setStability('unstable'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($updater->update() === false) { |
||
| 42 | $output->writeln('<info>Already up-to-date.</info>'); |
||
| 43 | } else { |
||
| 44 | $output->writeln('<info>' . $updater->getLocalPharFileBasename() . ' has been updated!</info>'); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 50 |
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: