These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @copyright Copyright (c) Flipbox Digital Limited |
||
5 | * @license https://flipboxfactory.com/software/hubspot/license |
||
6 | * @link https://www.flipboxfactory.com/software/hubspot/ |
||
7 | */ |
||
8 | |||
9 | namespace flipbox\hubspot\patron\connections; |
||
10 | |||
11 | use flipbox\hubspot\connections\ConnectionInterface; |
||
12 | use flipbox\hubspot\connections\IntegrationConnectionInterface; |
||
13 | use Flipbox\OAuth2\Client\Provider\HubSpotResourceOwner; |
||
14 | use yii\base\BaseObject; |
||
15 | |||
16 | /** |
||
17 | * @author Flipbox Factory <[email protected]> |
||
18 | * @since 1.0.0 |
||
19 | */ |
||
20 | class AccessTokenConnection extends BaseObject implements IntegrationConnectionInterface |
||
21 | { |
||
22 | use traits\AccessTokenAuthorizationTrait; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $hubId; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $appId; |
||
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | * @throws \flipbox\ember\exceptions\NotFoundException |
||
37 | * @throws \yii\base\InvalidConfigException |
||
38 | */ |
||
39 | public function getHubId(): string |
||
40 | { |
||
41 | if ($this->hubId === null) { |
||
42 | /** @var HubSpotResourceOwner $resourceOwner */ |
||
43 | $resourceOwner = $this->getProvider()->getResourceOwner($this->getAccessToken()); |
||
44 | |||
45 | $this->hubId = $resourceOwner->getHubId(); |
||
46 | } |
||
47 | |||
48 | return $this->hubId; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | * @throws \flipbox\ember\exceptions\NotFoundException |
||
54 | * @throws \yii\base\InvalidConfigException |
||
55 | */ |
||
56 | public function getAppId(): string |
||
57 | { |
||
58 | if ($this->appId === null) { |
||
59 | /** @var HubSpotResourceOwner $resourceOwner */ |
||
60 | $resourceOwner = $this->getProvider()->getResourceOwner($this->getAccessToken()); |
||
61 | |||
62 | $this->appId = $resourceOwner->getAppId(); |
||
0 ignored issues
–
show
|
|||
63 | } |
||
64 | |||
65 | return $this->appId; |
||
66 | } |
||
67 | } |
||
68 |
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 theid
property of an instance of theAccount
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.