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\TranslatorBundle\Command; |
||
4 | |||
5 | use Doctrine\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper; |
||
6 | use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand; |
||
7 | use Kunstmaan\TranslatorBundle\Service\Command\DiffCommand; |
||
8 | use Symfony\Component\Console\Input\InputInterface; |
||
9 | use Symfony\Component\Console\Input\InputOption; |
||
10 | use Symfony\Component\Console\Output\OutputInterface; |
||
11 | |||
12 | /** |
||
13 | * Command for generate migration classes by checking the translation flag value |
||
14 | * |
||
15 | * @final since 5.1 |
||
16 | * |
||
17 | * @deprecated This class is deprecated since KunstmaanTranslatorBundle 5.2 and will be removed in 6.0. |
||
18 | */ |
||
19 | class MigrationsDiffCommand extends DiffCommand |
||
20 | { |
||
21 | protected function configure() |
||
22 | { |
||
23 | parent::configure(); |
||
24 | |||
25 | $this |
||
26 | ->setName('kuma:translator:migrations:diff') |
||
27 | ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command.') |
||
28 | ; |
||
29 | } |
||
30 | |||
31 | public function execute(InputInterface $input, OutputInterface $output) |
||
32 | { |
||
33 | DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
||
34 | |||
35 | $configuration = $this->getMigrationConfiguration($input, $output); |
||
36 | DoctrineCommand::configureMigrations($this->getApplication()->getKernel()->getContainer(), $configuration); |
||
0 ignored issues
–
show
|
|||
37 | |||
38 | $exitCode = parent::execute($input, $output); |
||
39 | |||
40 | return is_numeric($exitCode) ? (int) $exitCode : 0; |
||
41 | } |
||
42 | } |
||
43 |
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: