Skip to content

[#516] Standardize middleware validation rule signatures#517

Merged
armanist merged 1 commit into
softberg:masterfrom
armanist:issue/516-middleware-void-signatures
May 13, 2026
Merged

[#516] Standardize middleware validation rule signatures#517
armanist merged 1 commit into
softberg:masterfrom
armanist:issue/516-middleware-void-signatures

Conversation

@armanist
Copy link
Copy Markdown
Member

@armanist armanist commented May 13, 2026

Closes #516

Summary by CodeRabbit

  • Chores
    • Standardized method signatures across middleware templates by adding explicit return type declarations for improved code consistency and type safety.

Review Change Stack

@armanist armanist added the enhancement New feature or request label May 13, 2026
@armanist armanist added this to the 3.0.0 milestone May 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.87%. Comparing base (ac34323) to head (a9b8ea6).

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.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

This PR standardizes the defineValidationRules(Request $request): void method signature across all DemoWeb and DemoApi middleware templates. The changes add explicit void return types to method declarations, reorder imports in DemoApi BaseMiddleware, and clean up multi-line method signature formatting in several DemoWeb templates.

Changes

Middleware defineValidationRules Standardization

Layer / File(s) Summary
Changelog documentation
CHANGELOG.md
Changelog entry documents standardization of defineValidationRules(Request $request): void across DemoWeb and DemoApi middleware templates.
DemoApi middleware templates standardization
src/Module/Templates/DemoApi/src/Middlewares/BaseMiddleware.php.tpl, Activate.php.tpl, Comment.php.tpl, Editor.php.tpl, Password.php.tpl, Signup.php.tpl, Update.php.tpl, Verify.php.tpl
All DemoApi middleware templates updated: BaseMiddleware reorders imports (introduces StatusCode) and formats respondWithError signature; all templates add explicit : void return type to defineValidationRules method.
DemoWeb middleware templates standardization
src/Module/Templates/DemoWeb/src/Middlewares/BaseMiddleware.php.tpl, Activate.php.tpl, Comment.php.tpl, Editor.php.tpl, Forget.php.tpl, Password.php.tpl, PostOwner.php.tpl, Resend.php.tpl, Signup.php.tpl, Update.php.tpl, Verify.php.tpl
All DemoWeb middleware templates updated: all add explicit : void return type to defineValidationRules method. Forget, Resend, and Update templates also reformat multi-line respondWithError method signatures to single-line declarations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

refactoring

Suggested reviewers

  • andrey-smaelov
  • live-soft
  • charoyan88

Poem

🐰 Middleware methods now align,
With void returns, crystal and fine!
From Demo to API, they all agree,
Type safety standardized, plain to see!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: standardizing middleware validation rule signatures across module templates.
Linked Issues check ✅ Passed All coding requirements from issue #516 are met: defineValidationRules methods across both DemoWeb and DemoApi templates consistently use the : void return type.
Out of Scope Changes check ✅ Passed All changes are within scope: only method signature updates to add : void return types and minor formatting adjustments to respondWithError signatures in middleware templates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Fix missing return type and return statement.

The respondWithError method is missing both the : Response return type declaration and a return statement before the redirectWith() call. This is inconsistent with all other middleware templates in this PR (e.g., Forget, Resend, PostOwner, Comment) where respondWithError consistently declares : Response and 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

📥 Commits

Reviewing files that changed from the base of the PR and between ac34323 and a9b8ea6.

📒 Files selected for processing (20)
  • CHANGELOG.md
  • src/Module/Templates/DemoApi/src/Middlewares/Activate.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/BaseMiddleware.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Comment.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Editor.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Password.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Signup.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Update.php.tpl
  • src/Module/Templates/DemoApi/src/Middlewares/Verify.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Activate.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/BaseMiddleware.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Comment.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Editor.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Forget.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Password.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/PostOwner.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Resend.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Signup.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Update.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Verify.php.tpl

@armanist armanist merged commit c236264 into softberg:master May 13, 2026
7 checks passed
@armanist armanist deleted the issue/516-middleware-void-signatures branch May 13, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize middleware defineValidationRules signatures in module templates

1 participant