| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | public static function buildDefinitionProvider(Discovery $discovery) |
||
| 25 | { |
||
| 26 | $bindings = $discovery->findBindings('thecodingmachine/yaml_definitions'); |
||
| 27 | |||
| 28 | $definitionProviders = []; |
||
| 29 | |||
| 30 | foreach ($bindings as $binding) { |
||
| 31 | foreach ($binding->getResources() as $resource) { |
||
|
|
|||
| 32 | $definitionProviders[] = new YamlDefinitionLoader($resource->getPath()); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | return self::mergeDefinitionProviders($definitionProviders); |
||
| 37 | } |
||
| 38 | |||
| 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: