1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: DIEU |
5
|
|
|
* Date: 07/02/2017 |
6
|
|
|
* Time: 00:40 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Starkerxp\StructureBundle\Command; |
10
|
|
|
|
11
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
14
|
|
|
use Symfony\Component\Yaml\Yaml; |
15
|
|
|
|
16
|
|
|
//I'm includng the yml dumper. Then : |
17
|
|
|
|
18
|
|
|
class TestCommand extends ContainerAwareCommand |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
protected function configure() |
22
|
|
|
{ |
23
|
|
|
$this->setName('test'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
28
|
|
|
{ |
29
|
|
|
$ymlDump = [ |
30
|
|
|
"services" => [ |
31
|
|
|
"starker_campagne.manager.campagne" => [ |
32
|
|
|
"class" => "Starkerxp\\CampagneBundle\\Manager\\CampagneManager", |
33
|
|
|
"arguments" => [ |
34
|
|
|
"@doctrine.orm.entity_manager", |
35
|
|
|
"Starkerxp\\CampagneBundle\\Entity\\Campagne", |
36
|
|
|
], |
37
|
|
|
"tags" => [ |
38
|
|
|
"name" => "starkerxp.manager.entity", |
39
|
|
|
], |
40
|
|
|
], |
41
|
|
|
], |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
$yaml = Yaml::dump($ymlDump, 3, 4, 3); |
46
|
|
|
$path = './test.yml'; |
47
|
|
|
file_put_contents($path, $yaml); |
48
|
|
|
|
49
|
|
|
// On récupère le contenu du fichier yml. |
50
|
|
|
$ymlDump = Yaml::parse(file_get_contents($path)); |
|
|
|
|
51
|
|
|
$ymlDump2 = [ |
|
|
|
|
52
|
|
|
"services" => [ |
53
|
|
|
"starker_campagne.manager.template" => [ |
54
|
|
|
"class" => "Starkerxp\\CampagneBundle\\Manager\\TemplateManager", |
55
|
|
|
"arguments" => [ |
56
|
|
|
"@doctrine.orm.entity_manager", |
57
|
|
|
"Starkerxp\\CampagneBundle\\Entity\\Template", |
58
|
|
|
], |
59
|
|
|
"tags" => [ |
60
|
|
|
"name" => "starkerxp.manager.entity", |
61
|
|
|
], |
62
|
|
|
], |
63
|
|
|
], |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
$path = './test.yml'; |
67
|
|
|
file_put_contents($path, $yaml); |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
} |
|
|
|
|
73
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.