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
Pull Request — master (#4)
by Jérémiah
06:39
created

Argument::getRawArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Definition;
13
14
class Argument implements \ArrayAccess, \Countable
15
{
16
    private $arguments = [];
17
18 5
    public function __construct($arguments)
19
    {
20 5
        if (!is_array($arguments) && !$arguments instanceof \ArrayAccess) {
21 5
            $arguments = [$arguments];
22 5
        }
23 5
        $this->arguments = $arguments;
0 ignored issues
show
Documentation Bug introduced by
It seems like $arguments can also be of type object<ArrayAccess>. However, the property $arguments 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...
24 5
    }
25
26
    public function offsetExists($offset)
27
    {
28
        return isset($this->arguments[$offset]);
29
    }
30
31
    public function offsetGet($offset)
32
    {
33
        return isset($this->arguments[$offset]) ? $this->arguments[$offset] : null;
34
    }
35
36
    public function offsetSet($offset, $value)
37
    {
38
        $this->arguments[$offset] = $value;
39
    }
40
41
    public function offsetUnset($offset)
42
    {
43
        unset($this->arguments[$offset]);
44
    }
45
46
    public function __get($key)
47
    {
48
        return $this->offsetGet($key);
49
    }
50
51
    public function __set($key, $value)
52
    {
53
        $this->offsetSet($key, $value);
54
    }
55
56
    public function getRawArguments()
57
    {
58
        return $this->arguments;
59
    }
60
61
    public function count()
62
    {
63
        return count($this->arguments);
64
    }
65
}
66