| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function createDefinition(ContainerBuilder $container, array $config): Definition |
||
| 27 | { |
||
| 28 | $definition = new Definition(JWK::class); |
||
| 29 | $definition->setFactory([ |
||
| 30 | new Reference(JWKFactory::class), |
||
| 31 | 'createFromKeyFile', |
||
| 32 | ]); |
||
| 33 | $definition->setArguments([ |
||
| 34 | $config['path'], |
||
| 35 | $config['password'], |
||
| 36 | $config['additional_values'], |
||
| 37 | ]); |
||
| 38 | |||
| 39 | return $definition; |
||
| 40 | } |
||
| 41 | |||
| 68 |
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: