1 | <?php |
||
31 | class Application extends Container |
||
32 | { |
||
33 | const VERSION = 'v3.2.0'; |
||
34 | |||
35 | /** |
||
36 | * @var Application |
||
37 | */ |
||
38 | public static $app; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $path; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $name; |
||
49 | |||
50 | /** |
||
51 | * @var bool |
||
52 | */ |
||
53 | protected $booted = false; |
||
54 | |||
55 | /** |
||
56 | * AppKernel constructor. |
||
57 | * |
||
58 | * @param $path |
||
59 | */ |
||
60 | 32 | public function __construct($path) |
|
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | 32 | public function getName() |
|
78 | |||
79 | /** |
||
80 | * @return bool |
||
81 | */ |
||
82 | 1 | public function isBooted() |
|
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | 32 | public function getPath() |
|
94 | |||
95 | /** |
||
96 | * Application bootstrap. |
||
97 | */ |
||
98 | 32 | public function bootstrap() |
|
115 | |||
116 | 32 | protected function registerExceptionHandler() |
|
126 | |||
127 | /** |
||
128 | * @param ServiceProviderInterface[] $services |
||
129 | */ |
||
130 | 32 | protected function registerServicesProviders(array $services) |
|
137 | |||
138 | /** |
||
139 | * @param ServerRequestInterface $request |
||
140 | * |
||
141 | * @return Response|\Symfony\Component\HttpFoundation\Response |
||
142 | */ |
||
143 | 8 | public function handleRequest(ServerRequestInterface $request) |
|
164 | |||
165 | /** |
||
166 | * @param Response|\Symfony\Component\HttpFoundation\Response $response |
||
167 | */ |
||
168 | 2 | public function handleResponse($response) |
|
172 | |||
173 | /** |
||
174 | * @param $e |
||
175 | * |
||
176 | * @return Response |
||
177 | */ |
||
178 | 3 | public function handleException($e) |
|
205 | |||
206 | /** |
||
207 | * Started application. |
||
208 | * |
||
209 | * @return int |
||
210 | */ |
||
211 | 1 | public function run() |
|
221 | |||
222 | /** |
||
223 | * @param ServerRequestInterface $request |
||
224 | * @param ResponseInterface|\Symfony\Component\HttpFoundation\Response $response |
||
225 | * |
||
226 | * @return int |
||
227 | */ |
||
228 | 2 | public function shutdown(ServerRequestInterface $request, $response) |
|
239 | } |
||
240 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are 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.php
However, as
OtherDir/Foo.php
does 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: