From 046a034455a7c8e761ba15995494e3d564175b9c Mon Sep 17 00:00:00 2001 From: n0nag0n Date: Tue, 4 Mar 2025 07:20:07 -0700 Subject: [PATCH] prettified --- flight/core/EventDispatcher.php | 2 +- tests/EventSystemTest.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flight/core/EventDispatcher.php b/flight/core/EventDispatcher.php index 828388c..b80eb42 100644 --- a/flight/core/EventDispatcher.php +++ b/flight/core/EventDispatcher.php @@ -35,7 +35,7 @@ class EventDispatcher foreach ($this->listeners[$event] as $callback) { $result = call_user_func_array($callback, $args); - // If you return false, it will break the loop and stop the other event listeners. + // If you return false, it will break the loop and stop the other event listeners. if ($result === false) { break; // Stop executing further listeners } diff --git a/tests/EventSystemTest.php b/tests/EventSystemTest.php index 26d51e6..6dba2c7 100644 --- a/tests/EventSystemTest.php +++ b/tests/EventSystemTest.php @@ -195,7 +195,7 @@ class EventSystemTest extends TestCase Flight::onEvent('test.event', 'not_a_callable'); } - /** + /** * Test that event propagation stops if a listener returns false. */ public function testStopPropagation() @@ -203,23 +203,23 @@ class EventSystemTest extends TestCase $firstCalled = false; $secondCalled = false; $thirdCalled = false; - + Flight::onEvent('test.event', function () use (&$firstCalled) { $firstCalled = true; return true; // Continue propagation }); - + Flight::onEvent('test.event', function () use (&$secondCalled) { $secondCalled = true; return false; // Stop propagation }); - + Flight::onEvent('test.event', function () use (&$thirdCalled) { $thirdCalled = true; }); - + Flight::triggerEvent('test.event'); - + $this->assertTrue($firstCalled, 'First listener should be called'); $this->assertTrue($secondCalled, 'Second listener should be called'); $this->assertFalse($thirdCalled, 'Third listener should not be called after propagation stopped');