Skip to content

Commit 826b083

Browse files
committed
Use try/finally to restore error handlers
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 418e5d5 commit 826b083

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Tests/EventListener/DebugHandlersListenerTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ public function testConfigure()
5050
try {
5151
$listener->configure();
5252
} catch (\Exception $exception) {
53+
} finally {
54+
restore_exception_handler();
55+
restore_error_handler();
5356
}
54-
restore_exception_handler();
55-
restore_error_handler();
5657

5758
if (null !== $exception) {
5859
throw $exception;
@@ -116,9 +117,10 @@ public function testConsoleEvent()
116117
try {
117118
$dispatcher->dispatch($event, ConsoleEvents::COMMAND);
118119
} catch (\Exception $exception) {
120+
} finally {
121+
restore_exception_handler();
122+
restore_error_handler();
119123
}
120-
restore_exception_handler();
121-
restore_error_handler();
122124

123125
if (null !== $exception) {
124126
throw $exception;

0 commit comments

Comments
 (0)