angelcamposm /
ping
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Ping for Laravel. |
||
| 5 | * |
||
| 6 | * This class makes Ping request to a host. |
||
| 7 | * |
||
| 8 | * Ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. |
||
| 9 | * |
||
| 10 | * @author Angel Campos <[email protected]> |
||
| 11 | * @requires PHP 8.0 |
||
| 12 | * |
||
| 13 | * @version 2.1.2 |
||
| 14 | */ |
||
| 15 | |||
| 16 | namespace Acamposm\Ping\ServiceProviders; |
||
| 17 | |||
| 18 | use Acamposm\Ping\Console\InstallPingPackageCommand; |
||
| 19 | use Acamposm\Ping\Ping; |
||
| 20 | use Illuminate\Support\ServiceProvider; |
||
| 21 | |||
| 22 | class PingServiceProvider extends ServiceProvider |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Bootstrap the application services. |
||
| 26 | */ |
||
| 27 | public function boot() |
||
| 28 | { |
||
| 29 | if ($this->app->runningInConsole()) { |
||
| 30 | $this->publishCommands(); |
||
| 31 | $this->publishConfiguration(); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Register the application services. |
||
| 37 | */ |
||
| 38 | public function register() |
||
| 39 | { |
||
| 40 | // Automatically apply the package configuration |
||
| 41 | $this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'ping'); |
||
| 42 | |||
| 43 | // Register the main class to use with the facade |
||
| 44 | $this->app->singleton('ping', function () { |
||
| 45 | return new Ping(); |
||
|
0 ignored issues
–
show
|
|||
| 46 | }); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Publishes console commands. |
||
| 51 | * |
||
| 52 | * @return void |
||
| 53 | */ |
||
| 54 | private function publishCommands(): void |
||
| 55 | { |
||
| 56 | if (!file_exists(config_path('ping.php'))) { |
||
| 57 | $this->commands([ |
||
| 58 | InstallPingPackageCommand::class, |
||
| 59 | ]); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Publishes package configuration files. |
||
| 65 | * |
||
| 66 | * @return void |
||
| 67 | */ |
||
| 68 | private function publishConfiguration(): void |
||
| 69 | { |
||
| 70 | $this->publishes([ |
||
| 71 | __DIR__.'/../../config/config.php' => config_path('ping.php'), |
||
| 72 | ], 'config'); |
||
| 73 | } |
||
| 74 | } |
||
| 75 |
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.