1 | <?php |
||
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) |
|
39 | |||
40 | /** |
||
41 | * @return \DateTime |
||
42 | */ |
||
43 | 2 | public function current() |
|
47 | |||
48 | /** |
||
49 | * @return void |
||
50 | */ |
||
51 | 6 | public function next() |
|
55 | |||
56 | /** |
||
57 | * @return int |
||
58 | */ |
||
59 | 1 | public function key() |
|
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() |
|
72 | |||
73 | /** |
||
74 | * @return void |
||
75 | */ |
||
76 | 6 | public function rewind() |
|
81 | } |
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 theid
property of an instance of theAccount
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.