| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public static function buildDefinitionProvider(Discovery $discovery) |
||
| 26 | { |
||
| 27 | $bindings = $discovery->findBindings('definition-interop/yaml-definition-files'); |
||
| 28 | |||
| 29 | $definitionProviders = []; |
||
| 30 | |||
| 31 | foreach ($bindings as $binding) { |
||
| 32 | foreach ($binding->getResources() as $resource) { |
||
|
|
|||
| 33 | /* @var $resource FileResource */ |
||
| 34 | $definitionProviders[] = new YamlDefinitionLoader($resource->getFilesystemPath()); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return self::mergeDefinitionProviders($definitionProviders); |
||
| 39 | } |
||
| 40 | |||
| 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: