| Conditions | 1 |
| Paths | 1 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | public function getAutoloaderConfig() |
||
| 31 | { |
||
| 32 | return array( |
||
| 33 | 'Zend\Loader\ClassMapAutoloader' => array( |
||
| 34 | __DIR__ . '/autoload_classmap.php', |
||
| 35 | array( |
||
| 36 | // We need this filter for initial user creation. |
||
| 37 | 'Auth\Entity\Filter\CredentialFilter' => __DIR__ . '/../Auth/src/Auth/Entity/Filter/CredentialFilter.php', |
||
| 38 | ), |
||
| 39 | ), |
||
| 40 | 'Zend\Loader\StandardAutoloader' => array( |
||
| 41 | 'namespaces' => array( |
||
| 42 | __NAMESPACE__ => __DIR__ . '/src' /* . __NAMESPACE__*/, |
||
| 43 | __NAMESPACE__ . 'Test' => __DIR__ . '/test/' . __NAMESPACE__ . 'Test', |
||
| 44 | ), |
||
| 45 | ), |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | |||
| 66 |
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: