1 | <?php |
||
2 | |||
3 | namespace Spinen\ClickUp\Providers; |
||
4 | |||
5 | use GuzzleHttp\Client as Guzzle; |
||
6 | use Illuminate\Contracts\Foundation\Application; |
||
7 | use Illuminate\Contracts\Support\DeferrableProvider; |
||
8 | use Illuminate\Support\Facades\Config; |
||
9 | use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
||
10 | use Spinen\ClickUp\Api\Client as ClickUp; |
||
11 | use Spinen\ClickUp\Support\Builder; |
||
12 | |||
13 | /** |
||
14 | * Class ClientServiceProvider |
||
15 | * |
||
16 | * Since this is deferred, it only needed to deal with code that has to do with the client. |
||
17 | * |
||
18 | * @package Spinen\ClickUp\Providers |
||
19 | */ |
||
20 | class ClientServiceProvider extends LaravelServiceProvider implements DeferrableProvider |
||
21 | { |
||
22 | /** |
||
23 | * Bootstrap services. |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | public function boot() |
||
28 | { |
||
29 | // |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Register services. |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function register() |
||
38 | { |
||
39 | $this->registerClient(); |
||
40 | |||
41 | $this->app->alias(ClickUp::class, 'ClickUp'); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get the services provided by the provider. |
||
46 | * |
||
47 | * @return array |
||
48 | */ |
||
49 | public function provides() |
||
50 | { |
||
51 | return [ |
||
52 | Builder::class, |
||
53 | ClickUp::class, |
||
54 | ]; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Register the client |
||
59 | * |
||
60 | * If the ClickUp id or roles are null, then assume sensible values via the API |
||
61 | */ |
||
62 | protected function registerClient(): void |
||
63 | { |
||
64 | $this->app->bind( |
||
65 | Builder::class, |
||
66 | function (Application $app) { |
||
67 | return new Builder($app->make(ClickUp::class)); |
||
0 ignored issues
–
show
|
|||
68 | } |
||
69 | ); |
||
70 | |||
71 | $this->app->bind( |
||
72 | ClickUp::class, |
||
73 | function (Application $app) { |
||
74 | return new ClickUp(Config::get('clickup'), $app->make(Guzzle::class)); |
||
75 | } |
||
76 | ); |
||
77 | } |
||
78 | } |
||
79 |
This check compares calls to functions or methods with their respective definitions. If the call has more 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.