1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ActionM\UnitPay; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\App; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use ActionM\UnitPay\Exceptions\InvalidConfiguration; |
8
|
|
|
|
9
|
|
|
class UnitPayServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Bootstrap the application services. |
13
|
|
|
*/ |
14
|
|
|
public function boot() |
15
|
|
|
{ |
16
|
|
|
$this->publishes([ |
17
|
|
|
__DIR__.'/../config/unitpay.php' => config_path('unitpay.php'), |
18
|
|
|
], 'config'); |
19
|
|
|
|
20
|
|
|
$this->publishes([ |
21
|
|
|
__DIR__.'/../resources/views' => base_path('resources/views/vendor/unitpay'), |
22
|
|
|
], 'views'); |
23
|
|
|
|
24
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'unitpay'); |
25
|
|
|
|
26
|
|
|
$this->testingEnv(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Register the application services. |
31
|
|
|
*/ |
32
|
|
|
public function register() |
33
|
|
|
{ |
34
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/unitpay.php', 'unitpay'); |
35
|
|
|
|
36
|
|
|
$this->app['events']->subscribe(UnitPayNotifier::class); |
37
|
|
|
|
38
|
|
|
$this->app->singleton('unitpay', function () { |
39
|
|
|
return $this->app->make('ActionM\UnitPay\UnitPay'); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
$this->app->alias('unitpay', 'UnitPay'); |
43
|
|
|
|
44
|
|
|
$this->app->singleton(UnitPayNotifier::class); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Not check config if testing env. |
49
|
|
|
* @throws InvalidConfiguration |
50
|
|
|
*/ |
51
|
|
|
public function testingEnv() |
52
|
|
|
{ |
53
|
|
|
if (! App::environment('testing')) { |
|
|
|
|
54
|
|
|
$callable = config('unitpay.searchOrderFilter'); |
55
|
|
|
|
56
|
|
|
if (! is_callable($callable)) { |
57
|
|
|
throw InvalidConfiguration::searchOrderFilterInvalid(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$callable = config('unitpay.paidOrderFilter'); |
61
|
|
|
|
62
|
|
|
if (! is_callable($callable)) { |
63
|
|
|
throw InvalidConfiguration::orderPaidFilterInvalid(); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.