Skip to content

[#511] Fix RouteBuilder post-group modifier chaining context#512

Merged
armanist merged 1 commit into
softberg:masterfrom
armanist:issue/511-routebuilder-post-group-chaining-clean
May 12, 2026
Merged

[#511] Fix RouteBuilder post-group modifier chaining context#512
armanist merged 1 commit into
softberg:masterfrom
armanist:issue/511-routebuilder-post-group-chaining-clean

Conversation

@armanist
Copy link
Copy Markdown
Member

@armanist armanist commented May 12, 2026

Closes #511

Summary by CodeRabbit

  • Bug Fixes

    • Improved route modifier chaining behavior on grouped routes, ensuring middlewares, rate limiting, and caching work correctly when applied in any order.
  • Tests

    • Added unit tests to verify modifier chaining on grouped routes in multiple combinations.

Review Change Stack

@armanist armanist added the bug Something isn't working label May 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83f140bc-a677-49f4-928e-c9bb7924c7cb

📥 Commits

Reviewing files that changed from the base of the PR and between eb8545f and d3b1abc.

📒 Files selected for processing (2)
  • src/Router/RouteBuilder.php
  • tests/Unit/Router/RouteBuilderTest.php

📝 Walkthrough

Walkthrough

RouteBuilder fixes internal state management to allow chaining multiple post-group modifiers on grouped routes without clearing $lastGroupRoutes after each call. Instead, the state is cleared at DSL boundaries and on new route creation. Three regression tests verify modifier chaining works in any order.

Changes

Post-group modifier chaining fix

Layer / File(s) Summary
State management refactoring in RouteBuilder
src/Router/RouteBuilder.php
group() now clears $lastGroupRoutes at the start; build() clears it at the end; middlewares(), cacheable(), and rateLimit() no longer reset the state after applying changes; addRoute() clears $lastGroupRoutes on new route creation to prevent stale state from persisting.
Regression tests for post-group modifier chaining
tests/Unit/Router/RouteBuilderTest.php
Added three tests verifying modifiers chain without errors in any order: middlewares→rateLimit, rateLimit→middlewares, and cacheable→rateLimit→middlewares. Each test asserts all grouped routes receive expected cache/rate/middleware settings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

bug

Suggested reviewers

  • andrey-smaelov

Poem

🐰 The chainable modifiers hop and play,
No more clearing state along the way,
Boundaries bound them, routes set free,
Fluent DSL flows with harmony! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing RouteBuilder post-group modifier chaining context to enable chainable modifiers like middlewares(), rateLimit(), and cacheable().
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #511: fixes post-group modifier chaining by resetting lastGroupRoutes state at DSL boundaries and route creation, implements all three test cases covering modifier combinations in both orders.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the RouteBuilder post-group modifier chaining bug: RouteBuilder.php state management changes and three new regression tests as specified in issue #511.

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

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

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.

@armanist armanist added this to the 3.0.0 milestone May 12, 2026
@armanist armanist requested a review from andrey-smaelov May 12, 2026 17:29
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #512   +/-   ##
=========================================
  Coverage     90.87%   90.87%           
  Complexity     3069     3069           
=========================================
  Files           263      263           
  Lines          8096     8096           
=========================================
  Hits           7357     7357           
  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.

@armanist armanist merged commit a194236 into softberg:master May 12, 2026
7 checks passed
@armanist armanist deleted the issue/511-routebuilder-post-group-chaining-clean branch May 12, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RouteBuilder post-group modifier chaining bug (middlewares, rateLimit, cacheable)

2 participants