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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 64.71%

Importance

Changes 0
Metric Value
dl 69
loc 69
ccs 11
cts 17
cp 0.6471
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 12 12 1
A offsetExists() 4 4 1
A offsetGet() 4 4 1
A offsetSet() 4 4 1
A offsetUnset() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}