From 2e70ee0f59278e403578f99e2c1dbb0a2eb2b4f7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 8 Feb 2025 13:09:42 +0100 Subject: [PATCH] make newly added constructor argument optional As the PostRunEvent class is already present in Symfony since 6.4 we cannot add new mandatory constructor arguments without breaking backwards compatibility. --- Event/PostRunEvent.php | 2 +- Tests/EventListener/DispatchSchedulerEventListenerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Event/PostRunEvent.php b/Event/PostRunEvent.php index b7d7f93..39db81a 100644 --- a/Event/PostRunEvent.php +++ b/Event/PostRunEvent.php @@ -20,7 +20,7 @@ class PostRunEvent private readonly ScheduleProviderInterface $schedule, private readonly MessageContext $messageContext, private readonly object $message, - private readonly mixed $result, + private readonly mixed $result = null, ) { } diff --git a/Tests/EventListener/DispatchSchedulerEventListenerTest.php b/Tests/EventListener/DispatchSchedulerEventListenerTest.php index a1b023d..b0a1d3b 100644 --- a/Tests/EventListener/DispatchSchedulerEventListenerTest.php +++ b/Tests/EventListener/DispatchSchedulerEventListenerTest.php @@ -57,8 +57,8 @@ class DispatchSchedulerEventListenerTest extends TestCase $listener->onMessageFailed($workerFailedEvent); $this->assertInstanceOf(PreRunEvent::class, $secondListener->preRunEvent); - $this->assertSame('result', $secondListener->postRunEvent->getResult()); $this->assertInstanceOf(PostRunEvent::class, $secondListener->postRunEvent); + $this->assertSame('result', $secondListener->postRunEvent->getResult()); $this->assertInstanceOf(FailureEvent::class, $secondListener->failureEvent); $this->assertEquals(new \Exception('failed'), $secondListener->failureEvent->getError()); }