1 | <?php |
||
15 | class YamlDefinitionLoaderFactory implements DefinitionProviderFactoryInterface |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * Creates a definition provider. |
||
20 | * |
||
21 | * @param Discovery $discovery |
||
22 | * |
||
23 | * @return DefinitionProviderInterface |
||
24 | */ |
||
25 | public static function buildDefinitionProvider(Discovery $discovery) |
||
40 | |||
41 | /** |
||
42 | * @param DefinitionProviderInterface[] $definitionProviders |
||
43 | */ |
||
44 | private static function mergeDefinitionProviders(array $definitionProviders) { |
||
51 | } |
||
52 |
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: