@@ -129,10 +129,14 @@ public static function stop()
129129 /**
130130 * Defer the execution of a callback.
131131 *
132- * @param callable(string $watcherId, mixed $data) $callback The callback to defer.
132+ * The deferred callable MUST be executed in the next tick of the event loop and before any other type of watcher.
133+ * Order of enabling MUST be preserved when executing the callbacks.
134+ *
135+ * @param callable(string $watcherId, mixed $data) $callback The callback to defer. The `$watcherId` will be
136+ * invalidated before the callback call.
133137 * @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
134138 *
135- * @return string An identifier that can be used to cancel, enable or disable the watcher.
139+ * @return string An unique identifier that can be used to cancel, enable or disable the watcher.
136140 */
137141 public static function defer (callable $ callback , $ data = null )
138142 {
@@ -143,13 +147,15 @@ public static function defer(callable $callback, $data = null)
143147 /**
144148 * Delay the execution of a callback.
145149 *
146- * The delay is a minimum and approximate, accuracy is not guaranteed.
150+ * The delay is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be determined by which
151+ * timers expire first, but timers with the same expiration time MAY be executed in any order.
147152 *
148- * @param int $time The amount of time, in milliseconds, to delay the execution for.
149- * @param callable(string $watcherId, mixed $data) $callback The callback to delay.
153+ * @param int $delay The amount of time, in milliseconds, to delay the execution for.
154+ * @param callable(string $watcherId, mixed $data) $callback The callback to delay. The `$watcherId` will be
155+ * invalidated before the callback call.
150156 * @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
151157 *
152- * @return string An identifier that can be used to cancel, enable or disable the watcher.
158+ * @return string An unique identifier that can be used to cancel, enable or disable the watcher.
153159 */
154160 public static function delay ($ time , callable $ callback , $ data = null )
155161 {
@@ -160,14 +166,15 @@ public static function delay($time, callable $callback, $data = null)
160166 /**
161167 * Repeatedly execute a callback.
162168 *
163- * The interval between executions is a minimum and approximate, accuracy is not guaranteed.
169+ * The interval between executions is a minimum and approximate, accuracy is not guaranteed. Order of calls MUST be
170+ * determined by which timers expire first, but timers with the same expiration time MAY be executed in any order.
164171 * The first execution is scheduled after the first interval period.
165172 *
166173 * @param int $interval The time interval, in milliseconds, to wait between executions.
167174 * @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
168175 * @param mixed $data Arbitrary data given to the callback function as the `$data` parameter.
169176 *
170- * @return string An identifier that can be used to cancel, enable or disable the watcher.
177+ * @return string An unique identifier that can be used to cancel, enable or disable the watcher.
171178 */
172179 public static function repeat ($ interval , callable $ callback , $ data = null )
173180 {
@@ -179,11 +186,11 @@ public static function repeat($interval, callable $callback, $data = null)
179186 * Execute a callback when a stream resource becomes readable or is closed for reading.
180187 *
181188 * Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
182- * watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
189+ * watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
183190 * resources, but are not required to, due to the high performance impact. Watchers on closed resources are
184191 * therefore undefined behavior.
185192 *
186- * Multiple watchers on the same stream may be executed in any order.
193+ * Multiple watchers on the same stream MAY be executed in any order.
187194 *
188195 * @param resource $stream The stream to monitor.
189196 * @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -201,11 +208,11 @@ public static function onReadable($stream, callable $callback, $data = null)
201208 * Execute a callback when a stream resource becomes writable or is closed for writing.
202209 *
203210 * Warning: Closing resources locally, e.g. with `fclose`, might not invoke the callback. Be sure to `cancel` the
204- * watcher when closing the resource locally. Drivers may choose to notify the user if there are watchers on invalid
211+ * watcher when closing the resource locally. Drivers MAY choose to notify the user if there are watchers on invalid
205212 * resources, but are not required to, due to the high performance impact. Watchers on closed resources are
206213 * therefore undefined behavior.
207214 *
208- * Multiple watchers on the same stream may be executed in any order.
215+ * Multiple watchers on the same stream MAY be executed in any order.
209216 *
210217 * @param resource $stream The stream to monitor.
211218 * @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
@@ -223,10 +230,10 @@ public static function onWritable($stream, callable $callback, $data = null)
223230 * Execute a callback when a signal is received.
224231 *
225232 * Warning: Installing the same signal on different instances of this interface is deemed undefined behavior.
226- * Implementations may try to detect this, if possible, but are not required to. This is due to technical
233+ * Implementations MAY try to detect this, if possible, but are not required to. This is due to technical
227234 * limitations of the signals being registered globally per process.
228235 *
229- * Multiple watchers on the same signal may be executed in any order.
236+ * Multiple watchers on the same signal MAY be executed in any order.
230237 *
231238 * @param int $signo The signal number to monitor.
232239 * @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.
0 commit comments