Conditions | 2 |
Paths | 2 |
Total Lines | 9 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | protected function execute(InputInterface $input, OutputInterface $output) |
||
21 | { |
||
22 | /** @var Container $container */ |
||
23 | $container = $this->getHelper('container')->getContainer(); |
||
|
|||
24 | foreach (array_keys($container->findByTag(ProxyExtension::TAG_LAZY)) as $name) { |
||
25 | $container->getService($name); |
||
26 | $output->writeln(sprintf('Proxy for service %s generated', $name)); |
||
27 | } |
||
28 | } |
||
29 | } |
||
30 |
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: