@@ -64,155 +64,162 @@ public static function stop()
64
64
/**
65
65
* Defer the execution of a callback.
66
66
*
67
- * @param callable $callback The callback to defer.
67
+ * @param callable(string $watcherId, mixed $data) $callback The callback to defer.
68
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
68
69
*
69
- * @return string An identifier that can be used to cancel, enable or disable the event .
70
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
70
71
*/
71
- public static function defer (callable $ callback )
72
+ public static function defer (callable $ callback, $ data = null )
72
73
{
73
- return self ::get ()->defer ($ callback );
74
+ return self ::get ()->defer ($ callback, $ data );
74
75
}
75
76
76
77
/**
77
78
* Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
78
79
*
79
- * @param callable $callback The callback to delay.
80
+ * @param callable(string $watcherId, mixed $data) $callback The callback to delay.
80
81
* @param int $time The amount of time, in milliseconds, to delay the execution for.
82
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
81
83
*
82
- * @return string An identifier that can be used to cancel, enable or disable the event .
84
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
83
85
*/
84
- public static function delay (callable $ callback , $ time )
86
+ public static function delay (callable $ callback , $ time, $ data = null )
85
87
{
86
- return self ::get ()->delay ($ callback , $ time );
88
+ return self ::get ()->delay ($ callback , $ time, $ data );
87
89
}
88
90
89
91
/**
90
92
* Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
91
93
*
92
- * @param callable $callback The callback to repeat.
94
+ * @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
93
95
* @param int $interval The time interval, in milliseconds, to wait between executions.
96
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
94
97
*
95
- * @return string An identifier that can be used to cancel, enable or disable the event .
98
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
96
99
*/
97
- public static function repeat (callable $ callback , $ interval )
100
+ public static function repeat (callable $ callback , $ interval, $ data = null )
98
101
{
99
- return self ::get ()->repeat ($ callback , $ interval );
102
+ return self ::get ()->repeat ($ callback , $ interval, $ data );
100
103
}
101
104
102
105
/**
103
106
* Execute a callback when a stream resource becomes readable.
104
107
*
105
108
* @param resource $stream The stream to monitor.
106
- * @param callable $callback The callback to execute.
109
+ * @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
110
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
107
111
*
108
- * @return string An identifier that can be used to cancel, enable or disable the event .
112
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
109
113
*/
110
- public static function onReadable ($ stream , callable $ callback )
114
+ public static function onReadable ($ stream , callable $ callback, $ data = null )
111
115
{
112
- return self ::get ()->onReadable ($ stream , $ callback );
116
+ return self ::get ()->onReadable ($ stream , $ callback, $ data );
113
117
}
114
118
115
119
/**
116
120
* Execute a callback when a stream resource becomes writable.
117
121
*
118
122
* @param resource $stream The stream to monitor.
119
- * @param callable $callback The callback to execute.
123
+ * @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
124
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
120
125
*
121
- * @return string An identifier that can be used to cancel, enable or disable the event .
126
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
122
127
*/
123
- public static function onWritable ($ stream , callable $ callback )
128
+ public static function onWritable ($ stream , callable $ callback, $ data = null )
124
129
{
125
- return self ::get ()->onWritable ($ stream , $ callback );
130
+ return self ::get ()->onWritable ($ stream , $ callback, $ data );
126
131
}
127
132
128
133
/**
129
134
* Execute a callback when a signal is received.
130
135
*
131
136
* @param int $signo The signal number to monitor.
132
- * @param callable $callback The callback to execute.
137
+ * @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.
138
+ * @param mixed $data Arbitrary data given to the callback function as the $data parameter.
133
139
*
134
- * @return string An identifier that can be used to cancel, enable or disable the event .
140
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
135
141
*/
136
- public static function onSignal ($ signo , callable $ callback )
142
+ public static function onSignal ($ signo , callable $ callback, $ data = null )
137
143
{
138
- return self ::get ()->onSignal ($ signo , $ callback );
144
+ return self ::get ()->onSignal ($ signo , $ callback, $ data );
139
145
}
140
146
141
147
/**
142
148
* Execute a callback when an error occurs.
143
149
*
144
- * @param callable $callback The callback to execute.
150
+ * @param callable(\Throwable|\Exception $exception) $callback The callback to execute.
145
151
*
146
- * @return string An identifier that can be used to cancel, enable or disable the event .
152
+ * @return string An identifier that can be used to cancel, enable or disable the watcher .
147
153
*/
148
154
public static function onError (callable $ callback )
149
155
{
150
156
return self ::get ()->onError ($ callback );
151
157
}
152
158
153
159
/**
154
- * Enable an event .
160
+ * Enable a watcher .
155
161
*
156
- * @param string $eventIdentifier The event identifier.
162
+ * @param string $watcherId The watcher identifier.
157
163
*
158
164
* @return void
159
165
*/
160
- public static function enable ($ eventIdentifier )
166
+ public static function enable ($ watcherId )
161
167
{
162
- self ::get ()->enable ($ eventIdentifier );
168
+ self ::get ()->enable ($ watcherId );
163
169
}
164
170
165
171
/**
166
- * Disable an event .
172
+ * Disable a watcher .
167
173
*
168
- * @param string $eventIdentifier The event identifier.
174
+ * @param string $watcherId The watcher identifier.
169
175
*
170
176
* @return void
171
177
*/
172
- public static function disable ($ eventIdentifier )
178
+ public static function disable ($ watcherId )
173
179
{
174
- self ::get ()->disable ($ eventIdentifier );
180
+ self ::get ()->disable ($ watcherId );
175
181
}
176
182
177
183
/**
178
- * Cancel an event .
184
+ * Cancel a watcher .
179
185
*
180
- * @param string $eventIdentifier The event identifier.
186
+ * @param string $watcherId The watcher identifier.
181
187
*
182
188
* @return void
183
189
*/
184
- public static function cancel ($ eventIdentifier )
190
+ public static function cancel ($ watcherId )
185
191
{
186
- self ::get ()->cancel ($ eventIdentifier );
192
+ self ::get ()->cancel ($ watcherId );
187
193
}
188
194
189
195
/**
190
- * Reference an event .
196
+ * Reference a watcher .
191
197
*
192
- * This will keep the event loop alive whilst the event is still being monitored. Events have this state by default.
198
+ * This will keep the event loop alive whilst the event is still being monitored. Watchers have this state by
199
+ * default.
193
200
*
194
- * @param string $eventIdentifier The event identifier.
201
+ * @param string $watcherId The watcher identifier.
195
202
*
196
203
* @return void
197
204
*/
198
- public static function reference ($ eventIdentifier )
205
+ public static function reference ($ watcherId )
199
206
{
200
- self ::get ()->reference ($ eventIdentifier );
207
+ self ::get ()->reference ($ watcherId );
201
208
}
202
209
203
210
/**
204
- * Unreference an event .
211
+ * Unreference a watcher .
205
212
*
206
- * The event loop should exit the run method when only unreferenced events are still being monitored. Events are all
207
- * referenced by default.
213
+ * The event loop should exit the run method when only unreferenced watchers are still being monitored. Events are
214
+ * all referenced by default.
208
215
*
209
- * @param string $eventIdentifier The event identifier.
216
+ * @param string $watcherId The watcher identifier.
210
217
*
211
218
* @return void
212
219
*/
213
- public static function unreference ($ eventIdentifier )
220
+ public static function unreference ($ watcherId )
214
221
{
215
- self ::get ()->unreference ($ eventIdentifier );
222
+ self ::get ()->unreference ($ watcherId );
216
223
}
217
224
218
225
/**
0 commit comments