1 | <?php |
||
25 | class ORMExecutor extends DoctrineORMExecutor implements ExecutorInterface |
||
26 | { |
||
27 | use ExecutorTrait; |
||
28 | |||
29 | /** |
||
30 | * @var LoaderInterface |
||
31 | */ |
||
32 | private $loader; |
||
33 | |||
34 | /** |
||
35 | * Construct new fixtures loader instance. |
||
36 | * |
||
37 | * @param EntityManagerInterface $manager EntityManagerInterface instance used for persistence. |
||
38 | * @param LoaderInterface $loader |
||
39 | * @param ORMPurger $purger |
||
40 | 49 | */ |
|
41 | public function __construct(EntityManagerInterface $manager, LoaderInterface $loader, ORMPurger $purger = null) |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | 48 | */ |
|
51 | public function purge() |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function execute(array $fixtures, $append = false) |
||
74 | } |
||
75 |
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: