Fix #193: Add public constructors for routes and groups - #295
Conversation
method-specific route classes
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #295 +/- ##
========================================
Coverage 0.00% 0.00%
- Complexity 129 140 +11
========================================
Files 13 20 +7
Lines 400 493 +93
========================================
- Misses 400 493 +93 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR implements issue #193 by making Route and Group constructible via public constructors (supporting named arguments) and introducing method-specific route classes (e.g., Get, Post) to reduce bootstrap-time object churn while keeping the existing static factories and fluent immutable API.
Changes:
- Make
RouteandGroupconstructors public and accept full configuration via named arguments. - Add
Yiisoft\Router\Route\MethodRouteplus concrete HTTP method route classes (Get,Post,Put,Delete,Patch,Head,Options). - Extend tests and documentation to cover / describe constructor-based configuration and new route classes.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/RouteTest.php | Adds coverage for the new Route constructor and method-specific route classes. |
| tests/GroupTest.php | Adds coverage for the new Group constructor behavior (hosts/middlewares/CORS). |
| src/Route.php | Makes Route non-final and introduces a public constructor accepting full configuration. |
| src/Group.php | Adds a public constructor accepting full configuration (routes, middleware, hosts, etc.). |
| src/Route/MethodRoute.php | Introduces a base class for method-specific routes that preconfigures methods. |
| src/Route/Get.php | Adds GET-specific route class. |
| src/Route/Post.php | Adds POST-specific route class. |
| src/Route/Put.php | Adds PUT-specific route class. |
| src/Route/Delete.php | Adds DELETE-specific route class. |
| src/Route/Patch.php | Adds PATCH-specific route class. |
| src/Route/Head.php | Adds HEAD-specific route class. |
| src/Route/Options.php | Adds OPTIONS-specific route class. |
| README.md | Documents constructor-based configuration and method-specific route classes. |
| CHANGELOG.md | Adds an entry for the new feature under 4.0.3. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
method-specific route classes