1 | <?php |
||
2 | |||
3 | namespace Sarahman\HttpRequestApiLog; |
||
4 | |||
5 | use Illuminate\Foundation\Application as IlluminateApplication; |
||
6 | use Illuminate\Support\ServiceProvider; |
||
7 | |||
8 | class HttpRequestApiLogServiceProvider extends ServiceProvider |
||
9 | { |
||
10 | /** |
||
11 | * Indicates if loading of the provider is deferred. |
||
12 | * |
||
13 | * @var bool |
||
14 | */ |
||
15 | protected $defer = false; |
||
16 | |||
17 | /** |
||
18 | * Actual provider based on Laravel version. |
||
19 | * |
||
20 | * @var \Illuminate\Support\ServiceProvider |
||
21 | */ |
||
22 | protected $provider; |
||
23 | |||
24 | /** |
||
25 | * Create a new service provider instance. |
||
26 | * |
||
27 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public function __construct($app) |
||
32 | { |
||
33 | parent::__construct($app); |
||
34 | |||
35 | $this->provider = $this->getProvider(); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Bootstrap the application events. |
||
40 | * |
||
41 | * @return void |
||
42 | */ |
||
43 | public function boot() |
||
44 | { |
||
45 | if (method_exists($this->provider, 'boot')) { |
||
46 | return $this->provider->boot(); |
||
0 ignored issues
–
show
|
|||
47 | } |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Register the service provider. |
||
52 | * |
||
53 | * @return void |
||
54 | */ |
||
55 | public function register() |
||
56 | { |
||
57 | return $this->provider->register(); |
||
0 ignored issues
–
show
Are you sure the usage of
$this->provider->register() targeting Illuminate\Support\ServiceProvider::register() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Return ServiceProvider according to Laravel version. |
||
62 | * |
||
63 | * @return \Illuminate\Support\ServiceProvider |
||
64 | */ |
||
65 | private function getProvider() |
||
66 | { |
||
67 | if (version_compare(IlluminateApplication::VERSION, '5.0', '<')) { |
||
68 | $provider = '\Sarahman\HttpRequestApiLog\ServiceProviderForLaravel4'; |
||
69 | } else { |
||
70 | $provider = '\Sarahman\HttpRequestApiLog\ServiceProviderForLaravelRecent'; |
||
71 | } |
||
72 | |||
73 | return new $provider($this->app); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Get the services provided by the provider. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function provides() |
||
82 | { |
||
83 | return ['http-request-api-log']; |
||
84 | } |
||
85 | } |
||
86 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.