1 | <?php |
||
14 | class App |
||
15 | { |
||
16 | /** |
||
17 | * Return value from application |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | private $output = ''; |
||
22 | |||
23 | /** |
||
24 | * @var Dependency $dependency |
||
25 | */ |
||
26 | private $dependency; |
||
27 | |||
28 | /** |
||
29 | * @var Emitter |
||
30 | */ |
||
31 | private $event; |
||
32 | |||
33 | /** |
||
34 | * @var Router |
||
35 | */ |
||
36 | private $router; |
||
37 | |||
38 | /** |
||
39 | * @var Request |
||
40 | */ |
||
41 | private $request; |
||
42 | |||
43 | /** |
||
44 | * Application bootstrap process |
||
45 | * |
||
46 | * The application registers the configuration in the app/config/core.php |
||
47 | * and then processes, and makes available the configured resources |
||
48 | * |
||
49 | * App constructor. |
||
50 | * @param Dependency $dependency |
||
51 | */ |
||
52 | public function __construct(Dependency $dependency) |
||
65 | |||
66 | /** |
||
67 | * Calls the proper shell for app execution |
||
68 | * |
||
69 | * @access private |
||
70 | */ |
||
71 | public function initialize() |
||
80 | |||
81 | /** |
||
82 | * @param $request array |
||
83 | * @param $request[0] string namespace to load |
||
84 | * @param $request[1] string method to call |
||
85 | * @access private |
||
86 | * @return bool |
||
87 | * @throws Exception |
||
88 | */ |
||
89 | private function processRequestParameters($request) : bool |
||
109 | |||
110 | /** |
||
111 | * @param bool $isRouteCallback |
||
112 | */ |
||
113 | private function start(bool $isRouteCallback) |
||
128 | |||
129 | /** |
||
130 | * Prepare application return value into a string |
||
131 | * |
||
132 | * @access public |
||
133 | * @return string |
||
134 | */ |
||
135 | public function __toString() |
||
139 | } |
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: