1 | <?php |
||
22 | final class ProxyFactory implements PromiseFactoryInterface, SingletonInterface |
||
23 | { |
||
24 | /** @var Printer */ |
||
25 | private $printer; |
||
26 | |||
27 | /** @var MaterializerInterface */ |
||
28 | private $materializer; |
||
29 | |||
30 | /** @var Names */ |
||
31 | private $names; |
||
32 | |||
33 | /** @var Instantiator */ |
||
34 | private $instantiator; |
||
35 | |||
36 | /** @var Extractor */ |
||
37 | private $extractor; |
||
38 | |||
39 | /** @var array */ |
||
40 | private $resolved = []; |
||
41 | |||
42 | /** |
||
43 | * @param Printer|null $printer |
||
44 | * @param MaterializerInterface|null $materializer |
||
45 | * @param Names|null $names |
||
46 | * @param Instantiator|null $instantiator |
||
47 | * @param Extractor|null $extractor |
||
48 | */ |
||
49 | public function __construct( |
||
62 | |||
63 | /** |
||
64 | * @param ORMInterface $orm |
||
65 | * @param string $role |
||
66 | * @param array $scope |
||
67 | * @return PromiseInterface |
||
68 | * |
||
69 | * @throws ProxyFactoryException |
||
70 | * @throws \Doctrine\Instantiator\Exception\ExceptionInterface |
||
71 | */ |
||
72 | public function promise(ORMInterface $orm, string $role, array $scope): PromiseInterface |
||
104 | |||
105 | /** |
||
106 | * @param \ReflectionClass $reflection |
||
107 | * @param string $className |
||
108 | * @param ORMInterface $orm |
||
109 | * @param string $role |
||
110 | * @param array $scope |
||
111 | * @return PromiseInterface |
||
112 | * |
||
113 | * @throws \Doctrine\Instantiator\Exception\ExceptionInterface |
||
114 | */ |
||
115 | private function instantiate( |
||
130 | } |
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: