Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — annotations ( 92917b...59f47e )
by Jérémiah
14:11
created

Connection::getTotalCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Relay\Connection\Output;
6
7
use Overblog\GraphQLBundle\Relay\Connection\ConnectionInterface;
8
use Overblog\GraphQLBundle\Relay\Connection\EdgeInterface;
9
use Overblog\GraphQLBundle\Relay\Connection\PageInfoInterface;
10
11
class Connection implements ConnectionInterface
12
{
13
    use DeprecatedPropertyPublicAccessTrait;
14
15
    /** @var EdgeInterface[] */
16
    protected $edges;
17
18
    /** @var PageInfoInterface */
19
    protected $pageInfo;
20
21
    /** @var int|null */
22
    protected $totalCount;
23
24 89
    public function __construct($edges = [], PageInfoInterface $pageInfo = null)
25
    {
26 89
        $this->edges = $edges;
27 89
        $this->pageInfo = $pageInfo;
28 89
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 86
    public function getEdges()
34
    {
35 86
        return $this->edges;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    public function setEdges(iterable $edges): void
42
    {
43 2
        $this->edges = $edges;
0 ignored issues
show
Documentation Bug introduced by
It seems like $edges can also be of type object<Overblog\GraphQLB...ay\Connection\iterable>. However, the property $edges is declared as type array<integer,object<Ove...nection\EdgeInterface>>. 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...
44 2
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 71
    public function getPageInfo(): ? PageInfoInterface
50
    {
51 71
        return $this->pageInfo;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function setPageInfo(PageInfoInterface $pageInfo): void
58
    {
59 1
        $this->pageInfo = $pageInfo;
60 1
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 57
    public function getTotalCount(): ?int
66
    {
67 57
        return $this->totalCount;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73 4
    public function setTotalCount(int $totalCount): void
74
    {
75 4
        $this->totalCount = $totalCount;
76 4
    }
77
}
78