1 | <?php namespace Comodojo\Dispatcher\Events; |
||
10 | class ServiceEvent extends AbstractEvent { |
||
11 | |||
12 | private $logger; |
||
13 | |||
14 | private $request; |
||
15 | |||
16 | private $router; |
||
17 | |||
18 | private $response; |
||
19 | |||
20 | private $extra; |
||
21 | |||
22 | public function __construct( |
||
44 | |||
45 | final public function logger() { |
||
50 | |||
51 | final public function request() { |
||
56 | |||
57 | final public function router() { |
||
62 | |||
63 | final public function response() { |
||
68 | |||
69 | final public function extra() { |
||
74 | |||
75 | } |
||
76 |
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: