| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 24 | public function create(ContainerBuilder $container, $id, array $config) |
||
| 25 | { |
||
| 26 | $definition = new Definition('Jose\Object\JWKSet'); |
||
| 27 | $definition->setFactory([ |
||
| 28 | new Reference('jose.factory.jwkset'), |
||
| 29 | 'createFromKeys', |
||
| 30 | ]); |
||
| 31 | $definition->setArguments([ |
||
| 32 | $this->fromKeysToReferences($config['id']), |
||
| 33 | ]); |
||
| 34 | |||
| 35 | $container->setDefinition($id, $definition); |
||
| 36 | } |
||
| 37 | |||
| 76 |
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 sub-classes 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 parent class: