Skip to content

Commit 7e0631c

Browse files
committed
refactor: rename method and variable names
1 parent e0e9531 commit 7e0631c

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ public function read(string $class, string $defaultController = 'Home', string $
6565
// Remove HTTP verb prefix.
6666
$methodInUri = lcfirst(substr($methodName, strlen($httpVerb)));
6767

68+
// Check if it is the default method.
6869
if ($methodInUri === $defaultMethod) {
69-
$routeWithoutController = $this->getRouteWithoutController(
70+
$routeForDefaultController = $this->getRouteForDefaultController(
7071
$classShortname,
7172
$defaultController,
7273
$classInUri,
@@ -75,8 +76,11 @@ public function read(string $class, string $defaultController = 'Home', string $
7576
$httpVerb
7677
);
7778

78-
if ($routeWithoutController !== []) {
79-
$output = [...$output, ...$routeWithoutController];
79+
if ($routeForDefaultController !== []) {
80+
// The controller is the default controller. It only
81+
// has a route for the default method. Other methods
82+
// will not be routed even if they exist.
83+
$output = [...$output, ...$routeForDefaultController];
8084

8185
continue;
8286
}
@@ -151,9 +155,11 @@ private function getUriByClass(string $classname): string
151155
}
152156

153157
/**
154-
* Gets a route without default controller.
158+
* Gets a route for the default controller.
159+
*
160+
* @phpstan-return list<array>
155161
*/
156-
private function getRouteWithoutController(
162+
private function getRouteForDefaultController(
157163
string $classShortname,
158164
string $defaultController,
159165
string $uriByClass,

0 commit comments

Comments
 (0)