Conversation
# Conflicts: # src/Modern/Middleware/DataResponseFormatter.php
There was a problem hiding this comment.
Pull request overview
This PR introduces a major refactoring that replaces the old DataResponse approach with a new DataStream concept for handling HTTP response data. The refactoring provides a more flexible and modern approach to data formatting with lazy evaluation and better separation of concerns.
Changes:
- Introduces
DataStreamandStringStreamclasses for lazy data formatting - Adds new
FormatterInterfacewith implementations for JSON, XML, HTML, and plain text formats - Creates response factory classes that produce PSR-7 responses with
DataStreambodies - Implements middleware for applying formatters to responses
- Adds content negotiation support via middleware and response factories
- Deprecates all old
DataResponse-based classes with appropriate migration paths
Reviewed changes
Copilot reviewed 66 out of 66 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/DataStream/DataStream.php | Core lazy stream implementation that formats data on read |
| src/DataStream/StringStream.php | Read-only string stream for formatted content |
| src/Formatter/FormatterInterface.php | New interface for data formatters |
| src/Formatter/JsonFormatter.php | JSON data formatter implementation |
| src/Formatter/XmlFormatter.php | XML data formatter implementation |
| src/Formatter/HtmlFormatter.php | HTML data formatter implementation |
| src/Formatter/PlainTextFormatter.php | Plain text formatter implementation |
| src/Formatter/DataEncodingException.php | Exception for data encoding failures |
| src/ResponseFactory/DataResponseFactoryInterface.php | Interface for response factories |
| src/ResponseFactory/DataResponseFactory.php | Creates responses without predefined formatter |
| src/ResponseFactory/AbstractFormattedResponseFactory.php | Base class for formatted response factories |
| src/ResponseFactory/JsonResponseFactory.php | JSON response factory |
| src/ResponseFactory/XmlResponseFactory.php | XML response factory |
| src/ResponseFactory/HtmlResponseFactory.php | HTML response factory |
| src/ResponseFactory/PlainTextResponseFactory.php | Plain text response factory |
| src/ResponseFactory/ContentNegotiatorResponseFactory.php | Content negotiation for response factories |
| src/Middleware/AbstractDataResponseMiddleware.php | Base middleware for applying formatters |
| src/Middleware/DataResponseMiddleware.php | Custom formatter middleware |
| src/Middleware/JsonDataResponseMiddleware.php | JSON formatting middleware |
| src/Middleware/XmlDataResponseMiddleware.php | XML formatting middleware |
| src/Middleware/HtmlDataResponseMiddleware.php | HTML formatting middleware |
| src/Middleware/PlainTextDataResponseMiddleware.php | Plain text formatting middleware |
| src/Middleware/ContentNegotiatorDataResponseMiddleware.php | Content negotiation middleware |
| src/NotAcceptableRequestHandler.php | Returns 406 response for unacceptable content types |
| tests/* | Comprehensive test coverage for all new functionality |
| docs/deprecated.md | Documentation for deprecated classes |
| README.md | Updated usage documentation |
| CHANGELOG.md | Documents the new features and deprecations |
| config/di-web.php | DI container configuration updates |
| composer.json | Dependency and script updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 66 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 66 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 66 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private ?FormatterInterface $formatter = null, | ||
| private readonly FormatterInterface $fallbackFormatter = new HtmlFormatter(), |
There was a problem hiding this comment.
That looks a bit weird to me. What's the use case for when $fallbackFormatter is changed but $formatter is not set?
There was a problem hiding this comment.
Fallback formatter is set only in the constructor and never changed.
Fallback formatter is used on read stream content in cases where formatter isn't set for a data stream.
No description provided.