| 1 | <?php |
||
| 10 | * |
||
| 11 | * @author daniels |
||
| 12 | */ |
||
| 13 | class TWsatLayout extends TTemplateControl |
||
| 14 | { |
||
| 15 | |||
| 16 | public function onLoad($param) |
||
| 21 | |||
| 22 | private function validateSecurity() |
||
| 33 | |||
| 34 | public function logout() |
||
| 35 | { |
||
| 36 | $this->Session["wsat_password"] = ""; |
||
| 37 | $url = $this->Service->constructUrl('TWsatLogin'); |
||
| 38 | $this->Response->redirect($url); |
||
| 39 | } |
||
| 41 | } |
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: