Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function execute(InputInterface $input, OutputInterface $output) |
||
27 | { |
||
28 | $urlToGithubPagesPharFile = 'https://typo3gmbh.github.io/elasticorn/elasticorn.phar'; |
||
29 | $urlToGithubPagesVersionFile = $urlToGithubPagesPharFile . '.version'; |
||
30 | $updater = new Updater(); |
||
31 | $updater->getStrategy()->setPharUrl($urlToGithubPagesPharFile); |
||
|
|||
32 | $updater->getStrategy()->setVersionUrl($urlToGithubPagesVersionFile); |
||
33 | $result = $updater->update(); |
||
34 | if (!$result) { |
||
35 | $output->writeln('No update necessary'); |
||
36 | } else { |
||
37 | $new = $updater->getNewVersion(); |
||
38 | $old = $updater->getOldVersion(); |
||
39 | $output->writeln( |
||
40 | sprintf( |
||
41 | 'Updated from %s to %s. To perform a rollback use ./elasticorn.phar self:rollback', |
||
42 | $old, |
||
43 | $new |
||
44 | ) |
||
45 | ); |
||
46 | } |
||
47 | } |
||
48 | } |
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: