Conditions | 3 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | protected function execute(InputInterface $input, OutputInterface $output) |
||
20 | { |
||
21 | $this->getContainer()->get('dami.verbosity')->change($output->getVerbosity()); |
||
|
|||
22 | |||
23 | $environment = $input->getOption('env'); |
||
24 | if (null !== $environment) { |
||
25 | $config = $this->getContainer()->get('connection_config'); |
||
26 | $config->changeEnvironment($environment); |
||
27 | } |
||
28 | |||
29 | $migrationDirectory = $this->getContainer()->getparameter('dami.migrations_directory'); |
||
30 | if (!file_exists($migrationDirectory)) { |
||
31 | mkdir($migrationDirectory); |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 |
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 sub-classes 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 parent class: