Enforce no-Envelope contract for adapters and serializers#307
Closed
vjik wants to merge 1 commit into
Closed
Conversation
vjik
commented
Jun 11, 2026
Member
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ✔️ |
| Tests pass? | ✔️ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #307 +/- ##
========================================
Coverage 0.00% 0.00%
Complexity 330 330
========================================
Files 49 49
Lines 909 908 -1
========================================
+ Misses 909 908 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR enforces a “no-Envelope input” contract for adapters and the JSON serializer by shifting envelope-carried data into message metadata, and by updating docs/tests to reflect the new contract (BC-breaking).
Changes:
- Update unit tests and benchmarks to use
withMetadata()instead of stackingEnvelopewrappers. - Make
JsonMessageSerializer::serialize()always recordmessage-classas the concrete message class (no envelope unwrapping logic). - Update adapter/serializer interface documentation to state that inputs are never
Envelopeinstances; add push-path unwrapping inAdapterPushHandler.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Message/JsonMessageSerializerTest.php | Updates serializer tests to use metadata instead of envelopes; adds assertions for preserved metadata. |
| tests/Benchmark/QueueBench.php | Updates benchmark “consume mapping” fixture to serialize metadata directly instead of envelopes. |
| src/Middleware/Push/AdapterPushHandler.php | Unwraps envelopes before calling the adapter’s push() method. |
| src/Message/MessageSerializerInterface.php | Documents the no-Envelope input contract for serializers. |
| src/Message/JsonMessageSerializer.php | Removes envelope-specific class resolution when serializing. |
| src/Adapter/AdapterInterface.php | Documents the no-Envelope input contract for adapters and handler callbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+22
to
+24
| return $this->adapter->push( | ||
| $message instanceof Envelope ? $message->getMessage() : $message, | ||
| ); |
Comment on lines
+18
to
+23
| * Processes all messages that are currently in the queue. The message passed to the handler callback | ||
| * is guaranteed to not be an {@see Envelope} instance, only a plain {@see MessageInterface} with | ||
| * merged metadata from any wrapping envelopes. | ||
| * | ||
| * @param callable $handlerCallback The handler which will handle messages (never an {@see Envelope} instance). | ||
| * Returns `false` if it cannot continue handling messages. |
Comment on lines
+40
to
+45
| * Adds a message to the queue. The message is guaranteed to not be an {@see Envelope} instance, | ||
| * only a plain {@see MessageInterface} with merged metadata from any wrapping envelopes. | ||
| * | ||
| * @param MessageInterface $message The message to push. Never an {@see Envelope} instance. | ||
| * @return MessageInterface The message with any modifications made by the adapter. May be wrapped in | ||
| * an {@see Envelope} to carry additional metadata. |
Comment on lines
+52
to
+57
| * Listens to the queue and passes messages to the given handler as they become available. | ||
| * The message passed to the handler callback is guaranteed to not be an {@see Envelope} instance, | ||
| * only a plain {@see MessageInterface} with merged metadata from any wrapping envelopes. | ||
| * | ||
| * @param callable $handlerCallback The handler which will handle messages (never an {@see Envelope} instance). | ||
| * Returns `false` if it cannot continue handling messages. |
Comment on lines
+183
to
185
| $message = (new TestMessage()) | ||
| ->withMetadata(['id' => 1]); | ||
| $serializer = $this->createSerializer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.