RunSqlDoctrineCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 20 2
A execute() 0 6 1
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
4
5
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Execute a SQL query and output the results.
12
 */
13
class RunSqlDoctrineCommand extends RunSqlCommand
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    protected function configure()
19
    {
20
        parent::configure();
21
22
        $this
23
            ->setName('doctrine:query:sql')
24
            ->setHelp(<<<EOT
25
The <info>%command.name%</info> command executes the given SQL query and
26
outputs the results:
27
28
<info>php %command.full_name% "SELECT * FROM users"</info>
29
EOT
30
        );
31
32
        if ($this->getDefinition()->hasOption('connection')) {
33
            return;
34
        }
35
36
        $this->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command');
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
0 ignored issues
show
Documentation introduced by
$this->getApplication() is of type null|object<Symfony\Comp...nt\Console\Application>, but the function expects a object<Symfony\Bundle\Fr...le\Console\Application>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
46
        return parent::execute($input, $output);
47
    }
48
}
49