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 | class MigrationsDiffCommand extends DiffCommand |
||
18 | { |
||
19 | protected function configure() |
||
20 | { |
||
21 | parent::configure(); |
||
22 | |||
23 | $this |
||
24 | ->setName('kuma:translator:migrations:diff') |
||
25 | ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command.') |
||
26 | ; |
||
27 | } |
||
28 | |||
29 | public function execute(InputInterface $input, OutputInterface $output) |
||
30 | { |
||
31 | DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
||
0 ignored issues
–
show
|
|||
32 | |||
33 | $configuration = $this->getMigrationConfiguration($input, $output); |
||
34 | DoctrineCommand::configureMigrations($this->getApplication()->getKernel()->getContainer(), $configuration); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
Symfony\Component\Console\Application as the method getKernel() does only exist in the following sub-classes of Symfony\Component\Console\Application : Symfony\Bundle\FrameworkBundle\Console\Application . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
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
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
Loading history...
|
|||
35 | |||
36 | parent::execute($input, $output); |
||
37 | } |
||
38 | } |
||
39 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: