1 | <?php |
||
18 | /** |
||
19 | * Render collection entity field inner block |
||
20 | * @param RenderInterface $renderer |
||
21 | * @param QueryInterface $query |
||
22 | * @param mixed $object Entity object instance |
||
23 | * @return string Rendered entity field |
||
24 | */ |
||
25 | public function render(RenderInterface $renderer, QueryInterface $query, $object) |
||
50 | } |
||
51 |
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: