1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Matchish\ScoutElasticSearch; |
||
6 | |||
7 | use Elasticsearch\Client; |
||
8 | use Illuminate\Support\ServiceProvider; |
||
9 | use Laravel\Scout\EngineManager; |
||
10 | use Laravel\Scout\ScoutServiceProvider; |
||
11 | use Matchish\ScoutElasticSearch\Console\Commands\FlushCommand; |
||
12 | use Matchish\ScoutElasticSearch\Console\Commands\ImportCommand; |
||
13 | use Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine; |
||
14 | use Matchish\ScoutElasticSearch\Searchable\DefaultImportSourceFactory; |
||
15 | use Matchish\ScoutElasticSearch\Searchable\ImportSourceFactory; |
||
16 | |||
17 | final class ScoutElasticSearchServiceProvider extends ServiceProvider |
||
18 | { |
||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | 50 | public function boot(): void |
|
23 | { |
||
24 | 50 | $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'scout'); |
|
25 | |||
26 | $this->app->make(EngineManager::class)->extend(ElasticSearchEngine::class, function () { |
||
27 | 18 | $elasticsearch = app(Client::class); |
|
28 | |||
29 | 18 | return new ElasticSearchEngine($elasticsearch); |
|
30 | 50 | }); |
|
31 | 50 | $this->registerCommands(); |
|
32 | 50 | } |
|
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 50 | public function register(): void |
|
38 | { |
||
39 | 50 | $this->app->register(ScoutServiceProvider::class); |
|
0 ignored issues
–
show
|
|||
40 | 50 | $this->app->bind(ImportSourceFactory::class, DefaultImportSourceFactory::class); |
|
41 | 50 | } |
|
42 | |||
43 | /** |
||
44 | * Register artisan commands. |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | 50 | private function registerCommands(): void |
|
49 | { |
||
50 | 50 | if ($this->app->runningInConsole()) { |
|
51 | 50 | $this->commands([ |
|
52 | 50 | ImportCommand::class, |
|
53 | FlushCommand::class, |
||
54 | ]); |
||
55 | } |
||
56 | 50 | } |
|
57 | } |
||
58 |
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.