|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
4
|
|
|
use Symfony\Component\DependencyInjection\Container; |
|
5
|
|
|
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
|
|
|
|
|
|
6
|
|
|
use Symfony\Component\DependencyInjection\Exception\LogicException; |
|
|
|
|
|
|
7
|
|
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException; |
|
|
|
|
|
|
8
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* ResolverTestReturnsAllBundlesIfNoBundleIsRequestedDebugProjectContainer. |
|
12
|
|
|
* |
|
13
|
|
|
* This class has been auto-generated |
|
14
|
|
|
* by the Symfony Dependency Injection Component. |
|
15
|
|
|
*/ |
|
16
|
|
View Code Duplication |
class ResolverTestReturnsAllBundlesIfNoBundleIsRequestedDebugProjectContainer extends Container |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
private $parameters; |
|
19
|
|
|
private $targetDirs = array(); |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Constructor. |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct() |
|
25
|
|
|
{ |
|
26
|
|
|
$dir = __DIR__; |
|
27
|
|
|
for ($i = 1; $i <= 5; ++$i) { |
|
28
|
|
|
$this->targetDirs[$i] = $dir = dirname($dir); |
|
29
|
|
|
} |
|
30
|
|
|
$this->parameters = $this->getDefaultParameters(); |
|
31
|
|
|
|
|
32
|
|
|
$this->services = array(); |
|
33
|
|
|
|
|
34
|
|
|
$this->aliases = array(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* {@inheritdoc} |
|
39
|
|
|
*/ |
|
40
|
|
|
public function compile() |
|
41
|
|
|
{ |
|
42
|
|
|
throw new LogicException('You cannot compile a dumped frozen container.'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function isFrozen() |
|
49
|
|
|
{ |
|
50
|
|
|
return true; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritdoc} |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getParameter($name) |
|
57
|
|
|
{ |
|
58
|
|
|
$name = strtolower($name); |
|
59
|
|
|
|
|
60
|
|
|
if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) { |
|
61
|
|
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $this->parameters[$name]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritdoc} |
|
69
|
|
|
*/ |
|
70
|
|
|
public function hasParameter($name) |
|
71
|
|
|
{ |
|
72
|
|
|
$name = strtolower($name); |
|
73
|
|
|
|
|
74
|
|
|
return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setParameter($name, $value) |
|
81
|
|
|
{ |
|
82
|
|
|
throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* {@inheritdoc} |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getParameterBag() |
|
89
|
|
|
{ |
|
90
|
|
|
if (null === $this->parameterBag) { |
|
91
|
|
|
$this->parameterBag = new FrozenParameterBag($this->parameters); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
return $this->parameterBag; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Gets the default parameters. |
|
99
|
|
|
* |
|
100
|
|
|
* @return array An array of the default parameters |
|
101
|
|
|
*/ |
|
102
|
|
|
protected function getDefaultParameters() |
|
103
|
|
|
{ |
|
104
|
|
|
return array( |
|
105
|
|
|
'kernel.root_dir' => $this->targetDirs[2], |
|
106
|
|
|
'kernel.environment' => 'testReturnsAllBundlesIfNoBundleIsRequested', |
|
107
|
|
|
'kernel.debug' => true, |
|
108
|
|
|
'kernel.name' => 'Resolver', |
|
109
|
|
|
'kernel.cache_dir' => __DIR__, |
|
110
|
|
|
'kernel.logs_dir' => ($this->targetDirs[2].'/logs'), |
|
111
|
|
|
'kernel.bundles' => array( |
|
112
|
|
|
'ABundle' => 'Hautelook\\AliceBundle\\Resolver\\ABundle', |
|
113
|
|
|
'BBundle' => 'Hautelook\\AliceBundle\\Resolver\\BBundle', |
|
114
|
|
|
), |
|
115
|
|
|
'kernel.charset' => 'UTF-8', |
|
116
|
|
|
'kernel.container_class' => 'ResolverTestReturnsAllBundlesIfNoBundleIsRequestedDebugProjectContainer', |
|
117
|
|
|
'database.name' => 'alice', |
|
118
|
|
|
'database.user' => 'root', |
|
119
|
|
|
'database.password' => '', |
|
120
|
|
|
); |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: