1 | <?php |
||
22 | class TokenRevocationEndpointSource implements Component |
||
23 | { |
||
24 | /** |
||
25 | * @return string |
||
26 | */ |
||
27 | public function name(): string |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function load(array $configs, ContainerBuilder $container) |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function getNodeDefinition(NodeDefinition $node) |
||
51 | { |
||
52 | $node->children() |
||
|
|||
53 | ->arrayNode($this->name()) |
||
54 | ->addDefaultsIfNotSet() |
||
55 | ->canBeEnabled() |
||
56 | ->children() |
||
57 | ->scalarNode('path') |
||
58 | ->info('The token revocation endpoint path') |
||
59 | ->defaultValue('/token/revocation') |
||
78 |
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: