1 | <?php |
||
26 | class ModuleList implements IteratorAggregate, Countable, ArrayAccess |
||
27 | { |
||
28 | /** |
||
29 | * @var RootModule |
||
30 | */ |
||
31 | private $rootModule; |
||
32 | |||
33 | /** |
||
34 | * @var Module[] |
||
35 | */ |
||
36 | private $modules = array(); |
||
37 | |||
38 | 372 | public function __construct(array $modules = array()) |
|
42 | |||
43 | /** |
||
44 | * Adds a module to the collection. |
||
45 | * |
||
46 | * @param Module $module The added module. |
||
47 | */ |
||
48 | 369 | public function add(Module $module) |
|
56 | |||
57 | /** |
||
58 | * Adds multiple modules to the collection. |
||
59 | * |
||
60 | * @param Module[] $modules The added modules. |
||
61 | */ |
||
62 | 372 | public function merge(array $modules) |
|
68 | |||
69 | /** |
||
70 | * Replaces the collection with the given modules. |
||
71 | * |
||
72 | * @param Module[] $modules The modules to set. |
||
73 | */ |
||
74 | 2 | public function replace(array $modules) |
|
79 | |||
80 | /** |
||
81 | * Removes a module from the collection. |
||
82 | * |
||
83 | * @param string $name The module name. |
||
84 | */ |
||
85 | 12 | public function remove($name) |
|
93 | |||
94 | /** |
||
95 | * Removes all modules from the collection. |
||
96 | */ |
||
97 | 3 | public function clear() |
|
105 | |||
106 | /** |
||
107 | * Returns the module with the given name. |
||
108 | * |
||
109 | * @param string $name The module name. |
||
110 | * |
||
111 | * @return Module The module with the passed name. |
||
112 | * |
||
113 | * @throws NoSuchModuleException If the module was not found. |
||
114 | */ |
||
115 | 51 | public function get($name) |
|
126 | |||
127 | /** |
||
128 | * Returns whether a module with the given name exists. |
||
129 | * |
||
130 | * @param string $name The module name. |
||
131 | * |
||
132 | * @return bool Whether a module with this name exists. |
||
133 | */ |
||
134 | 34 | public function contains($name) |
|
138 | |||
139 | /** |
||
140 | * Returns the root module. |
||
141 | * |
||
142 | * If the collection contains no root module, `null` is returned. |
||
143 | * |
||
144 | * @return RootModule|null The root module or `null` if none exists. |
||
|
|||
145 | */ |
||
146 | 270 | public function getRootModule() |
|
150 | |||
151 | /** |
||
152 | * Returns the name of the root module. |
||
153 | * |
||
154 | * If the collection contains no root module, `null` is returned. |
||
155 | * |
||
156 | * @return string|null The root module name or `null` if none exists. |
||
157 | */ |
||
158 | 2 | public function getRootModuleName() |
|
162 | |||
163 | /** |
||
164 | * Returns all installed modules. |
||
165 | * |
||
166 | * The installed modules are all modules that are not the root module. |
||
167 | * |
||
168 | * @return Module[] The installed modules indexed by their names. |
||
169 | */ |
||
170 | 6 | public function getInstalledModules() |
|
180 | |||
181 | /** |
||
182 | * Returns the names of all installed modules. |
||
183 | * |
||
184 | * The installed modules are all modules that are not the root module. |
||
185 | * |
||
186 | * @return string[] The names of the installed modules. |
||
187 | */ |
||
188 | 1 | public function getInstalledModuleNames() |
|
192 | |||
193 | /** |
||
194 | * Returns the names of all modules. |
||
195 | * |
||
196 | * @return string[] The module names. |
||
197 | */ |
||
198 | 93 | public function getModuleNames() |
|
202 | |||
203 | /** |
||
204 | * Returns the modules in the collection. |
||
205 | * |
||
206 | * @return Module[] The modules in the collection. |
||
207 | */ |
||
208 | 6 | public function toArray() |
|
212 | |||
213 | /** |
||
214 | * Returns whether the collection is empty. |
||
215 | * |
||
216 | * @return bool Returns `true` if the collection is empty and `false` |
||
217 | * otherwise. |
||
218 | */ |
||
219 | 2 | public function isEmpty() |
|
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | 268 | public function getIterator() |
|
231 | |||
232 | /** |
||
233 | * {@inheritdoc} |
||
234 | */ |
||
235 | 33 | public function count() |
|
239 | |||
240 | /** |
||
241 | * {@inheritdoc} |
||
242 | */ |
||
243 | 1 | public function offsetExists($name) |
|
247 | |||
248 | /** |
||
249 | * {@inheritdoc} |
||
250 | */ |
||
251 | 6 | public function offsetGet($name) |
|
255 | |||
256 | /** |
||
257 | * {@inheritdoc} |
||
258 | */ |
||
259 | 1 | public function offsetSet($name, $module) |
|
263 | |||
264 | /** |
||
265 | * {@inheritdoc} |
||
266 | */ |
||
267 | 1 | public function offsetUnset($name) |
|
271 | } |
||
272 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.