Issues (9)

ServiceProvider/ConfigurationServiceProvider.php (2 issues)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ServiceProvider;
4
5
use League\Container\Container;
6
use League\Container\ServiceProvider\AbstractServiceProvider;
7
use League\Container\ServiceProvider\BootableServiceProviderInterface;
8
9
class ConfigurationServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected $provides = [
15
        'GITLAB_URL',
16
        'GITLAB_TOKEN',
17
        'SLACK_WEBHOOK_URL',
18
        'SLACK_CHANNEL',
19
    ];
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function register()
25
    {
26
    }
27
28
    /**
29
     * Method will be invoked on registration of a service provider implementing
30
     * this interface. Provides ability for eager loading of Service Providers.
31
     *
32
     * @return void
33
     */
34
    public function boot()
35
    {
36
        $dotEnv = \Dotenv\Dotenv::create(__DIR__ . '../..');
0 ignored issues
show
The call to Dotenv\Dotenv::create() has too few arguments starting with paths. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        /** @scrutinizer ignore-call */ 
37
        $dotEnv = \Dotenv\Dotenv::create(__DIR__ . '../..');

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
__DIR__ . '../..' of type string is incompatible with the type Dotenv\Repository\RepositoryInterface expected by parameter $repository of Dotenv\Dotenv::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $dotEnv = \Dotenv\Dotenv::create(/** @scrutinizer ignore-type */ __DIR__ . '../..');
Loading history...
37
        $dotEnv->safeLoad();
38
        $dotEnv->required(['GITLAB_TOKEN'])->notEmpty();
39
40
        /** @var Container $container */
41
        $container = $this->getContainer();
42
43
        $container->add('SLACK_WEBHOOK_URL', getenv('SLACK_WEBHOOK_URL'));
44
        $container->add('SLACK_CHANNEL', getenv('SLACK_CHANNEL'));
45
        $container->add('GITLAB_TOKEN', getenv('GITLAB_TOKEN'));
46
        $container->add('GITLAB_URL', (getenv('GITLAB_URL') ? getenv('GITLAB_URL') : 'https://gitlab.com'));
47
    }
48
}
49