1 | <?php |
||
29 | class ResourceProvider extends AbstractResource |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * The configuration entity -- could be a file, array or dir |
||
34 | * |
||
35 | * @var array|string |
||
36 | */ |
||
37 | private $entity; |
||
38 | |||
39 | /** |
||
40 | * If the import was not relative then the content will be stored in this array |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | private $parent_content = array(); |
||
45 | |||
46 | /** |
||
47 | * Is the import relative |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $relative; |
||
52 | |||
53 | /** |
||
54 | * The parent Vars class |
||
55 | * |
||
56 | * @var \M1\Vars\Vars |
||
57 | */ |
||
58 | public $vars; |
||
59 | |||
60 | /** |
||
61 | * The ResourceProvider constructor creates the content from the entity |
||
62 | * |
||
63 | * @param \M1\Vars\Vars $vars The calling Vars class |
||
64 | * @param string|array $entity The configuration entity |
||
65 | * @param bool $relative Is the entity relative to the calling entity or class |
||
66 | * |
||
67 | * @throws \InvalidArgumentException If the entity passed is not a string or array |
||
68 | */ |
||
69 | 62 | public function __construct(Vars $vars, $entity, $relative = true) |
|
81 | |||
82 | /** |
||
83 | * Creates the content from the entity |
||
84 | * |
||
85 | * @param string|array $entity The configuration entity |
||
86 | */ |
||
87 | 61 | private function createContent($entity) |
|
115 | |||
116 | /** |
||
117 | * Creates the content from the entity |
||
118 | * |
||
119 | * @param string|array $entity The configuration entity |
||
120 | * @param string $type The type of entity |
||
121 | * |
||
122 | * @throws \InvalidArgumentException If the entity is not array|file, is readable or exists |
||
123 | * |
||
124 | * @returns array The array of resources |
||
125 | */ |
||
126 | 61 | private function processEntity($entity, $type) |
|
142 | |||
143 | /** |
||
144 | * Adds content to the parent contents |
||
145 | * |
||
146 | * @param array $content The content from the resource |
||
147 | */ |
||
148 | 49 | private function addContent($content) |
|
156 | |||
157 | /** |
||
158 | * Returns the supported files using the extensions from the loaders in the entity which is a directory |
||
159 | * |
||
160 | * @see \M1\Vars\Loader\LoaderProvider::getExtensions() \M1\Vars\Loader\LoaderProvider::getExtensions() |
||
161 | * @see \M1\Vars\Loader\LoaderProvider::makeLoaders() \M1\Vars\Loader\LoaderProvider::makeLoaders() |
||
162 | * |
||
163 | * @return array|bool Returns the supported files or false if no files were found |
||
164 | */ |
||
165 | 4 | private function getSupportedFilesInDir() |
|
173 | |||
174 | /** |
||
175 | * Merges various configuration contents into one array |
||
176 | * |
||
177 | * @param mixed $contents,... Optional number of arrays to merge |
||
178 | * |
||
179 | * @return array The merged contents |
||
180 | */ |
||
181 | 50 | private function mergeContents() |
|
186 | |||
187 | /** |
||
188 | * Adds content to the parent content array |
||
189 | * |
||
190 | * @param array $content The content to add |
||
191 | */ |
||
192 | 7 | public function addParentContent(array $content) |
|
196 | |||
197 | /** |
||
198 | * Merges the content and the parent content together |
||
199 | * |
||
200 | * @return \M1\Vars\Resource\ResourceProvider |
||
201 | */ |
||
202 | 50 | public function mergeParentContent() |
|
208 | |||
209 | /** |
||
210 | * Returns the parent content |
||
211 | * |
||
212 | * @return mixed The parent content |
||
213 | */ |
||
214 | 38 | public function getParentContent() |
|
218 | } |
||
219 |
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.