1 | <?php |
||
8 | class ExportList implements ExportableInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var ExportListConfiguratorInterface |
||
12 | */ |
||
13 | private $configurator; |
||
14 | |||
15 | 5 | public function __construct(ExportListConfiguratorInterface $configurator) |
|
22 | |||
23 | /** |
||
24 | * @deprecated ? This method is not configured in the configurator interface |
||
25 | */ |
||
26 | public function bindRequest(Request $request) |
||
30 | |||
31 | 1 | public function getExportColumns() |
|
35 | |||
36 | 1 | public function getIterator() |
|
40 | |||
41 | 1 | public function getStringValue($item, $columnName) |
|
45 | } |
||
46 |
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: