| 1 | <?php |
||
| 31 | class RegistryManager extends BaseManager implements ManagerInterface |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * |
||
| 35 | * @access public |
||
| 36 | * @return \CCDNForum\ForumBundle\Entity\Registry |
||
| 37 | */ |
||
| 38 | public function createRegistry() |
||
| 42 | |||
| 43 | /** |
||
| 44 | * |
||
| 45 | * @access public |
||
| 46 | * @param \CCDNForum\ForumBundle\Entity\Registry $registry |
||
| 47 | * @return \CCDNForum\ForumBundle\Model\Component\Manager\RegistryManager |
||
| 48 | */ |
||
| 49 | public function saveRegistry(Registry $registry) |
||
| 55 | } |
||
| 56 |
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: