This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Caffeinated\Modules; |
||
4 | |||
5 | use Caffeinated\Modules\Contracts\RepositoryInterface; |
||
6 | use Illuminate\Foundation\Application; |
||
7 | |||
8 | class Modules implements RepositoryInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var Application |
||
12 | */ |
||
13 | protected $app; |
||
14 | |||
15 | /** |
||
16 | * @var RepositoryInterface |
||
17 | */ |
||
18 | protected $repository; |
||
19 | |||
20 | /** |
||
21 | * Create a new Modules instance. |
||
22 | * |
||
23 | * @param Application $app |
||
24 | 1 | * @param RepositoryInterface $repository |
|
25 | */ |
||
26 | 1 | public function __construct(Application $app, RepositoryInterface $repository) |
|
27 | 1 | { |
|
28 | 1 | $this->app = $app; |
|
29 | $this->repository = $repository; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Register the module service provider file from all modules. |
||
34 | * |
||
35 | * @return mixed |
||
36 | */ |
||
37 | public function register() |
||
38 | { |
||
39 | $modules = $this->repository->enabled(); |
||
40 | |||
41 | $modules->each(function ($properties, $slug) { |
||
0 ignored issues
–
show
|
|||
42 | $this->registerServiceProvider($properties); |
||
43 | |||
44 | $this->autoloadFiles($properties); |
||
45 | }); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Register the module service provider. |
||
50 | * |
||
51 | * @param string $properties |
||
52 | * |
||
53 | * @return string |
||
54 | * |
||
55 | * @throws \Caffeinated\Modules\Exception\FileMissingException |
||
56 | */ |
||
57 | protected function registerServiceProvider($properties) |
||
58 | { |
||
59 | $namespace = $this->resolveNamespace($properties); |
||
0 ignored issues
–
show
$properties is of type string , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
60 | $file = $this->repository->getPath()."/{$namespace}/Providers/{$namespace}ServiceProvider.php"; |
||
0 ignored issues
–
show
$file is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
61 | $serviceProvider = $this->repository->getNamespace().'\\'.$namespace."\\Providers\\{$namespace}ServiceProvider"; |
||
62 | |||
63 | if (class_exists($serviceProvider)) { |
||
64 | $this->app->register($serviceProvider); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Autoload custom module files. |
||
70 | * |
||
71 | * @param array $properties |
||
72 | */ |
||
73 | protected function autoloadFiles($properties) |
||
74 | { |
||
75 | if (isset($properties['autoload'])) { |
||
76 | $namespace = $this->resolveNamespace($properties); |
||
77 | $path = $this->repository->getPath()."/{$namespace}/"; |
||
78 | |||
79 | foreach ($properties['autoload'] as $file) { |
||
80 | include $path.$file; |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
85 | public function optimize() |
||
86 | { |
||
87 | return $this->repository->optimize(); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Get all modules. |
||
92 | * |
||
93 | * @return Collection |
||
94 | */ |
||
95 | public function all() |
||
96 | { |
||
97 | return $this->repository->all(); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Get all module slugs. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | public function slugs() |
||
106 | { |
||
107 | return $this->repository->slugs(); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Get modules based on where clause. |
||
112 | * |
||
113 | * @param string $key |
||
114 | * @param mixed $value |
||
115 | * |
||
116 | * @return Collection |
||
117 | */ |
||
118 | public function where($key, $value) |
||
119 | { |
||
120 | return $this->repository->where($key, $value); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Sort modules by given key in ascending order. |
||
125 | * |
||
126 | * @param string $key |
||
127 | * |
||
128 | * @return Collection |
||
129 | */ |
||
130 | public function sortBy($key) |
||
131 | { |
||
132 | return $this->repository->sortBy($key); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Sort modules by given key in ascending order. |
||
137 | * |
||
138 | * @param string $key |
||
139 | * |
||
140 | * @return Collection |
||
141 | */ |
||
142 | public function sortByDesc($key) |
||
143 | { |
||
144 | return $this->repository->sortByDesc($key); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Check if the given module exists. |
||
149 | * |
||
150 | * @param string $slug |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | public function exists($slug) |
||
155 | { |
||
156 | return $this->repository->exists($slug); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Returns count of all modules. |
||
161 | * |
||
162 | * @return int |
||
163 | */ |
||
164 | public function count() |
||
165 | { |
||
166 | return $this->repository->count(); |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * Get modules path. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getPath() |
||
175 | { |
||
176 | return $this->repository->getPath(); |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * Set modules path in "RunTime" mode. |
||
181 | * |
||
182 | * @param string $path |
||
183 | * |
||
184 | * @return object $this |
||
185 | */ |
||
186 | public function setPath($path) |
||
187 | { |
||
188 | return $this->repository->setPath($path); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Get path for the specified module. |
||
193 | * |
||
194 | * @param string $slug |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getModulePath($slug) |
||
199 | { |
||
200 | return $this->repository->getModulePath($slug); |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * Get modules namespace. |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | public function getNamespace() |
||
209 | { |
||
210 | return $this->repository->getNamespace(); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Get a module's properties. |
||
215 | * |
||
216 | * @param string $slug |
||
217 | * |
||
218 | * @return mixed |
||
219 | */ |
||
220 | public function getManifest($slug) |
||
221 | { |
||
222 | return $this->repository->getManifest($slug); |
||
223 | } |
||
224 | |||
225 | /** |
||
226 | * Get a module property value. |
||
227 | * |
||
228 | * @param string $property |
||
229 | * @param mixed $default |
||
230 | * |
||
231 | * @return mixed |
||
232 | */ |
||
233 | public function get($property, $default = null) |
||
234 | { |
||
235 | return $this->repository->get($property, $default); |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * Set a module property value. |
||
240 | * |
||
241 | * @param string $property |
||
242 | * @param mixed $value |
||
243 | * |
||
244 | * @return bool |
||
245 | */ |
||
246 | public function set($property, $value) |
||
247 | { |
||
248 | return $this->repository->set($property, $value); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Gets all enabled modules. |
||
253 | * |
||
254 | * @return array |
||
255 | */ |
||
256 | public function enabled() |
||
257 | { |
||
258 | return $this->repository->enabled(); |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * Gets all disabled modules. |
||
263 | * |
||
264 | * @return array |
||
265 | */ |
||
266 | public function disabled() |
||
267 | { |
||
268 | return $this->repository->disabled(); |
||
269 | } |
||
270 | |||
271 | /** |
||
272 | * Check if specified module is enabled. |
||
273 | * |
||
274 | * @param string $slug |
||
275 | * |
||
276 | * @return bool |
||
277 | */ |
||
278 | public function isEnabled($slug) |
||
279 | { |
||
280 | return $this->repository->isEnabled($slug); |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * Check if specified module is disabled. |
||
285 | * |
||
286 | * @param string $slug |
||
287 | * |
||
288 | * @return bool |
||
289 | */ |
||
290 | public function isDisabled($slug) |
||
291 | { |
||
292 | return $this->repository->isDisabled($slug); |
||
293 | } |
||
294 | |||
295 | /** |
||
296 | * Enables the specified module. |
||
297 | * |
||
298 | * @param string $slug |
||
299 | * |
||
300 | * @return bool |
||
301 | */ |
||
302 | public function enable($slug) |
||
303 | { |
||
304 | return $this->repository->enable($slug); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * Disables the specified module. |
||
309 | * |
||
310 | * @param string $slug |
||
311 | * |
||
312 | * @return bool |
||
313 | */ |
||
314 | public function disable($slug) |
||
315 | { |
||
316 | return $this->repository->disable($slug); |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * Resolve the correct module namespace. |
||
321 | * |
||
322 | * @param array $properties |
||
323 | */ |
||
324 | public function resolveNamespace($properties) |
||
325 | { |
||
326 | return isset($properties['namespace']) |
||
327 | ? $properties['namespace'] |
||
328 | : studly_case($properties['slug']) |
||
329 | ; |
||
330 | } |
||
331 | } |
||
332 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.