GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( b87887...138d7a )
by t
62:54 queued 27s
created

Auth::getError()   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 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace icy2003\php\iapis\wechat\miniprogram;
4
5
use icy2003\php\I;
6
use icy2003\php\iapis\Api;
7
use icy2003\php\ihelpers\Arrays;
8
use icy2003\php\ihelpers\Http;
9
use icy2003\php\ihelpers\Json;
10
11
class Auth extends Api
12
{
13
14
    public function __construct($appid, $secret)
15
    {
16
        $this->setOption('appid', $appid);
17
        $this->setOption('secret', $secret);
18
    }
19
20
    public function isSuccess()
21
    {
22
        if (0 === I::get($this->_result, 'errcode', 0)) {
23
            return true;
24
        }
25
        return false;
26
    }
27
28
    public function getError()
29
    {
30
        return [
31
            'errcode' => I::get($this->_result, 'errcode', 0),
32
            'errmsg' => I::get($this->_result, 'errmsg', ''),
33
        ];
34
    }
35
36
    public function getAccessToken()
37
    {
38
        $this->setOption('grant_type', 'client_credential');
39
        $this->_result = Json::decode(Http::get('https://api.weixin.qq.com/cgi-bin/token', $this->filterOptions([
0 ignored issues
show
Documentation Bug introduced by
It seems like icy2003\php\ihelpers\Jso..., 'appid', 'secret')))) can also be of type false. However, the property $_result is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
40
            'grant_type', 'appid', 'secret',
41
        ])));
42
        $this->_toArrayCall = function ($array) {
43
            return Arrays::columns1($array, ['access_token', 'expires_in']);
44
        };
45
46
        return $this;
47
    }
48
49
    public function code2Session($code)
50
    {
51
        $this->setOption('grant_type', 'authorization_code');
52
        $this->setOption('js_code', $code);
53
        $this->_result = Json::decode(Http::get('https://api.weixin.qq.com/sns/jscode2session', $this->filterOptions([
0 ignored issues
show
Documentation Bug introduced by
It seems like icy2003\php\ihelpers\Jso...code', 'grant_type')))) can also be of type false. However, the property $_result is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
54
            'appid', 'secret', 'js_code', 'grant_type',
55
        ])));
56
        // 这个接口返回没有 errcode
57
        $this->_toArrayCall = function ($array) {
58
            return Arrays::columns1($array, ['openid', 'session_key', 'unionid']);
59
        };
60
61
        return $this;
62
    }
63
}
64