Skip to content

Commit be1245f

Browse files
committed
refactor: remove comments that restate the code in checkRoutes()
The dropped comments only repeated what the following lines do. The ones that explain why the code works this way, including the metacharacter list and the trailing-LF fallback, are kept.
1 parent 08cbc30 commit be1245f

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

‎system/Router/Router.php‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ protected function checkRoutes(string $uri): bool
440440
? $uri
441441
: trim($uri, '/ ');
442442

443-
// Loop through the route array looking for wildcards
444443
foreach ($routes as $routeKey => $handler) {
445444
$routeKey = $routeKey === '/'
446445
? $routeKey
@@ -463,7 +462,6 @@ protected function checkRoutes(string $uri): bool
463462

464463
$matches = [$uri];
465464
} else {
466-
// Are we dealing with a locale?
467465
if (str_contains($routeKey, '{locale}')) {
468466
$routeKey = str_replace('{locale}', '[^/]+', $routeKey);
469467
}
@@ -473,7 +471,6 @@ protected function checkRoutes(string $uri): bool
473471
}
474472
}
475473

476-
// Is this route supposed to redirect to another?
477474
if ($this->collection->isRedirect($routeKey)) {
478475
// replacing matched route groups with references: post/([0-9]+) -> post/$1
479476
$redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function (): string {
@@ -508,13 +505,9 @@ protected function checkRoutes(string $uri): bool
508505
unset($matched);
509506
}
510507

511-
// Are we using Closures? If so, then we need
512-
// to collect the params into an array
513-
// so it can be passed to the controller method later.
514508
if (! is_string($handler) && is_callable($handler)) {
515509
$this->controller = $handler;
516510

517-
// Remove the original string from the matches array
518511
array_shift($matches);
519512

520513
$this->params = $matches;
@@ -531,19 +524,16 @@ protected function checkRoutes(string $uri): bool
531524
$methodAndParams = '';
532525
}
533526

534-
// Checks `/` in controller name
535527
if (str_contains($controller, '/')) {
536528
throw RouterException::forInvalidControllerName($handler);
537529
}
538530

539531
if (str_contains($handler, '$') && str_contains($routeKey, '(')) {
540-
// Checks dynamic controller
541532
if (str_contains($controller, '$')) {
542533
throw RouterException::forDynamicController($handler);
543534
}
544535

545536
if (config(Routing::class)->multipleSegmentsOneParam === false) {
546-
// Using back-references
547537
$segments = explode('/', preg_replace('#\A' . $routeKey . '\z#u', $handler, $uri));
548538
} else {
549539
if (str_contains($methodAndParams, '/')) {

0 commit comments

Comments
 (0)