1 | <?php |
||
18 | class DebuggerTimer |
||
19 | { |
||
20 | /** |
||
21 | * @var TimerPanel |
||
22 | */ |
||
23 | protected $panel; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $name; |
||
29 | |||
30 | /** |
||
31 | * @var float |
||
32 | */ |
||
33 | protected $delta; |
||
34 | |||
35 | /** |
||
36 | * @param TimerPanel $panel Debugger timer imer panel |
||
37 | * @param string|null $name Timer name |
||
38 | */ |
||
39 | public function __construct(TimerPanel $panel, string $name = null) |
||
44 | |||
45 | /** |
||
46 | * Return delta time |
||
47 | * |
||
48 | * @return float |
||
49 | */ |
||
50 | public function getDelta() : float |
||
54 | |||
55 | /** |
||
56 | * Set timer name |
||
57 | * |
||
58 | * Do not overrides. |
||
59 | * |
||
60 | * @param string|null $name |
||
61 | * @return $this |
||
62 | */ |
||
63 | public function setName(string $name = null) |
||
68 | |||
69 | /** |
||
70 | * Start the timer |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function start() |
||
79 | |||
80 | /** |
||
81 | * Stop the timer |
||
82 | * |
||
83 | * @param string $title Debugger bar timer value title |
||
84 | * @return float Delta time |
||
85 | */ |
||
86 | public function stop(string $title = null) : float |
||
92 | |||
93 | /** |
||
94 | * @return string |
||
95 | */ |
||
96 | public function __toString() |
||
100 | } |
||
101 |
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.