Passed
Pull Request — master (#773)
by Songda
02:17 queued 31s
created

PapayContractShortcut::getPlugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\Shortcut;
6
7
use Yansongda\Pay\Contract\ShortcutInterface;
8
use Yansongda\Pay\Plugin\Wechat\Papay\OnlyContractPlugin;
9
use Yansongda\Pay\Plugin\Wechat\PreparePlugin;
10
11
/**
12
 * 返回只签约(委托代扣)参数.
13
 *
14
 * @see https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_3.shtml
15
 */
16
class PapayContractShortcut implements ShortcutInterface
17
{
18
    public function getPlugins(array $params): array
19
    {
20
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(Yansongda\P...yContractPlugin::class) returns the type array<integer,string> which is incompatible with the return type mandated by Yansongda\Pay\Contract\S...Interface::getPlugins() of Yansongda\Pay\Contract\PluginInterface[].

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
21
            PreparePlugin::class,
22
            OnlyContractPlugin::class,
23
        ];
24
    }
25
}
26