Use only arrays and scalar values as data and metadata in messages#304
Use only arrays and scalar values as data and metadata in messages#304vjik wants to merge 7 commits into
Conversation
vjik
commented
Jun 7, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ✔️ |
| Tests pass? | ✔️ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #304 +/- ##
========================================
Coverage 0.00% 0.00%
Complexity 330 330
========================================
Files 49 49
Lines 910 909 -1
========================================
+ Misses 910 909 -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 tightens the queue message contract so that message payload data and metadata are limited to scalars, null, and arrays (recursively), and it removes support for object-based metadata values (e.g., stringable objects used as IDs). This aligns message contents with serialization-friendly data shapes and makes the BC break explicit via PHP union types and updated Psalm annotations.
Changes:
- Restricts
MessageInterface::fromData()/getData()tobool|int|float|string|array|nulland documents the scalar/array-only constraint via Psalm types. - Updates core message/envelope implementations and test stubs to match the new
getData()return type. - Removes stringable-object ID support in
IdEnvelope(and its corresponding unit test) and hardensDelayEnvelope::fromMessage()against array metadata.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Support/TestMessage.php | Updates test message stub getData() return type to match the new message contract. |
| tests/Unit/Message/IdEnvelopeTest.php | Removes test coverage for stringable-object IDs to reflect the new metadata constraints. |
| src/Middleware/FailureHandling/FailureEnvelope.php | Narrows metadata shape in the envelope’s Psalm generic annotation. |
| src/Message/MessageInterface.php | Introduces scalar/array-only data contract with union types and Psalm type aliases/docs. |
| src/Message/IdEnvelope.php | Drops stringable-object ID handling and narrows envelope metadata generic annotation. |
| src/Message/GenericMessage.php | Updates constructor/data typing and imports Psalm type for the new message data contract. |
| src/Message/Envelope.php | Narrows envelope template constraint and getData() return type to match MessageInterface. |
| src/Message/DelayEnvelope.php | Narrows metadata generic annotation and avoids casting array metadata to float in fromMessage(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Represents a queue message with a type identifier, payload data, and metadata. | ||
| * | ||
| * @psalm-type MessageData = scalar|null|array<scalar|null|array> |
There was a problem hiding this comment.
Should it be recursive?
| * @psalm-type MessageData = scalar|null|array<scalar|null|array> | |
| * @psalm-type MessageData = scalar|null|array<array-key, MessageData> |
There was a problem hiding this comment.
It's not fixed in the messages-and-handlers.md as well. It still mentions objects.
There was a problem hiding this comment.
Should it be recursive?
Yes, but Psalm doesn't support recursive types.
There was a problem hiding this comment.
It's not fixed in the
messages-and-handlers.mdas well. It still mentions objects.
Fixed types. But I don't found objects usage in data or metadata...