refactor: extract DefinedRouteCollector - #7653
Conversation
d12c63b to
6f0d950
Compare
| /** | ||
| * Collect all defined routes for display. | ||
| */ | ||
| class DefinedRouteCollector |
There was a problem hiding this comment.
is this intended to be extended? can this be made final?
| return (new RouteCollection($loader, $moduleConfig, new Routing()))->setHTTPVerb('get'); | ||
| } | ||
|
|
||
| public function test() |
There was a problem hiding this comment.
Please make this test name descriptive. If using --test-dox option this test will have an empty name.
There was a problem hiding this comment.
I forgot to rename it. Done.
| $this->routeCollection = $routes; | ||
| } | ||
|
|
||
| public function collect(): Generator |
There was a problem hiding this comment.
Can you add the signature of the Generator in the PHPDoc so that it can be used by IDEs?
There was a problem hiding this comment.
That sig begs the question: is it worth introducing a value object at some point for better definition?
There was a problem hiding this comment.
The data structure of a route is complex, so it would be easier to understand if it were a class.
|
PHPStan is unhappy. |
See #7649 |
|
in addition to this when a new RouteCollection library is created implementing the RouteCollectionInterface this throw an exception of CodeIgniter\Router\DefinedRouteCollector::__construct(): Argument #1 ($routes) must be of type CodeIgniter\Router\RouteCollection, App\Libraries\Routing\RouteCollection given, called in C:\laragon\www\sebaadev\system\Debug\Toolbar\Collectors\Routes.php on line 103@kenji I suggest you replace I edited the core code of DefinedRouteCollector to this and it worked private RouteCollectionInterface $routeCollection;
public function __construct(RouteCollectionInterface $routes)
{
$this->routeCollection = $routes;
} |
|
@ChibuezeAgwuDennis We can't. Because |
Okay i understand but it can be fixed since |
Description
Checklist: