From 88654584545aab76b1d563f3a4afb64037f816b6 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 29 Nov 2020 22:36:55 -0600 Subject: [PATCH] throw is now an expression! --- lib/Internal/Placeholder.php | 6 ++---- lib/Internal/ResolutionQueue.php | 4 +--- test/DeferTest.php | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/Internal/Placeholder.php b/lib/Internal/Placeholder.php index 5e352d5..7e26081 100644 --- a/lib/Internal/Placeholder.php +++ b/lib/Internal/Placeholder.php @@ -58,10 +58,8 @@ final class Placeholder { try { $this->result = null; - } catch (\Throwable $e) { - Loop::defer(static function () use ($e): void { - throw $e; - }); + } catch (\Throwable $exception) { + Loop::defer(static fn() => throw $exception); } } diff --git a/lib/Internal/ResolutionQueue.php b/lib/Internal/ResolutionQueue.php index 0895977..f642097 100644 --- a/lib/Internal/ResolutionQueue.php +++ b/lib/Internal/ResolutionQueue.php @@ -71,9 +71,7 @@ final class ResolutionQueue Promise\rethrow($result); } } catch (\Throwable $exception) { - Loop::defer(static function () use ($exception): void { - throw $exception; - }); + Loop::defer(static fn() => throw $exception); } } } diff --git a/test/DeferTest.php b/test/DeferTest.php index e329c4f..c505ae7 100644 --- a/test/DeferTest.php +++ b/test/DeferTest.php @@ -18,11 +18,9 @@ class DeferTest extends AsyncTestCase $exception = new TestException; - defer(function () use ($exception): void { - throw $exception; - }); + defer(fn() => throw $exception); - delay(1); // Tick event loop. + delay(5); // Tick event loop. $this->assertSame($exception, $reason); }