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.

AnnotationBlock::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 12
loc 12
ccs 7
cts 7
cp 1
crap 1
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace PhpBoot\Annotation;
4
5
6 View Code Duplication
class AnnotationBlock implements \ArrayAccess
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
{
8
    /**
9
     * AnnotationBlock constructor.
10
     * @param string $name
11
     * @param string $summary
12
     * @param string $description
13
     * @param AnnotationTag[] $children
14
     * @param AnnotationBlock|null $parent
15
     */
16 21
    public function __construct($name='',
17
                                $summary='',
18
                                $description='',
19
                                $children=[],
20
                                $parent=null)
21
    {
22 21
        $this->name = $name;
23 21
        $this->summary = $summary;
24 21
        $this->description = $description;
25 21
        $this->children = $children;
26 21
        $this->parent = $parent;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parent can also be of type object<PhpBoot\Annotation\AnnotationBlock>. However, the property $parent is declared as type object<PhpBoot\Annotation\AnnotationTag>|null. 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...
27 21
    }
28
29
    /**
30
     * @var string
31
     */
32
    public $name = '';
33
    /**
34
     * @var string
35
     */
36
    public $summary = '';
37
    /**
38
     * @var string
39
     */
40
    public $description='';
41
    /**
42
     * @var AnnotationTag[]
43
     */
44
    public $children=[];
45
46
    /**
47
     * @var AnnotationTag|null
48
     */
49
    public $parent;
50
51
52 21
    public function offsetExists($offset)
53
    {
54 21
        return isset($this->$offset);
55
    }
56
57
58 21
    public function offsetGet($offset)
59
    {
60 21
        return $this->$offset;
61
    }
62
63
64
    public function offsetSet($offset, $value)
65
    {
66
        $this->$offset = $value;
67
    }
68
69
70
    public function offsetUnset($offset)
71
    {
72
        unset($this->$offset);
73
    }
74
}