1 | <?php |
||
28 | class ResourceProvider extends AbstractResource |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * The configuration entity -- could be a file, array or dir |
||
33 | * |
||
34 | * @var array|string |
||
35 | */ |
||
36 | private $entity; |
||
37 | |||
38 | /** |
||
39 | * If the import was not relative then the content will be stored in this array |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | private $parent_content = array(); |
||
44 | |||
45 | /** |
||
46 | * Is the import relative |
||
47 | * |
||
48 | * @var bool |
||
49 | */ |
||
50 | private $relative; |
||
51 | |||
52 | /** |
||
53 | * The parent Vars class |
||
54 | * |
||
55 | * @var \M1\Vars\Vars |
||
56 | */ |
||
57 | public $vars; |
||
58 | |||
59 | /** |
||
60 | * The ResourceProvider constructor creates the content from the entity |
||
61 | * |
||
62 | * @param \M1\Vars\Vars $vars The calling Vars class |
||
63 | * @param string|array $entity The configuration entity |
||
64 | * @param bool $relative Is the entity relative to the calling entity or class |
||
65 | * |
||
66 | * @throws \InvalidArgumentException If the entity passed is not a string or array |
||
67 | */ |
||
68 | 62 | public function __construct(Vars $vars, $entity, $relative = true) |
|
80 | |||
81 | /** |
||
82 | * Creates the content from the entity |
||
83 | * |
||
84 | * @param string|array $entity The configuration entity |
||
85 | */ |
||
86 | 61 | private function createContent($entity) |
|
114 | |||
115 | /** |
||
116 | * Creates the content from the entity |
||
117 | * |
||
118 | * @param string|array $entity The configuration entity |
||
119 | * @param string $type The type of entity |
||
120 | * |
||
121 | * @throws \InvalidArgumentException If the entity is not array|file, is readable or exists |
||
122 | * |
||
123 | * @returns array The array of resources |
||
124 | */ |
||
125 | 61 | private function processEntity($entity, $type) |
|
141 | |||
142 | /** |
||
143 | * Adds content to the parent contents |
||
144 | * |
||
145 | * @param array $content The content from the resource |
||
146 | */ |
||
147 | 49 | private function addContent($content) |
|
155 | |||
156 | /** |
||
157 | * Returns the supported files using the extensions from the loaders in the entity which is a directory |
||
158 | * |
||
159 | * @see \M1\Vars\Loader\LoaderProvider::getExtensions() \M1\Vars\Loader\LoaderProvider::getExtensions() |
||
160 | * @see \M1\Vars\Loader\LoaderProvider::makeLoaders() \M1\Vars\Loader\LoaderProvider::makeLoaders() |
||
161 | * |
||
162 | * @return array|bool Returns the supported files or false if no files were found |
||
163 | */ |
||
164 | 4 | private function getSupportedFilesInDir() |
|
199 | |||
200 | /** |
||
201 | * Merges various configuration contents into one array |
||
202 | * |
||
203 | * @param mixed $contents,... Optional number of arrays to merge |
||
204 | * |
||
205 | * @return array The merged contents |
||
206 | */ |
||
207 | 50 | private function mergeContents() |
|
212 | |||
213 | /** |
||
214 | * Adds content to the parent content array |
||
215 | * |
||
216 | * @param array $content The content to add |
||
217 | */ |
||
218 | 7 | public function addParentContent(array $content) |
|
222 | |||
223 | /** |
||
224 | * Merges the content and the parent content together |
||
225 | * |
||
226 | * @return \M1\Vars\Resource\ResourceProvider |
||
227 | */ |
||
228 | 50 | public function mergeParentContent() |
|
234 | |||
235 | /** |
||
236 | * Returns the parent content |
||
237 | * |
||
238 | * @return mixed The parent content |
||
239 | */ |
||
240 | 38 | public function getParentContent() |
|
244 | } |
||
245 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.