Refactor middleware fallback handler#43
Conversation
olegbaturin
commented
Sep 7, 2025
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ✔️ |
| Fixed issues |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43 +/- ##
============================================
- Coverage 96.29% 91.78% -4.52%
+ Complexity 34 32 -2
============================================
Files 3 4 +1
Lines 81 73 -8
============================================
- Hits 78 67 -11
- Misses 3 6 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
update require-dev fix psalm
rename handler to action
|
Version with 'Handler' renamed to the 'Action'. |
|
The change is backwards compatibility breaking one. |
|
I'll update readme |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the middleware fallback handler in the RequestBodyParser package, changing from a boolean flag approach to a more flexible handler-based approach for managing parsing errors.
Key changes:
- Removed the
ignoreBadRequestBody()method and boolean flag pattern - Modified the
BadRequestHandlerInterfaceto acceptParserExceptiondirectly in thehandle()method - Updated constructor to require explicit
BadRequestHandlerInterfaceparameter instead of creating a default instance
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/RequestBodyParser.php | Refactored constructor and error handling logic, removed ignoreBadRequestBody() method |
| src/BadRequestHandlerInterface.php | Changed interface to pass exception directly to handle() method |
| src/BadRequestHandler.php | Updated to accept exception parameter in handle() method, removed immutable pattern |
| src/ParserException.php | Made the exception class final |
| tests/RequestBodyParsersTest.php | Updated tests to use new handler pattern and removed obsolete test methods |
| tests/BadRequestHandlerTest.php | Updated tests for new handler signature |
| tests/ConfigTest.php | Added new test for DI container configuration |
| config/di-web.php | Added DI configuration for default bad request handler |
| README.md | Updated documentation for new error handling approach |
| CHANGELOG.md | Added entry for the refactoring |
| composer.json | Added yiisoft/di dependency |
| psalm.xml | Updated configuration settings |
| phpunit.xml.dist | Added config directory to coverage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.