-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Fix middleware docblocks #28717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
namespace Symfony\Component\Messenger\Middleware; | ||
|
||
use Symfony\Component\Messenger\Envelope; | ||
use Symfony\Component\Messenger\EnvelopeAwareInterface; | ||
use Symfony\Component\Messenger\Exception\ValidationFailedException; | ||
use Symfony\Component\Messenger\Middleware\Configuration\ValidationConfiguration; | ||
|
@@ -28,6 +29,9 @@ public function __construct(ValidatorInterface $validator) | |
$this->validator = $validator; | ||
} | ||
|
||
/** | ||
* @param Envelope $envelope | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be backported to 4.1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to backport this, not worth it. |
||
public function handle($envelope, callable $next) | ||
{ | ||
$message = $envelope->getMessage(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about type-hinting the parameter instead and remove the docbloc instead?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it cannot have a type hint because messages can be any object (as per MiddlewareInterface), middlewares that expect the envelope to be passed need to implement the
EnvelopeAwareInterface
markerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, exactly, we can't typehint (as the interface does not have any). That's the subtlety of the
EnvelopeAwareInterface
. Having the PhpDoc "forces" your IDE to know about the right object it gets.