| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 7 | 
| Code Lines | 5 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php | ||
| 13 | public function __construct(callable $urlGenerator, ResourceManager $resourceManager = null) | ||
| 14 |     { | ||
| 15 |         parent::__construct(new DataView(null, function ($url) { | ||
| 16 | return "<div data-details-container='1' data-details-url='$url'></div>"; | ||
| 17 | }), $resourceManager); | ||
| 18 | $this->setUrlGenerator($urlGenerator); | ||
| 19 | } | ||
| 20 | |||
| 60 | 
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: