Skip to content

Commit 3c97715

Browse files
committed
Fix: allow string keys in wrapped exceptions array
1 parent 8f2cd4a commit 3c97715

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/Unwrapper/Amp/AmpExceptionUnwrapper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use function array_map;
1212
use function array_merge;
13+
use function array_values;
1314

1415
final class AmpExceptionUnwrapper implements ExceptionUnwrapper
1516
{
@@ -25,9 +26,11 @@ public function unwrap(Throwable $exception): array
2526
return $this->innerUnwrapper->unwrap($exception);
2627
}
2728

29+
$wrappedExceptions = array_values($exception->getReasons());
30+
2831
$unwrapped = array_map(
2932
$this->outerUnwrapper->unwrap(...),
30-
$exception->getReasons(),
33+
$wrappedExceptions,
3134
);
3235

3336
return array_merge(...$unwrapped);

src/Unwrapper/Messenger/MessengerExceptionUnwrapper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use function array_map;
1212
use function array_merge;
13+
use function array_values;
1314

1415
final class MessengerExceptionUnwrapper implements ExceptionUnwrapper
1516
{
@@ -25,8 +26,8 @@ public function unwrap(Throwable $exception): array
2526
return $this->innerUnwrapper->unwrap($exception);
2627
}
2728

28-
/** @var non-empty-array<Throwable> $wrappedExceptions */
29-
$wrappedExceptions = $exception->getWrappedExceptions();
29+
/** @var non-empty-list<Throwable> $wrappedExceptions */
30+
$wrappedExceptions = array_values($exception->getWrappedExceptions());
3031

3132
$unwrappedExceptions = array_map(
3233
$this->outerUnwrapper->unwrap(...),

tests/Unwrapper/ExceptionUnwrapperUnitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public function testCompositeExceptionIsUnwrapped(): void
7575
new HandlerFailedException(
7676
Envelope::wrap(new stdClass()),
7777
[
78-
$exception1,
78+
'first' => $exception1,
7979
new CompositeException([
80-
$exception2,
80+
'second' => $exception2,
8181
]),
8282
],
8383
),

0 commit comments

Comments
 (0)