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 phpDocumentor\Plugin; |
||
4 | |||
5 | use Cilex\Application; |
||
6 | use Cilex\ServiceProviderInterface; |
||
7 | use phpDocumentor\Configuration as ApplicationConfiguration; |
||
8 | |||
9 | class ServiceProvider implements ServiceProviderInterface |
||
10 | { |
||
11 | public function register(Application $app) |
||
12 | { |
||
13 | /** @var ApplicationConfiguration $config */ |
||
14 | $config = $app['config']; |
||
15 | $plugins = $config->getPlugins(); |
||
16 | |||
17 | if (! $plugins) { |
||
0 ignored issues
–
show
|
|||
18 | $app->register(new Core\ServiceProvider()); |
||
19 | $app->register(new Scrybe\ServiceProvider()); |
||
20 | |||
21 | return; |
||
22 | } |
||
23 | |||
24 | array_walk( |
||
25 | $plugins, |
||
26 | function ($plugin) use ($app) { |
||
27 | /** @var Plugin $plugin */ |
||
28 | $provider = (strpos($plugin->getClassName(), '\\') === false) |
||
29 | ? sprintf('phpDocumentor\\Plugin\\%s\\ServiceProvider', $plugin->getClassName()) |
||
30 | : $plugin->getClassName(); |
||
31 | if (!class_exists($provider)) { |
||
32 | throw new \RuntimeException('Loading Service Provider for ' . $provider . ' failed.'); |
||
33 | } |
||
34 | |||
35 | try { |
||
36 | $app->register(new $provider($plugin)); |
||
37 | } catch (\InvalidArgumentException $e) { |
||
38 | throw new \RuntimeException($e->getMessage()); |
||
39 | } |
||
40 | } |
||
41 | ); |
||
42 | } |
||
43 | } |
||
44 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.