1 | <?php |
||
11 | class Timer |
||
12 | { |
||
13 | use \PHPDaemon\Traits\ClassWatchdog; |
||
14 | use \PHPDaemon\Traits\StaticObjectWatchdog; |
||
15 | use EventLoopContainer; |
||
16 | |||
17 | /** |
||
18 | * @var Timer[] List of timers |
||
19 | */ |
||
20 | protected static $list = []; |
||
21 | /** |
||
22 | * @var integer Counter |
||
23 | */ |
||
24 | protected static $counter = 1; |
||
25 | /** |
||
26 | * @var integer|null Timer id |
||
27 | */ |
||
28 | public $id; |
||
29 | /** |
||
30 | * @var integer Current timeout holder |
||
31 | */ |
||
32 | public $lastTimeout; |
||
33 | /** |
||
34 | * @var boolean Is the timer finished? |
||
35 | */ |
||
36 | public $finished = false; |
||
37 | /** |
||
38 | * @var callable Callback |
||
39 | */ |
||
40 | public $cb; |
||
41 | /** |
||
42 | * @var integer Priority |
||
43 | */ |
||
44 | public $priority; |
||
45 | /** |
||
46 | * @var \EventBufferEvent Event resource |
||
47 | */ |
||
48 | protected $ev; |
||
49 | |||
50 | /** |
||
51 | * Constructor |
||
52 | * @param callable $cb Callback |
||
53 | * @param integer $timeout Timeout |
||
|
|||
54 | * @param integer|string $id Timer ID |
||
55 | * @param integer $priority Priority |
||
56 | */ |
||
57 | public function __construct($cb, $timeout = null, $id = null, $priority = null) |
||
78 | |||
79 | /** |
||
80 | * Set prioriry |
||
81 | * @param integer $priority Priority |
||
82 | * @return void |
||
83 | */ |
||
84 | public function setPriority($priority) |
||
89 | |||
90 | /** |
||
91 | * Sets timeout |
||
92 | * @param integer $timeout Timeout |
||
93 | * @return void |
||
94 | */ |
||
95 | public function timeout($timeout = null) |
||
102 | |||
103 | /** |
||
104 | * Adds timer |
||
105 | * @param callable $cb Callback |
||
106 | * @param integer $timeout Timeout |
||
107 | * @param integer|string $id Timer ID |
||
108 | * @param integer $priority Priority |
||
109 | * @return integer|string Timer ID |
||
110 | */ |
||
111 | public static function add($cb, $timeout = null, $id = null, $priority = null) |
||
116 | |||
117 | /** |
||
118 | * Sets timeout |
||
119 | * @param integer|string $id Timer ID |
||
120 | * @param integer $timeout Timeout |
||
121 | * @return boolean |
||
122 | */ |
||
123 | public static function setTimeout($id, $timeout = null) |
||
131 | |||
132 | /** |
||
133 | * Removes timer by ID |
||
134 | * @param integer|string $id Timer ID |
||
135 | * @return void |
||
136 | */ |
||
137 | public static function remove($id) |
||
143 | |||
144 | /** |
||
145 | * Frees the timer |
||
146 | * @return void |
||
147 | */ |
||
148 | public function free() |
||
156 | |||
157 | /** |
||
158 | * Cancels timer by ID |
||
159 | * @param integer|string $id Timer ID |
||
160 | * @return void |
||
161 | */ |
||
162 | public static function cancelTimeout($id) |
||
168 | |||
169 | /** |
||
170 | * Cancels timer |
||
171 | * @return void |
||
172 | */ |
||
173 | public function cancel() |
||
177 | |||
178 | /** |
||
179 | * Called when timer is triggered |
||
180 | * @return void |
||
181 | */ |
||
182 | public function eventCall() |
||
192 | |||
193 | /** |
||
194 | * Finishes timer |
||
195 | * @return void |
||
196 | */ |
||
197 | public function finish() |
||
201 | |||
202 | /** |
||
203 | * Destructor |
||
204 | * @return void |
||
205 | */ |
||
206 | public function __destruct() |
||
210 | } |
||
211 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.