Skip to content

Use only arrays and scalar values as data and metadata in messages#304

Open
vjik wants to merge 7 commits into
masterfrom
improve-message-interface
Open

Use only arrays and scalar values as data and metadata in messages#304
vjik wants to merge 7 commits into
masterfrom
improve-message-interface

Conversation

@vjik

@vjik vjik commented Jun 7, 2026

Copy link
Copy Markdown
Member
Q A
Is bugfix?
New feature?
Breaks BC? ✔️
Tests pass? ✔️

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (7bcbc2c) to head (129015c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Message/DelayEnvelope.php 0.00% 2 Missing ⚠️
src/Message/GenericMessage.php 0.00% 2 Missing ⚠️
src/Message/Envelope.php 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vjik vjik requested a review from a team June 7, 2026 14:07
@vjik vjik added the status:code review The pull request needs review. label Jun 7, 2026
@samdark samdark requested a review from Copilot June 7, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() to bool|int|float|string|array|null and 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 hardens DelayEnvelope::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.

Comment thread src/Message/MessageInterface.php
Comment thread src/Message/MessageInterface.php Outdated
/**
* Represents a queue message with a type identifier, payload data, and metadata.
*
* @psalm-type MessageData = scalar|null|array<scalar|null|array>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be recursive?

Suggested change
* @psalm-type MessageData = scalar|null|array<scalar|null|array>
* @psalm-type MessageData = scalar|null|array<array-key, MessageData>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not fixed in the messages-and-handlers.md as well. It still mentions objects.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be recursive?

Yes, but Psalm doesn't support recursive types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not fixed in the messages-and-handlers.md as well. It still mentions objects.

Fixed types. But I don't found objects usage in data or metadata...

@vjik vjik requested a review from samdark June 8, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants