1 | <?php |
||
30 | class ResourceProvider extends AbstractResource |
||
31 | { |
||
32 | use ResourceFlagsTrait; |
||
33 | |||
34 | /** |
||
35 | * The configuration entity -- could be a file, array or dir |
||
36 | * |
||
37 | * @var array|string |
||
38 | */ |
||
39 | private $entity; |
||
40 | |||
41 | /** |
||
42 | * If the import was not relative then the content will be stored in this array |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private $parent_content = array(); |
||
47 | |||
48 | /** |
||
49 | * Are dirs wanting to be recursively searched |
||
50 | * |
||
51 | * @var bool |
||
52 | */ |
||
53 | private $recursive; |
||
54 | |||
55 | /** |
||
56 | * Is the import relative |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | private $relative; |
||
61 | |||
62 | /** |
||
63 | * Suppress file not found exceptions |
||
64 | * |
||
65 | * @var bool |
||
66 | */ |
||
67 | private $suppress_file_exceptions = false; |
||
68 | |||
69 | /** |
||
70 | * The parent Vars class |
||
71 | * |
||
72 | * @var \M1\Vars\Vars |
||
73 | */ |
||
74 | public $vars; |
||
75 | |||
76 | /** |
||
77 | * The ResourceProvider constructor creates the content from the entity |
||
78 | * |
||
79 | * @param \M1\Vars\Vars $vars The calling Vars class |
||
80 | * @param string|array $entity The configuration entity |
||
81 | * @param bool $relative Is the entity relative to the calling entity or class |
||
82 | * @param bool $recursive If entity a dir, do you want to recursively check directories |
||
83 | * |
||
84 | * @throws \InvalidArgumentException If the entity passed is not a string or array |
||
85 | */ |
||
86 | 72 | public function __construct(Vars $vars, $entity, $relative = true, $recursive = true) |
|
99 | |||
100 | /** |
||
101 | * Creates the content from the entity |
||
102 | * |
||
103 | * @param string|array $entity The configuration entity |
||
104 | */ |
||
105 | 71 | private function createContent($entity) |
|
134 | |||
135 | /** |
||
136 | * Creates the content from the entity |
||
137 | * |
||
138 | * @param string|array $entity The configuration entity |
||
139 | * @param string $type The type of entity |
||
140 | * |
||
141 | * @throws \InvalidArgumentException If the entity is not array|file, is readable or exists |
||
142 | * |
||
143 | * @returns array The array of resources |
||
144 | */ |
||
145 | 71 | private function processEntity($entity, $type) |
|
165 | |||
166 | /** |
||
167 | * Creates the content from the entity |
||
168 | * |
||
169 | * @param string $entity The configuration entity |
||
170 | * |
||
171 | * @returns string The parsed entity |
||
172 | */ |
||
173 | 71 | private function parseEntity($entity) |
|
192 | |||
193 | /** |
||
194 | * Adds content to the parent contents |
||
195 | * |
||
196 | * @param array $content The content from the resource |
||
197 | */ |
||
198 | 57 | private function addContent($content) |
|
206 | |||
207 | /** |
||
208 | * Returns the supported files using the extensions from the loaders in the entity which is a directory |
||
209 | * |
||
210 | * @see \M1\Vars\Loader\LoaderProvider::getExtensions() \M1\Vars\Loader\LoaderProvider::getExtensions() |
||
211 | * @see \M1\Vars\Loader\LoaderProvider::makeLoaders() \M1\Vars\Loader\LoaderProvider::makeLoaders() |
||
212 | * |
||
213 | * @return array|bool Returns the supported files or false if no files were found |
||
214 | */ |
||
215 | 5 | private function getSupportedFilesInDir() |
|
223 | |||
224 | /** |
||
225 | * Merges various configuration contents into one array |
||
226 | * |
||
227 | * @param mixed $contents,... Optional number of arrays to merge |
||
228 | * |
||
229 | * @return array The merged contents |
||
230 | */ |
||
231 | 59 | private function mergeContents() |
|
236 | |||
237 | /** |
||
238 | * Adds content to the parent content array |
||
239 | * |
||
240 | * @param array $content The content to add |
||
241 | */ |
||
242 | 7 | public function addParentContent(array $content) |
|
246 | |||
247 | /** |
||
248 | * Merges the content and the parent content together |
||
249 | * |
||
250 | * @return \M1\Vars\Resource\ResourceProvider |
||
251 | */ |
||
252 | 59 | public function mergeParentContent() |
|
258 | |||
259 | /** |
||
260 | * Returns the parent content |
||
261 | * |
||
262 | * @return mixed The parent content |
||
263 | */ |
||
264 | 44 | public function getParentContent() |
|
268 | } |
||
269 |
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.