From 77a2e146815f77ac80703aa6e58bd874108b8645 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Mon, 9 Oct 2023 20:49:37 +0200 Subject: [PATCH] fix phpcs issues --- AltoRouter.php | 2 +- tests/AltoRouterTest.php | 25 +++++++------ tests/benchmark-parse-api.php | 66 +++++++++++++++++------------------ 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/AltoRouter.php b/AltoRouter.php index 31aa338..ff33398 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -233,7 +233,7 @@ class AltoRouter $match = strcmp($requestUrl, $route) === 0; } else { // Compare longest non-param string with url before moving on to regex - // Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241) + // Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241) if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) { continue; } diff --git a/tests/AltoRouterTest.php b/tests/AltoRouterTest.php index 86aa6fe..88dc21c 100644 --- a/tests/AltoRouterTest.php +++ b/tests/AltoRouterTest.php @@ -36,7 +36,7 @@ class SimpleTraversable implements Iterator { return $this->_position; } - public function next() : void + public function next() : void { ++$this->_position; } @@ -138,7 +138,7 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase */ public function testSetBasePath() { - $this->router->setBasePath('/some/path'); + $this->router->setBasePath('/some/path'); $this->assertEquals('/some/path', $this->router->getBasePath()); $this->router->setBasePath('/some/path'); @@ -514,18 +514,17 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase } public function testMatchWithSlashBeforeOptionalPart() - { - $this->router->map('GET', '/archives/[lmin:category]?', 'Article#archives'); - $expected = [ - 'target' => 'Article#archives', - 'params' => [], - 'name' => null - ]; + { + $this->router->map('GET', '/archives/[lmin:category]?', 'Article#archives'); + $expected = [ + 'target' => 'Article#archives', + 'params' => [], + 'name' => null + ]; - $this->assertEquals($expected, $this->router->match('/archives/', 'GET')); - $this->assertEquals($expected, $this->router->match('/archives', 'GET')); - - } + $this->assertEquals($expected, $this->router->match('/archives/', 'GET')); + $this->assertEquals($expected, $this->router->match('/archives', 'GET')); + } /** * @covers AltoRouter::addMatchTypes diff --git a/tests/benchmark-parse-api.php b/tests/benchmark-parse-api.php index 8cb3816..814f2cc 100644 --- a/tests/benchmark-parse-api.php +++ b/tests/benchmark-parse-api.php @@ -13,46 +13,46 @@ require __DIR__ . '/../vendor/autoload.php'; $routes = [ - ["POST", "/1/classes/[a:className]"], - ["GET", "/1/classes/[a:className]/[i:objectId]"], - ["PUT", "/1/classes/[a:className]/[i:objectId]"], - ["GET", "/1/classes/[a:className]"], - ["DELETE", "/1/classes/[a:className]/[i:objectId]"], + ["POST", "/1/classes/[a:className]"], + ["GET", "/1/classes/[a:className]/[i:objectId]"], + ["PUT", "/1/classes/[a:className]/[i:objectId]"], + ["GET", "/1/classes/[a:className]"], + ["DELETE", "/1/classes/[a:className]/[i:objectId]"], - // Users - ["POST", "/1/users"], - ["GET", "/1/login"], - ["GET", "/1/users/[i:objectId]"], - ["PUT", "/1/users/[i:objectId]"], - ["GET", "/1/users"], - ["DELETE", "/1/users/[i:objectId]"], - ["POST", "/1/requestPasswordReset"], + // Users + ["POST", "/1/users"], + ["GET", "/1/login"], + ["GET", "/1/users/[i:objectId]"], + ["PUT", "/1/users/[i:objectId]"], + ["GET", "/1/users"], + ["DELETE", "/1/users/[i:objectId]"], + ["POST", "/1/requestPasswordReset"], - // Roles - ["POST", "/1/roles"], - ["GET", "/1/roles/[i:objectId]"], - ["PUT", "/1/roles/[i:objectId]"], - ["GET", "/1/roles"], - ["DELETE", "/1/roles/[i:objectId]"], + // Roles + ["POST", "/1/roles"], + ["GET", "/1/roles/[i:objectId]"], + ["PUT", "/1/roles/[i:objectId]"], + ["GET", "/1/roles"], + ["DELETE", "/1/roles/[i:objectId]"], - // Files - ["POST", "/1/files/:fileName"], + // Files + ["POST", "/1/files/:fileName"], - // Analytics - ["POST", "/1/events/[a:eventName]"], + // Analytics + ["POST", "/1/events/[a:eventName]"], - // Push Notifications - ["POST", "/1/push"], + // Push Notifications + ["POST", "/1/push"], - // Installations - ["POST", "/1/installations"], - ["GET", "/1/installations/[i:objectId]"], - ["PUT", "/1/installations/[i:objectId]"], - ["GET", "/1/installations"], - ["DELETE", "/1/installations/[i:objectId]"], + // Installations + ["POST", "/1/installations"], + ["GET", "/1/installations/[i:objectId]"], + ["PUT", "/1/installations/[i:objectId]"], + ["GET", "/1/installations"], + ["DELETE", "/1/installations/[i:objectId]"], - // Cloud Functions - ["POST", "/1/functions"], + // Cloud Functions + ["POST", "/1/functions"], ]; $total_time = 0; $router = new AltoRouter();