1 | <?php |
||
19 | final class HydratingIterator implements Iterator |
||
20 | { |
||
21 | /** @var Generator|null */ |
||
22 | private $iterator; |
||
23 | |||
24 | /** @var UnitOfWork */ |
||
25 | private $unitOfWork; |
||
26 | |||
27 | /** @var ClassMetadata */ |
||
28 | private $class; |
||
29 | |||
30 | /** @var array */ |
||
31 | private $unitOfWorkHints; |
||
32 | |||
33 | 120 | public function __construct(Traversable $traversable, UnitOfWork $unitOfWork, ClassMetadata $class, array $unitOfWorkHints = []) |
|
40 | |||
41 | 89 | public function __destruct() |
|
45 | |||
46 | /** |
||
47 | * @see http://php.net/iterator.current |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 111 | public function current() |
|
55 | |||
56 | /** |
||
57 | * @see http://php.net/iterator.mixed |
||
58 | * |
||
59 | * @return mixed |
||
60 | */ |
||
61 | 120 | public function key() |
|
65 | |||
66 | /** |
||
67 | * @see http://php.net/iterator.next |
||
68 | */ |
||
69 | 68 | public function next() : void |
|
73 | |||
74 | /** |
||
75 | * @see http://php.net/iterator.rewind |
||
76 | */ |
||
77 | 119 | public function rewind() : void |
|
81 | |||
82 | /** |
||
83 | * @see http://php.net/iterator.valid |
||
84 | */ |
||
85 | 120 | public function valid() : bool |
|
89 | |||
90 | 120 | private function getIterator() : Generator |
|
98 | |||
99 | 111 | private function hydrate($document) |
|
103 | |||
104 | 120 | private function wrapTraversable(Traversable $traversable) : Generator |
|
110 | } |
||
111 |
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: