| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 22 | 
| Code Lines | 16 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 1 | Features | 0 | 
| 1 | <?php  | 
            ||
| 15 | public function render(RenderInterface $renderer, QueryInterface $query, $object)  | 
            ||
| 16 |     { | 
            ||
| 17 | // Get all available groups from db  | 
            ||
| 18 | $groupSelect = array();  | 
            ||
| 19 |         foreach ($query->className('group')->cond('Active', 1)->exec() as $group) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 20 | $groupSelect[] = $group->GroupID.':'.$group->Name;  | 
            ||
| 21 | }  | 
            ||
| 22 | |||
| 23 | // Set view  | 
            ||
| 24 | return $renderer->view($this->innerView)  | 
            ||
| 25 | ->set($this->css, 'class')  | 
            ||
| 26 | ->set($object, 'item')  | 
            ||
| 27 | ->set(  | 
            ||
| 28 |                 m('samsoncms_input_application')->createFieldByType( | 
            ||
| 29 | $query,  | 
            ||
| 30 | 4,  | 
            ||
| 31 | $object,  | 
            ||
| 32 | $this->name  | 
            ||
| 33 |                 )->build(implode(',', $groupSelect)), | 
            ||
| 34 | 'field'  | 
            ||
| 35 | )->output();  | 
            ||
| 36 | }  | 
            ||
| 37 | }  | 
            
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: