@@ -27,13 +27,13 @@ final class Loop
2727 /**
2828 * Set the factory to be used to create a default drivers.
2929 *
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.
3232 *
3333 * The factory will be invoked if none is passed to Loop::execute. A default driver will be created to support
3434 * synchronous waits in traditional applications.
3535 *
36- * @param DriverFactory|null $factory
36+ * @param DriverFactory|null $factory New factory to replace the previous one.
3737 */
3838 public static function setFactory (DriverFactory $ factory = null )
3939 {
@@ -42,13 +42,15 @@ public static function setFactory(DriverFactory $factory = null)
4242 }
4343
4444 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 ;
4648 }
4749
4850 /**
4951 * Execute a callback within the scope of an event loop driver.
5052 *
51- * @param callable $callback The callback to execute
53+ * @param callable $callback The callback to execute.
5254 * @param Driver $driver The event loop driver. If null a new one is created from the set factory.
5355 *
5456 * @return void
@@ -72,7 +74,7 @@ public static function execute(callable $callback, Driver $driver = null)
7274 /**
7375 * Create a new driver if a factory is present, otherwise throw.
7476 *
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.
7678 */
7779 private static function createDriver ()
7880 {
@@ -100,6 +102,7 @@ public static function get()
100102 if (self ::$ driver ) {
101103 return self ::$ driver ;
102104 }
105+
103106 return self ::$ driver = self ::createDriver ();
104107 }
105108
@@ -232,7 +235,7 @@ public static function enable($watcherId)
232235 *
233236 * @return void
234237 *
235- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
238+ * @throws InvalidWatcherException If the watcher identifier is invalid.
236239 */
237240 public static function disable ($ watcherId )
238241 {
@@ -241,8 +244,8 @@ public static function disable($watcherId)
241244 }
242245
243246 /**
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.
246249 *
247250 * @param string $watcherId The watcher identifier.
248251 *
@@ -264,7 +267,7 @@ public static function cancel($watcherId)
264267 *
265268 * @return void
266269 *
267- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
270+ * @throws InvalidWatcherException If the watcher identifier is invalid.
268271 */
269272 public static function reference ($ watcherId )
270273 {
@@ -282,7 +285,7 @@ public static function reference($watcherId)
282285 *
283286 * @return void
284287 *
285- * @throws InvalidWatcherException Thrown if the watcher identifier is invalid.
288+ * @throws InvalidWatcherException If the watcher identifier is invalid.
286289 */
287290 public static function unreference ($ watcherId )
288291 {
@@ -328,7 +331,8 @@ public static function fetchState($key)
328331 *
329332 * Subsequent calls to this method will overwrite the previous handler.
330333 *
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.
332336 *
333337 * @return void
334338 */
@@ -341,8 +345,7 @@ public static function setErrorHandler(callable $callback = null)
341345 /**
342346 * Retrieve an associative array of information about the event loop driver.
343347 *
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:
346349 *
347350 * [
348351 * "defer" => ["enabled" => int, "disabled" => int],
@@ -354,8 +357,8 @@ public static function setErrorHandler(callable $callback = null)
354357 * "watchers" => ["referenced" => int, "unreferenced" => int],
355358 * ];
356359 *
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.
359362 *
360363 * @return array
361364 */
0 commit comments