From 8ee7d61452e716f8bed31c1835054c12900af8e1 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 7 Oct 2020 22:52:23 -0500 Subject: [PATCH] Remove registry data and error handler when clearing loop --- lib/Loop/Driver.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Loop/Driver.php b/lib/Loop/Driver.php index 09524b2..d08fcb3 100644 --- a/lib/Loop/Driver.php +++ b/lib/Loop/Driver.php @@ -37,7 +37,7 @@ abstract class Driver implements \FiberScheduler private array $nextTickQueue = []; /** @var callable(\Throwable):void|null */ - private $errorHandler; + private $errorHandler = null; /** @var mixed[] */ private array $registry = []; @@ -645,14 +645,17 @@ abstract class Driver implements \FiberScheduler } /** - * Removes all watchers from the event loop. This method is intended for clearing the loop between - * tests and not intended for use in an application. + * Removes all watchers, registry data, and error handler from the event loop. This method is intended for + * clearing the loop between tests and not intended for use in an application. */ final public function clear(): void { foreach ($this->watchers as $watcher) { $this->cancel($watcher->id); } + + $this->registry = []; + $this->errorHandler = null; } /**