1 | <?php |
||
11 | final class Collection extends ValueObject |
||
12 | { |
||
13 | /** |
||
14 | * @var int |
||
15 | */ |
||
16 | protected $id; |
||
17 | |||
18 | /** |
||
19 | * @var \eZ\Publish\API\Repository\Values\Content\Content |
||
20 | */ |
||
21 | protected $content; |
||
22 | |||
23 | /** |
||
24 | * @var \eZ\Publish\API\Repository\Values\User\User |
||
25 | */ |
||
26 | protected $creator; |
||
27 | |||
28 | /** |
||
29 | * @var \DateTimeInterface |
||
30 | */ |
||
31 | protected $created; |
||
32 | |||
33 | /** |
||
34 | * @var \DateTimeInterface |
||
35 | */ |
||
36 | protected $modified; |
||
37 | |||
38 | /** |
||
39 | * @var \Netgen\InformationCollection\API\Value\Attribute[] |
||
40 | */ |
||
41 | protected $attributes; |
||
42 | |||
43 | public function __construct(int $id, Content $content, User $creator, DateTimeInterface $created, DateTimeInterface $modified, array $attributes) |
||
52 | |||
53 | /** |
||
54 | * @return int |
||
55 | */ |
||
56 | public function getId(): int |
||
60 | |||
61 | /** |
||
62 | * @return Content |
||
63 | */ |
||
64 | public function getContent(): Content |
||
68 | |||
69 | /** |
||
70 | * @return User |
||
71 | */ |
||
72 | public function getCreator(): User |
||
76 | |||
77 | /** |
||
78 | * @return \DateTimeInterface |
||
79 | */ |
||
80 | public function getCreated(): DateTimeInterface |
||
84 | |||
85 | /** |
||
86 | * @return \DateTimeInterface |
||
87 | */ |
||
88 | public function getModified(): DateTimeInterface |
||
92 | |||
93 | /** |
||
94 | * @return Attribute[] |
||
95 | */ |
||
96 | public function getAttributes(): array |
||
100 | } |
||
101 |
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: