1 | <?php |
||
2 | |||
3 | namespace Nip\Mail; |
||
4 | |||
5 | use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider; |
||
6 | use Nip\Mail\Transport\TransportFactory; |
||
7 | |||
8 | /** |
||
9 | * Class MailServiceProvider. |
||
10 | */ |
||
11 | class MailServiceProvider extends AbstractSignatureServiceProvider |
||
12 | { |
||
13 | public const NAME = 'mail'; |
||
14 | |||
15 | /** |
||
16 | 1 | * {@inheritdoc} |
|
17 | */ |
||
18 | 1 | public function register() |
|
19 | 1 | { |
|
20 | 1 | $this->registerTransportManager(); |
|
21 | $this->registerMailer(); |
||
22 | 1 | } |
|
23 | |||
24 | protected function registerTransportManager() |
||
25 | 1 | { |
|
26 | 1 | $this->getContainer()->share(TransportFactory::class, TransportFactory::class); |
|
27 | 1 | } |
|
28 | 1 | ||
29 | protected function registerMailer() |
||
30 | 1 | { |
|
31 | $this->getContainer()->share('mailer', function () { |
||
32 | $transportManager = $this->getContainer()->get(TransportFactory::class); |
||
33 | 1 | $mailer = new MailerManager($transportManager); |
|
0 ignored issues
–
show
|
|||
34 | 1 | ||
35 | 1 | return $mailer; |
|
36 | 1 | }); |
|
37 | 1 | } |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function provides() |
||
43 | { |
||
44 | return [ |
||
45 | 'mailer', |
||
46 | TransportFactory::class, |
||
47 | 'mailer.transportManager', |
||
48 | ]; |
||
49 | } |
||
50 | } |
||
51 |
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.