These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminListBundle\AdminList; |
||
4 | |||
5 | use Kunstmaan\AdminListBundle\AdminList\Configurator\ExportListConfiguratorInterface; |
||
6 | use Symfony\Component\HttpFoundation\Request; |
||
7 | |||
8 | class ExportList implements ExportableInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var ExportListConfiguratorInterface |
||
12 | */ |
||
13 | private $configurator; |
||
14 | |||
15 | 4 | public function __construct(ExportListConfiguratorInterface $configurator) |
|
16 | { |
||
17 | 4 | $this->configurator = $configurator; |
|
18 | 4 | $this->configurator->buildFilters(); |
|
19 | 4 | $this->configurator->buildExportFields(); |
|
20 | 4 | $this->configurator->buildIterator(); |
|
21 | 4 | } |
|
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) |
||
29 | { |
||
30 | $this->configurator->bindRequest($request); |
||
0 ignored issues
–
show
|
|||
31 | } |
||
32 | |||
33 | 1 | public function getExportColumns() |
|
34 | { |
||
35 | 1 | return $this->configurator->getExportFields(); |
|
36 | } |
||
37 | |||
38 | 1 | public function getIterator() |
|
39 | { |
||
40 | 1 | return $this->configurator->getIterator(); |
|
41 | } |
||
42 | |||
43 | 1 | public function getStringValue($item, $columnName) |
|
44 | { |
||
45 | 1 | return $this->configurator->getStringValue($item, $columnName); |
|
46 | } |
||
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: