@@ -27,13 +27,13 @@ final class Loop
27
27
/**
28
28
* Set the factory to be used to create a default drivers.
29
29
*
30
- * Setting a factory is only allowed as long as no loop is currently running.
31
- * Passing null will reset the default driver and remove the factory.
30
+ * Setting a factory is only allowed as long as no loop is currently running. Passing null will reset the default
31
+ * driver and remove the factory.
32
32
*
33
33
* The factory will be invoked if none is passed to Loop::execute. A default driver will be created to support
34
34
* synchronous waits in traditional applications.
35
35
*
36
- * @param DriverFactory|null $factory
36
+ * @param DriverFactory|null $factory New factory to replace the previous one.
37
37
*/
38
38
public static function setFactory (DriverFactory $ factory = null )
39
39
{
@@ -42,13 +42,15 @@ public static function setFactory(DriverFactory $factory = null)
42
42
}
43
43
44
44
self ::$ factory = $ factory ;
45
- self ::$ driver = null ; // reset it here, it will be actually instantiated inside execute() or get()
45
+
46
+ // reset it here, it will be actually instantiated inside execute() or get()
47
+ self ::$ driver = null ;
46
48
}
47
49
48
50
/**
49
51
* Execute a callback within the scope of an event loop driver.
50
52
*
51
- * @param callable $callback The callback to execute
53
+ * @param callable $callback The callback to execute.
52
54
* @param Driver $driver The event loop driver. If null a new one is created from the set factory.
53
55
*
54
56
* @return void
@@ -72,7 +74,7 @@ public static function execute(callable $callback, Driver $driver = null)
72
74
/**
73
75
* Create a new driver if a factory is present, otherwise throw.
74
76
*
75
- * @throws \LogicException if no factory is set or no driver returned from factory
77
+ * @throws \LogicException If no factory is set or no driver returned from factory.
76
78
*/
77
79
private static function createDriver ()
78
80
{
@@ -100,6 +102,7 @@ public static function get()
100
102
if (self ::$ driver ) {
101
103
return self ::$ driver ;
102
104
}
105
+
103
106
return self ::$ driver = self ::createDriver ();
104
107
}
105
108
@@ -232,7 +235,7 @@ public static function enable($watcherId)
232
235
*
233
236
* @return void
234
237
*
235
- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
238
+ * @throws InvalidWatcherException If the watcher identifier is invalid.
236
239
*/
237
240
public static function disable ($ watcherId )
238
241
{
@@ -241,8 +244,8 @@ public static function disable($watcherId)
241
244
}
242
245
243
246
/**
244
- * Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After this
245
- * operation the watcher is permanently invalid.
247
+ * Cancel a watcher. This will detatch the event loop from all resources that are associated to the watcher. After
248
+ * this operation the watcher is permanently invalid.
246
249
*
247
250
* @param string $watcherId The watcher identifier.
248
251
*
@@ -264,7 +267,7 @@ public static function cancel($watcherId)
264
267
*
265
268
* @return void
266
269
*
267
- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
270
+ * @throws InvalidWatcherException If the watcher identifier is invalid.
268
271
*/
269
272
public static function reference ($ watcherId )
270
273
{
@@ -282,7 +285,7 @@ public static function reference($watcherId)
282
285
*
283
286
* @return void
284
287
*
285
- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
288
+ * @throws InvalidWatcherException If the watcher identifier is invalid.
286
289
*/
287
290
public static function unreference ($ watcherId )
288
291
{
@@ -328,7 +331,8 @@ public static function fetchState($key)
328
331
*
329
332
* Subsequent calls to this method will overwrite the previous handler.
330
333
*
331
- * @param callable(\Throwable|\Exception $error)|null $callback The callback to execute; null will clear the current handler.
334
+ * @param callable(\Throwable|\Exception $error)|null $callback The callback to execute; null will clear the current
335
+ * handler.
332
336
*
333
337
* @return void
334
338
*/
@@ -341,8 +345,7 @@ public static function setErrorHandler(callable $callback = null)
341
345
/**
342
346
* Retrieve an associative array of information about the event loop driver.
343
347
*
344
- * The returned array MUST contain the following data describing the driver's
345
- * currently registered watchers:
348
+ * The returned array MUST contain the following data describing the driver's currently registered watchers:
346
349
*
347
350
* [
348
351
* "defer" => ["enabled" => int, "disabled" => int],
@@ -354,8 +357,8 @@ public static function setErrorHandler(callable $callback = null)
354
357
* "watchers" => ["referenced" => int, "unreferenced" => int],
355
358
* ];
356
359
*
357
- * Implementations MAY optionally add more information in the array but
358
- * at minimum the above key => value format MUST always be provided.
360
+ * Implementations MAY optionally add more information in the array but at minimum the above key => value format
361
+ * MUST always be provided.
359
362
*
360
363
* @return array
361
364
*/
0 commit comments