1 | <?php |
||||
2 | |||||
3 | namespace MrShan0\WordpressAuth; |
||||
4 | |||||
5 | use Auth; |
||||
6 | use Hautelook\Phpass\PasswordHash; |
||||
7 | use Illuminate\Support\ServiceProvider; |
||||
8 | use MrShan0\WordpressAuth\Auth\EloquentWordpressUserProvider; |
||||
9 | use MrShan0\WordpressAuth\Guard\WordpressGuard; |
||||
10 | use MrShan0\WordpressAuth\Hashing\WordPressHasher; |
||||
11 | |||||
12 | class WordpressAuthServiceProvider extends ServiceProvider |
||||
13 | { |
||||
14 | /** |
||||
15 | * Indicates if loading of the provider is deferred. |
||||
16 | * |
||||
17 | * @var bool |
||||
18 | */ |
||||
19 | protected $defer = false; |
||||
20 | |||||
21 | /** |
||||
22 | * Perform post-registration booting of services. |
||||
23 | * |
||||
24 | * @return void |
||||
25 | */ |
||||
26 | public function boot() |
||||
27 | { |
||||
28 | $this->publishes([ |
||||
29 | __DIR__ . '/../config/wordpress-auth.php' => config_path('wordpress-auth.php'), |
||||
30 | ]); |
||||
31 | } |
||||
32 | |||||
33 | /** |
||||
34 | * Register bindings in the container. |
||||
35 | * |
||||
36 | * @return void |
||||
37 | */ |
||||
38 | public function register() |
||||
39 | { |
||||
40 | $this->mergeConfigFrom(__DIR__ . '/../config/wordpress-auth.php', 'wordpress-auth'); |
||||
41 | |||||
42 | Auth::extend('wordpress', function ($app) { |
||||
43 | return new WordpressGuard( |
||||
0 ignored issues
–
show
|
|||||
44 | new EloquentWordpressUserProvider($app['wordpress-auth'], $config['model']) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
new MrShan0\WordpressAut...th'], $config['model']) of type MrShan0\WordpressAuth\Au...ntWordpressUserProvider is incompatible with the type string expected by parameter $name of MrShan0\WordpressAuth\Gu...essGuard::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
45 | ); |
||||
46 | }); |
||||
47 | |||||
48 | $this->app->singleton('wordpress-auth', function ($app) { |
||||
49 | $iteration_count = $app['config']->get('wordpress-auth.hash.iteration_count'); |
||||
50 | $portable_hashes = $app['config']->get('wordpress-auth.hash.portable_hashes'); |
||||
51 | |||||
52 | $hasher = new PasswordHash($iteration_count, $portable_hashes); |
||||
53 | |||||
54 | return new WordPressHasher($hasher); |
||||
55 | }); |
||||
56 | |||||
57 | Auth::provider('eloquent.wordpress', function ($app, array $config) { |
||||
58 | return new EloquentWordpressUserProvider($app['wordpress-auth'], $config['model']); |
||||
59 | }); |
||||
60 | } |
||||
61 | |||||
62 | /** |
||||
63 | * Get the services provided by the provider. |
||||
64 | * |
||||
65 | * @return string[] |
||||
66 | */ |
||||
67 | public function provides() |
||||
68 | { |
||||
69 | return ['wordpress-auth']; |
||||
70 | } |
||||
71 | } |
||||
72 |
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.