1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace OSS\CoreBundle\Command;
|
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
6
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
8
|
|
|
use Symfony\Component\Console\Output\NullOutput;
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
10
|
|
|
|
11
|
|
|
class SetupCommand extends ContainerAwareCommand
|
12
|
|
|
{
|
13
|
|
|
/**
|
14
|
|
|
* @var InputInterface
|
15
|
|
|
*/
|
16
|
|
|
private $input;
|
17
|
|
|
|
18
|
|
|
/**
|
19
|
|
|
* @var OutputInterface
|
20
|
|
|
*/
|
21
|
|
|
private $output;
|
22
|
|
|
|
23
|
|
|
protected function configure()
|
24
|
|
|
{
|
25
|
|
|
$this->setName('oss:setup');
|
26
|
|
|
$this->setDescription('Sets up the game.');
|
27
|
|
|
}
|
28
|
|
|
|
29
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
30
|
|
|
{
|
31
|
|
|
$this->input = $input;
|
32
|
|
|
$this->output = $output;
|
33
|
|
|
|
34
|
|
|
$this->executeCommand('doctrine:schema:drop', 'dropping database schema', '--force');
|
35
|
|
|
$this->executeCommand('doctrine:schema:create', 'creating database schema');
|
36
|
|
|
$this->executeCommand('doctrine:fixtures:load', 'loading all fixtures');
|
37
|
|
|
$this->setUpMatchFixtures($output);
|
|
|
|
|
38
|
|
|
}
|
39
|
|
|
|
40
|
|
|
/**
|
41
|
|
|
* @param string $commandName
|
42
|
|
|
* @param string $message
|
43
|
|
|
* @param string $params
|
44
|
|
|
*
|
45
|
|
|
* @throws \Exception
|
46
|
|
|
*/
|
47
|
|
|
private function executeCommand($commandName, $message, $params = '')
|
48
|
|
|
{
|
49
|
|
|
$this->commandStart($message);
|
50
|
|
|
$command = $this->getApplication()->find($commandName);
|
51
|
|
|
$input = array('command' => $commandName);
|
52
|
|
|
if (!empty($params)) {
|
53
|
|
|
$input[$params] = true;
|
54
|
|
|
}
|
55
|
|
|
$arrayInput = new ArrayInput($input);
|
56
|
|
|
$arrayInput->setInteractive(false);
|
57
|
|
|
$command->run($arrayInput, new NullOutput());
|
58
|
|
|
$this->output->writeln('<info>OK</info>');
|
59
|
|
|
}
|
60
|
|
|
|
61
|
|
|
private function setUpMatchFixtures()
|
62
|
|
|
{
|
63
|
|
|
$this->commandStart('setting up match fixtures');
|
64
|
|
|
$this->getContainer()->get('oss.core.service.fixture')->createFixtures(1);
|
65
|
|
|
$this->output->writeln('<info>OK</info>');
|
66
|
|
|
}
|
67
|
|
|
|
68
|
|
|
/**
|
69
|
|
|
* @param string $message
|
70
|
|
|
*/
|
71
|
|
|
private function commandStart($message)
|
72
|
|
|
{
|
73
|
|
|
$this->output->write($message . substr('..................................................', 0, 50 - strlen($message)));
|
74
|
|
|
}
|
75
|
|
|
}
|
76
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.