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.
Passed
Push — master ( 07b164...660df5 )
by Kristjan
36s
created

ChronoIterator::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace COG\ChronoShifter\Iterator;
4
5
use COG\ChronoShifter\Shifter\ChronoShifter;
6
7
/**
8
 * @author Kristjan Siimson <[email protected]>
9
 * @package Domain
10
 */
11
class ChronoIterator implements \Iterator
12
{
13
    /**
14
     * @var ChronoShifter
15
     */
16
    private $shifter;
17
18
    /**
19
     * @var string
20
     */
21
    private $date;
22
23
    /**
24
     * @var \DateTime
25
     */
26
    private $startDate;
27
28
    /**
29
     * @param ChronoShifter $shifter
30
     * @param string $date
31
     */
32 6
    public function __construct(ChronoShifter $shifter, $date = null)
33
    {
34 6
        $this->shifter = $shifter;
35 6
        $this->date = $this->startDate = $date;
0 ignored issues
show
Documentation Bug introduced by
It seems like $date can also be of type string. However, the property $startDate is declared as type object<DateTime>. 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...
36
37 6
        $this->rewind();
38 6
    }
39
40
    /**
41
     * @return \DateTime
42
     */
43 2
    public function current()
44
    {
45 2
        return $this->date;
46
    }
47
48
    /**
49
     * @return void
50
     */
51 6
    public function next()
52
    {
53 6
        $this->date = $this->shifter->shift($this->date);
54 6
    }
55
56
    /**
57
     * @return int
58
     */
59 1
    public function key()
60
    {
61 1
        return strtotime($this->date);
62
    }
63
64
    /**
65
     * @return boolean The return value will be casted to boolean and then evaluated.
66
     * Returns true on success or false on failure.
67
     */
68 2
    public function valid()
69
    {
70 2
        return true;
71
    }
72
73
    /**
74
     * @return void
75
     */
76 6
    public function rewind()
77
    {
78 6
        $this->date = $this->startDate;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->startDate of type object<DateTime> is incompatible with the declared type string of property $date.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
79 6
        $this->next();
80
    }
81
}