Skip to content

Commit d7bcb75

Browse files
committed
Rector improvements
1 parent 3648f26 commit d7bcb75

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

system/Router/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request
165165
*/
166166
private function getAutoRouter(): AutoRouterInterface
167167
{
168-
if ($this->autoRouter === null) {
168+
if (!$this->autoRouter instanceof AutoRouterInterface) {
169169
$autoRoutesImproved = config(Feature::class)->autoRoutesImproved ?? false;
170170
if ($autoRoutesImproved) {
171171
assert($this->collection instanceof RouteCollection);

tests/system/Router/RoutingOptimizationTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CodeIgniter\Exceptions\PageNotFoundException;
1717
use CodeIgniter\HTTP\IncomingRequest;
1818
use CodeIgniter\HTTP\Method;
19+
use CodeIgniter\Router\Controllers\Mycontroller;
1920
use CodeIgniter\Test\CIUnitTestCase;
2021
use Config\Feature;
2122
use Config\Modules;
@@ -79,7 +80,7 @@ public function testAutoRoutingOnlyMode(): void
7980
$router = new Router($collection, $this->request);
8081
$router->handle('mycontroller');
8182

82-
$this->assertSame('\\CodeIgniter\\Router\\Controllers\\Mycontroller', $router->controllerName());
83+
$this->assertSame('\\' . Mycontroller::class, $router->controllerName());
8384
$this->assertSame('getIndex', $router->methodName());
8485
}
8586

@@ -150,7 +151,7 @@ public function testBothModesEnabled(): void
150151

151152
// Test fallback to auto-routing
152153
$router->handle('mycontroller');
153-
$this->assertSame('\\CodeIgniter\\Router\\Controllers\\Mycontroller', $router->controllerName());
154+
$this->assertSame(Mycontroller::class, $router->controllerName());
154155
$this->assertSame('getIndex', $router->methodName());
155156
}
156157

0 commit comments

Comments
 (0)