[#516] Standardize middleware validation rule signatures#517
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #517 +/- ##
=========================================
Coverage 90.87% 90.87%
Complexity 3070 3070
=========================================
Files 263 263
Lines 8100 8100
=========================================
Hits 7361 7361
Misses 739 739 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThis PR standardizes the ChangesMiddleware defineValidationRules Standardization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Module/Templates/DemoWeb/src/Middlewares/Password.php.tpl (1)
67-71:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix missing return type and return statement.
The
respondWithErrormethod is missing both the: Responsereturn type declaration and areturnstatement before theredirectWith()call. This is inconsistent with all other middleware templates in this PR (e.g., Forget, Resend, PostOwner, Comment) whererespondWithErrorconsistently declares: Responseand returns the redirect response. Without returning the response, the middleware error handling will not work correctly.🐛 Proposed fix
- protected function respondWithError(Request $request, $message) + protected function respondWithError(Request $request, $message): Response { session()->setFlash('error', $message); - redirectWith(base_url(true) . '/' . current_lang() . '/account-settings#account_password', $request->all()); + return redirectWith(base_url(true) . '/' . current_lang() . '/account-settings#account_password', $request->all()); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Module/Templates/DemoWeb/src/Middlewares/Password.php.tpl` around lines 67 - 71, The respondWithError method lacks the Response return type and does not return the redirect response; update the method signature to add ": Response" and prepend "return" to the redirectWith(...) call so that respondWithError(Request $request, $message): Response sets the flash (session()->setFlash('error', $message)) and returns the redirectWith(base_url(true) . '/' . current_lang() . '/account-settings#account_password', $request->all()) response, matching other middleware (e.g., Forget, Resend, PostOwner, Comment).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/Module/Templates/DemoWeb/src/Middlewares/Password.php.tpl`:
- Around line 67-71: The respondWithError method lacks the Response return type
and does not return the redirect response; update the method signature to add ":
Response" and prepend "return" to the redirectWith(...) call so that
respondWithError(Request $request, $message): Response sets the flash
(session()->setFlash('error', $message)) and returns the
redirectWith(base_url(true) . '/' . current_lang() .
'/account-settings#account_password', $request->all()) response, matching other
middleware (e.g., Forget, Resend, PostOwner, Comment).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 15b29b91-f274-4077-a412-f8f092b2a5a9
📒 Files selected for processing (20)
CHANGELOG.mdsrc/Module/Templates/DemoApi/src/Middlewares/Activate.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/BaseMiddleware.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Comment.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Editor.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Password.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Signup.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Update.php.tplsrc/Module/Templates/DemoApi/src/Middlewares/Verify.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Activate.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/BaseMiddleware.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Comment.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Editor.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Forget.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Password.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/PostOwner.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Resend.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Signup.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Update.php.tplsrc/Module/Templates/DemoWeb/src/Middlewares/Verify.php.tpl
Closes #516
Summary by CodeRabbit