From 857673b3c308b7d8d1b2f25a76946cf5135a77e3 Mon Sep 17 00:00:00 2001 From: Michal Sniatala Date: Sun, 17 Nov 2024 13:12:13 +0100 Subject: [PATCH] fix: code issues after merging develop (#9284) * cs-fix * fix services call * apply rector rules --- system/Commands/Utilities/Routes/FilterCollector.php | 4 ++-- system/Validation/StrictRules/FileRules.php | 2 +- tests/system/Database/Live/MySQLi/FoundRowsTest.php | 12 ++++++------ tests/system/Router/RouteCollectionTest.php | 4 ++-- tests/system/View/ViewTest.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/system/Commands/Utilities/Routes/FilterCollector.php b/system/Commands/Utilities/Routes/FilterCollector.php index 5a4e3d186940..17395d2f096a 100644 --- a/system/Commands/Utilities/Routes/FilterCollector.php +++ b/system/Commands/Utilities/Routes/FilterCollector.php @@ -109,7 +109,7 @@ public function getClasses(string $method, string $uri): array ]; } - $request = Services::incomingrequest(null, false); + $request = service('incomingrequest', null, false); $request->setMethod($method); $router = $this->createRouter($request); @@ -145,7 +145,7 @@ public function getRequiredFilters(): array */ public function getRequiredFilterClasses(): array { - $request = Services::incomingrequest(null, false); + $request = service('incomingrequest', null, false); $request->setMethod(Method::GET); $router = $this->createRouter($request); diff --git a/system/Validation/StrictRules/FileRules.php b/system/Validation/StrictRules/FileRules.php index e808d4b2a382..9176716ef561 100644 --- a/system/Validation/StrictRules/FileRules.php +++ b/system/Validation/StrictRules/FileRules.php @@ -38,7 +38,7 @@ class FileRules */ public function __construct(?RequestInterface $request = null) { - if ($request === null) { + if (! $request instanceof RequestInterface) { $request = service('request'); } diff --git a/tests/system/Database/Live/MySQLi/FoundRowsTest.php b/tests/system/Database/Live/MySQLi/FoundRowsTest.php index d5b88b49af28..b39f8999085d 100644 --- a/tests/system/Database/Live/MySQLi/FoundRowsTest.php +++ b/tests/system/Database/Live/MySQLi/FoundRowsTest.php @@ -81,7 +81,7 @@ public function testAffectedRowsAfterEnableFoundRowsWithNoChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 2); + $this->assertSame(2, $affectedRows); } public function testAffectedRowsAfterDisableFoundRowsWithNoChange(): void @@ -97,7 +97,7 @@ public function testAffectedRowsAfterDisableFoundRowsWithNoChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 0); + $this->assertSame(0, $affectedRows); } public function testAffectedRowsAfterEnableFoundRowsWithChange(): void @@ -113,7 +113,7 @@ public function testAffectedRowsAfterEnableFoundRowsWithChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 2); + $this->assertSame(2, $affectedRows); } public function testAffectedRowsAfterDisableFoundRowsWithChange(): void @@ -129,7 +129,7 @@ public function testAffectedRowsAfterDisableFoundRowsWithChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 2); + $this->assertSame(2, $affectedRows); } public function testAffectedRowsAfterEnableFoundRowsWithPartialChange(): void @@ -145,7 +145,7 @@ public function testAffectedRowsAfterEnableFoundRowsWithPartialChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 2); + $this->assertSame(2, $affectedRows); } public function testAffectedRowsAfterDisableFoundRowsWithPartialChange(): void @@ -161,6 +161,6 @@ public function testAffectedRowsAfterDisableFoundRowsWithPartialChange(): void $affectedRows = $db1->affectedRows(); - $this->assertSame($affectedRows, 1); + $this->assertSame(1, $affectedRows); } } diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index cde22e98b3b0..a8d74984d17c 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -1750,7 +1750,7 @@ public function testRouteMatchingHostMultipleCorrect(): void service('request')->setMethod(Method::GET); $routes = $this->getCollector(); - $router = new Router($routes, Services::request()); + $router = new Router($routes, service('request')); $routes->setDefaultNamespace('App\Controllers'); $routes->setDefaultController('Home'); @@ -1770,7 +1770,7 @@ public function testRouteMatchingHostMultipleFail(): void service('request')->setMethod(Method::GET); $routes = $this->getCollector(); - $router = new Router($routes, Services::request()); + $router = new Router($routes, service('request')); $routes->setDefaultNamespace('App\Controllers'); $routes->setDefaultController('Home'); diff --git a/tests/system/View/ViewTest.php b/tests/system/View/ViewTest.php index 7ec1adcbe80f..206cdc222d27 100644 --- a/tests/system/View/ViewTest.php +++ b/tests/system/View/ViewTest.php @@ -13,8 +13,8 @@ namespace CodeIgniter\View; -use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Autoloader\FileLocatorInterface; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; use Config;