| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function onBootstrap(EventInterface $e) |
||
| 14 | { |
||
| 15 | /** @var ModuleManager $moduleManager */ |
||
| 16 | $moduleManager = $e->getApplication() |
||
|
|
|||
| 17 | ->getServiceManager() |
||
| 18 | ->get('ModuleManager'); |
||
| 19 | |||
| 20 | $baseModule = $moduleManager->getModule('T4webBase'); |
||
| 21 | |||
| 22 | if (!is_null($baseModule)) { |
||
| 23 | throw new RuntimeException('T4web\DomainModule has conflict with T4webBase module, |
||
| 24 | for use it you must disable T4webBase module.'); |
||
| 25 | } |
||
| 26 | |||
| 27 | } |
||
| 28 | |||
| 45 |
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: