1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Dontdrinkandroot\Gitki\WebBundle\Command; |
5
|
|
|
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
use Symfony\Component\Yaml\Yaml; |
9
|
|
|
|
10
|
|
|
class ConfigCheckCommand extends AbstractConfigCommand |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
protected $config; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
protected $securityConfig; |
21
|
|
|
|
22
|
|
|
protected function configure() |
23
|
|
|
{ |
24
|
|
|
$this |
25
|
|
|
->setName('gitki:config:check') |
26
|
|
|
->setDescription('Check if the configuration is valid and configure mandatory parameters'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
30
|
|
|
{ |
31
|
|
|
$rootDir = $this->getRootDir(); |
32
|
|
|
$configPath = $rootDir . '/app/config/config.yml'; |
33
|
|
|
$securityConfigPath = $rootDir . '/app/config/security.yml'; |
34
|
|
|
$this->config = Yaml::parse($configPath); |
|
|
|
|
35
|
|
|
$this->securityConfig = Yaml::parse($securityConfigPath); |
|
|
|
|
36
|
|
|
|
37
|
|
|
// $this->doConfigSteps($input, $output); |
|
|
|
|
38
|
|
|
|
39
|
|
|
// TODO: continue |
40
|
|
|
$output->writeln(Yaml::dump($this->config, 10)); |
41
|
|
|
file_put_contents($configPath, Yaml::dump($this->config, 10)); |
42
|
|
|
$output->writeln(Yaml::dump($this->securityConfig, 10)); |
43
|
|
|
file_put_contents($securityConfigPath, Yaml::dump($this->securityConfig, 10)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
// protected function doConfigSteps(InputInterface $input, OutputInterface $output) |
|
|
|
|
47
|
|
|
// { |
48
|
|
|
// $this->configureRepositoryPath($input, $output); |
49
|
|
|
// } |
50
|
|
|
// |
51
|
|
|
// protected function configureRepositoryPath($input, $output) |
52
|
|
|
// { |
53
|
|
|
// $repositoryPath = null; |
54
|
|
|
// if (isset($this->gitkiConfig['repository_path'])) { |
55
|
|
|
// $repositoryPath = $this->gitkiConfig['repository_path']; |
56
|
|
|
// } |
57
|
|
|
// |
58
|
|
|
// $questionString = 'Please specify the git repository path'; |
59
|
|
|
// if (null !== $repositoryPath) { |
60
|
|
|
// $questionString .= ' (or hit enter to use "' . $repositoryPath . '")'; |
61
|
|
|
// } |
62
|
|
|
// $questionString .= ': '; |
63
|
|
|
// $question = new Question($questionString, $repositoryPath); |
64
|
|
|
// $this->gitkiConfig['repository_path'] = $this->getQuestionHelper()->ask($input, $output, $question); |
65
|
|
|
// } |
66
|
|
|
} |
67
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.