1 | <?php |
||
50 | class ItemObjectModel extends ItemList implements ItemObjectModelInterface |
||
51 | { |
||
52 | /** |
||
53 | * Rel declarations |
||
54 | * |
||
55 | * @var RelInterface[] |
||
56 | */ |
||
57 | protected $rels; |
||
58 | |||
59 | /** |
||
60 | * Alternate resources |
||
61 | * |
||
62 | * @var AlternateInterface[] |
||
63 | */ |
||
64 | protected $alternates; |
||
65 | |||
66 | /** |
||
67 | * ItemList constructor |
||
68 | * |
||
69 | * @param ItemInterface[] $items Items |
||
70 | * @param RelInterface[] $rels Rel declarations |
||
71 | * @param AlternateInterface[] $alternates Alternate resources |
||
72 | */ |
||
73 | 1 | public function __construct(array $items = [], array $rels = [], array $alternates = []) |
|
79 | |||
80 | /** |
||
81 | * Return all rel declarations of a particular type |
||
82 | * |
||
83 | * @param string $type Rel type |
||
84 | * @param int|null $index Optional: particular index |
||
85 | * @return RelInterface|RelInterface[] Single rel=* declaration or list of particular rel declarations |
||
86 | * @throws OutOfBoundsException If the rel type is out of bounds |
||
87 | * @throws OutOfBoundsException If the rel index is out of bounds |
||
88 | * @api |
||
89 | */ |
||
90 | public function rel($type, $index = null) |
||
111 | |||
112 | /** |
||
113 | * Return all rel=* declaration groups |
||
114 | * |
||
115 | * @return RelInterface[] Rel=* declaration groups |
||
116 | * @api |
||
117 | */ |
||
118 | public function rels() |
||
122 | |||
123 | /** |
||
124 | * Return all alternate resources |
||
125 | * |
||
126 | * @return AlternateInterface[] Alternate resources |
||
127 | * @api |
||
128 | */ |
||
129 | public function alternates() |
||
133 | |||
134 | /** |
||
135 | * Return the alternate resource of a particular type |
||
136 | * |
||
137 | * @param string $type Alternate representation type |
||
138 | * @return AlternateInterface|null Alternate resource |
||
139 | * @throws OutOfBoundsException If the alternate type is out of bounds |
||
140 | * @api |
||
141 | */ |
||
142 | public function alternate($type) |
||
153 | } |
||
154 |
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: