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 | * @param Request $request |
||
25 | * |
||
26 | * @deprecated ? This method is not configured in the configurator interface |
||
27 | */ |
||
28 | public function bindRequest(Request $request) |
||
32 | |||
33 | 1 | public function getExportColumns() |
|
37 | |||
38 | 1 | public function getIterator() |
|
42 | |||
43 | 1 | public function getStringValue($item, $columnName) |
|
47 | } |
||
48 |
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: