New syntax - #225
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #225 +/- ##
=========================================
Coverage 0.00% 0.00%
- Complexity 129 201 +72
=========================================
Files 13 15 +2
Lines 400 544 +144
=========================================
- Misses 400 544 +144 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR SummaryThis pull request introduces numerous updates aimed at better organizing and streamlining how routes are handled in the system:
These changes all contribute to a more robust and efficient route handling system within the software, aligning the codebase with modern best practices in PHP coding. |
We can mention it in docs or drop the current syntax.
Yes, doesn't fix directly. Since there is no exception, there is no need for it. |
But what goal of syntax change? |
vjik
left a comment
There was a problem hiding this comment.
Can we make Route and Group constructors public and keep BC?
I think, GroupBuilder and RouteBuilder are not needed.
Did you mean builders? Route and Group constructors are public in this PR.
Will we abandon the current syntax? |
No, I mean
Mark as deprecated, then remove in major version. |
Let's abandon right away since the PR has major changes. |
…ray_is_list, and apply readonly properties
What major changes are needed? |
# Conflicts: # composer.json # src/Debug/DebugRoutesCommand.php # src/Route.php
…on, and apply `readonly` for constructor injection
…dlewares and adjust defaults assignment logic
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@rustamwin resolving of conflicts is needed. |
|
I also think we can keep backwards compatibility and mark some methods as deprecated but not sure it's needed. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated no new comments.
Suppressed comments (4)
src/Debug/RouterCollector.php:92
- Same as above:
hostscurrently returns an imploded string. Prefer returning the host list for a clearer debug data shape.
'hosts' => implode(', ', $route->getHosts()),
src/Builder/GroupBuilder.php:59
routes()assigns the variadic$routesarray directly, which preserves named-argument keys (e.g.routes(a: $r1, b: $r2)) and can yield a non-list array in the resultingGroup. Normalize to a list witharray_values()to keep ordering predictable and consistent with other variadic APIs here (e.g.middleware()/prependMiddleware()usearray_values()).
public function routes(Group|Route|RoutableInterface ...$routes): self
{
$new = clone $this;
$new->routes = $routes;
return $new;
src/Group.php:121
setRoutes()stores the provided array as-is. If callers pass an associative array (or if a builder/variadic call preserves named-argument keys),getRoutes()will no longer be a list and indexing like$group->getRoutes()[0]can break. Consider normalizing witharray_values()when assigning.
public function setRoutes(array $routes): self
{
$this->assertRoutes($routes);
$this->routes = $routes;
return $this;
src/Debug/RouterCollector.php:59
- The
currentRoute.hostsfield name is plural, but the value is a comma-separated string. Returning the actual host list makes the collected data less ambiguous (and avoids''vsnullwhen there are no hosts).
This issue also appears on line 92 of the same file.
'hosts' => implode(', ', $route->getHosts()),
Current syntax