Change 'body' property of Message to accept any iterable #2

Closed
opened 2026-04-26 09:13:09 +02:00 by c.fahner · 0 comments
Owner

The $body property of the Message interface currently requires a specific class implementation of Stringable&Traversable. The Stringable type was initially added for convenience, to be able to treat the message body as any regular string. However, the problem being solved - concatenating a Traversable<Stringable|string> without an additional function invocation - is too trivial to burden all implementations of one of the main interfaces of the library with. The property should also just have a single responsibility, holding the chunked message body, and not also being responsible for its representation / output.

This issue changes the Message::$body property to accept any iterable<Stringable|string> directly, removing the need to write the same __toString() method for every implementation.

The `$body` property of the `Message` interface currently requires a specific class implementation of `Stringable&Traversable`. The `Stringable` type was initially added for convenience, to be able to treat the message body as any regular string. However, the problem being solved - concatenating a `Traversable<Stringable|string>` without an additional function invocation - is too trivial to burden all implementations of one of the main interfaces of the library with. The property should also just have a single responsibility, holding the chunked message body, and not also being responsible for its representation / output. This issue changes the `Message::$body` property to accept any `iterable<Stringable|string>` directly, removing the need to write the same `__toString()` method for every implementation.
c.fahner added this to the v0.2 milestone 2026-04-26 09:13:09 +02:00
c.fahner stopped working 2026-04-26 14:57:53 +02:00
9 minutes 1 second
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 9 minutes 1 second
c.fahner
9 minutes 1 second
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
slendium/http#2
No description provided.