| Conditions | 1 |
| Paths | 1 |
| Total Lines | 16 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function getNodeDefinition(NodeDefinition $node) |
||
| 49 | { |
||
| 50 | $node->children() |
||
|
|
|||
| 51 | ->arrayNode($this->name()) |
||
| 52 | ->addDefaultsIfNotSet() |
||
| 53 | ->canBeEnabled() |
||
| 54 | ->children() |
||
| 55 | ->integerNode('secret_lifetime') |
||
| 56 | ->defaultValue(60 * 60 * 24 * 14) |
||
| 57 | ->min(0) |
||
| 58 | ->info('Secret lifetime (in seconds; 0 = unlimited)') |
||
| 59 | ->end() |
||
| 60 | ->end() |
||
| 61 | ->end() |
||
| 62 | ->end(); |
||
| 63 | } |
||
| 64 | |||
| 73 |
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: