| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 26 | protected function configure() |
||
| 27 | { |
||
| 28 | $this |
||
| 29 | ->setName('cache:clear') |
||
| 30 | ->setDescription('Clears the cache') |
||
| 31 | ->setHelp(<<<EOF |
||
| 32 | The <info>%command.name%</info> command clears the application cache for a given environment |
||
| 33 | and debug mode: |
||
| 34 | |||
| 35 | <info>php %command.full_name% --env=dev</info> |
||
| 36 | <info>php %command.full_name% --env=prod --no-debug</info> |
||
| 37 | EOF |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 62 |
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: