Skip to content

Refactor middleware fallback handler#43

Open
olegbaturin wants to merge 16 commits into
yiisoft:masterfrom
olegbaturin:refactor-middleware-fallback-handler
Open

Refactor middleware fallback handler#43
olegbaturin wants to merge 16 commits into
yiisoft:masterfrom
olegbaturin:refactor-middleware-fallback-handler

Conversation

@olegbaturin

Copy link
Copy Markdown
Q A
Is bugfix?
New feature?
Breaks BC? ✔️
Fixed issues

@codecov

codecov Bot commented Sep 7, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.78%. Comparing base (c7b850e) to head (cdaf6c6).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
config/di-web.php 0.00% 3 Missing ⚠️
src/RequestBodyParser.php 76.92% 3 Missing ⚠️
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.
📢 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.

@olegbaturin

Copy link
Copy Markdown
Author

Version with 'Handler' renamed to the 'Action'.

Comment thread src/Parser/JsonParser.php Outdated
Comment thread src/BadRequestAction.php Outdated
Comment thread config/di-web.php Outdated
@samdark samdark requested a review from vjik September 10, 2025 22:09
@samdark

samdark commented Sep 10, 2025

Copy link
Copy Markdown
Member

The change is backwards compatibility breaking one.

@olegbaturin

Copy link
Copy Markdown
Author

I'll update readme

@samdark samdark requested a review from Copilot September 29, 2025 22:23

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 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 BadRequestHandlerInterface to accept ParserException directly in the handle() method
  • Updated constructor to require explicit BadRequestHandlerInterface parameter 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.

Comment thread README.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants