Issues (93)

src/Plugin/Wechat/V2/VerifySignaturePlugin.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\V2;
6
7
use Closure;
8
use Yansongda\Artful\Contract\PluginInterface;
9
use Yansongda\Artful\Exception\ContainerException;
10
use Yansongda\Artful\Exception\InvalidConfigException;
11
use Yansongda\Artful\Exception\ServiceNotFoundException;
12
use Yansongda\Artful\Logger;
13
use Yansongda\Artful\Rocket;
14
use Yansongda\Pay\Exception\InvalidSignException;
15
16
use function Yansongda\Artful\should_do_http_request;
17
use function Yansongda\Pay\get_wechat_config;
18
use function Yansongda\Pay\verify_wechat_sign_v2;
19
20
class VerifySignaturePlugin implements PluginInterface
21
{
22
    /**
23
     * @throws ContainerException
24
     * @throws InvalidConfigException
25
     * @throws ServiceNotFoundException
26
     * @throws InvalidSignException
27
     */
28
    public function assembly(Rocket $rocket, Closure $next): Rocket
29
    {
30
        /* @var Rocket $rocket */
31
        $rocket = $next($rocket);
32
33
        Logger::debug('[Wechat][V2][VerifySignaturePlugin] 插件开始装载', ['rocket' => $rocket]);
34
35
        $config = get_wechat_config($rocket->getParams());
36
37
        if (!should_do_http_request($rocket->getDirection())) {
38
            return $rocket;
39
        }
40
41
        verify_wechat_sign_v2($config, $rocket->getDestination()?->all() ?? []);
0 ignored issues
show
The method all() does not exist on Psr\Http\Message\MessageInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        verify_wechat_sign_v2($config, $rocket->getDestination()?->/** @scrutinizer ignore-call */ all() ?? []);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
43
        Logger::info('[Wechat][V2][VerifySignaturePlugin] 插件装载完毕', ['rocket' => $rocket]);
44
45
        return $rocket;
46
    }
47
}
48