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