Skip to content

Commit 8d96608

Browse files
bug symfony#58090 [Messenger] Fix conditional type on WrappedExceptionsInterface (derrabus)
This PR was merged into the 7.2 branch. Discussion ---------- [Messenger] Fix conditional type on WrappedExceptionsInterface | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#58066 (comment) | License | MIT This PR replaces symfony#58068 with a simpler version that still fixes the issue that symfony#58066 caused. Conditional return types that refer to arguments (here: `$class`) instead of template types are supported by both major static analysis tools: * https://phpstan.org/r/2bb3f152-3325-4618-a9b2-5470806edc9c * https://psalm.dev/r/d62bb4307d Commits ------- defa371 [Messenger] Fix conditional type on WrappedExceptionsInterface
2 parents e314213 + defa371 commit 8d96608

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Symfony/Component/Messenger/Exception/WrappedExceptionsInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
interface WrappedExceptionsInterface extends \Throwable
2020
{
2121
/**
22-
* @template TClass of class-string<\Throwable>
22+
* @template TException of \Throwable
2323
*
24-
* @param TClass|null $class
24+
* @param class-string<TException>|null $class
2525
*
2626
* @return \Throwable[]
2727
*
28-
* @psalm-return (TClass is null ? \Throwable[] : TClass[])
28+
* @psalm-return ($class is null ? \Throwable[] : TException[])
2929
*/
3030
public function getWrappedExceptions(?string $class = null, bool $recursive = false): array;
3131
}

src/Symfony/Component/Messenger/Exception/WrappedExceptionsTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ trait WrappedExceptionsTrait
2121
private array $exceptions;
2222

2323
/**
24-
* @template TClass of class-string<\Throwable>
24+
* @template TException of \Throwable
2525
*
26-
* @param TClass|null $class
26+
* @param class-string<TException>|null $class
2727
*
2828
* @return \Throwable[]
2929
*
30-
* @psalm-return (TClass is null ? \Throwable[] : TClass[])
30+
* @psalm-return ($class is null ? \Throwable[] : TException[])
3131
*/
3232
public function getWrappedExceptions(?string $class = null, bool $recursive = false): array
3333
{

0 commit comments

Comments
 (0)