mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-08-04 23:47:30 +02:00
fix phpcs issues
This commit is contained in:
@@ -233,7 +233,7 @@ class AltoRouter
|
|||||||
$match = strcmp($requestUrl, $route) === 0;
|
$match = strcmp($requestUrl, $route) === 0;
|
||||||
} else {
|
} else {
|
||||||
// Compare longest non-param string with url before moving on to regex
|
// 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] !== '/')) {
|
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ class SimpleTraversable implements Iterator
|
|||||||
{
|
{
|
||||||
return $this->_position;
|
return $this->_position;
|
||||||
}
|
}
|
||||||
public function next() : void
|
public function next() : void
|
||||||
{
|
{
|
||||||
++$this->_position;
|
++$this->_position;
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetBasePath()
|
public function testSetBasePath()
|
||||||
{
|
{
|
||||||
$this->router->setBasePath('/some/path');
|
$this->router->setBasePath('/some/path');
|
||||||
$this->assertEquals('/some/path', $this->router->getBasePath());
|
$this->assertEquals('/some/path', $this->router->getBasePath());
|
||||||
|
|
||||||
$this->router->setBasePath('/some/path');
|
$this->router->setBasePath('/some/path');
|
||||||
@@ -514,18 +514,17 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testMatchWithSlashBeforeOptionalPart()
|
public function testMatchWithSlashBeforeOptionalPart()
|
||||||
{
|
{
|
||||||
$this->router->map('GET', '/archives/[lmin:category]?', 'Article#archives');
|
$this->router->map('GET', '/archives/[lmin:category]?', 'Article#archives');
|
||||||
$expected = [
|
$expected = [
|
||||||
'target' => 'Article#archives',
|
'target' => 'Article#archives',
|
||||||
'params' => [],
|
'params' => [],
|
||||||
'name' => null
|
'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
|
* @covers AltoRouter::addMatchTypes
|
||||||
|
@@ -13,46 +13,46 @@
|
|||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
$routes = [
|
$routes = [
|
||||||
["POST", "/1/classes/[a:className]"],
|
["POST", "/1/classes/[a:className]"],
|
||||||
["GET", "/1/classes/[a:className]/[i:objectId]"],
|
["GET", "/1/classes/[a:className]/[i:objectId]"],
|
||||||
["PUT", "/1/classes/[a:className]/[i:objectId]"],
|
["PUT", "/1/classes/[a:className]/[i:objectId]"],
|
||||||
["GET", "/1/classes/[a:className]"],
|
["GET", "/1/classes/[a:className]"],
|
||||||
["DELETE", "/1/classes/[a:className]/[i:objectId]"],
|
["DELETE", "/1/classes/[a:className]/[i:objectId]"],
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
["POST", "/1/users"],
|
["POST", "/1/users"],
|
||||||
["GET", "/1/login"],
|
["GET", "/1/login"],
|
||||||
["GET", "/1/users/[i:objectId]"],
|
["GET", "/1/users/[i:objectId]"],
|
||||||
["PUT", "/1/users/[i:objectId]"],
|
["PUT", "/1/users/[i:objectId]"],
|
||||||
["GET", "/1/users"],
|
["GET", "/1/users"],
|
||||||
["DELETE", "/1/users/[i:objectId]"],
|
["DELETE", "/1/users/[i:objectId]"],
|
||||||
["POST", "/1/requestPasswordReset"],
|
["POST", "/1/requestPasswordReset"],
|
||||||
|
|
||||||
// Roles
|
// Roles
|
||||||
["POST", "/1/roles"],
|
["POST", "/1/roles"],
|
||||||
["GET", "/1/roles/[i:objectId]"],
|
["GET", "/1/roles/[i:objectId]"],
|
||||||
["PUT", "/1/roles/[i:objectId]"],
|
["PUT", "/1/roles/[i:objectId]"],
|
||||||
["GET", "/1/roles"],
|
["GET", "/1/roles"],
|
||||||
["DELETE", "/1/roles/[i:objectId]"],
|
["DELETE", "/1/roles/[i:objectId]"],
|
||||||
|
|
||||||
// Files
|
// Files
|
||||||
["POST", "/1/files/:fileName"],
|
["POST", "/1/files/:fileName"],
|
||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
["POST", "/1/events/[a:eventName]"],
|
["POST", "/1/events/[a:eventName]"],
|
||||||
|
|
||||||
// Push Notifications
|
// Push Notifications
|
||||||
["POST", "/1/push"],
|
["POST", "/1/push"],
|
||||||
|
|
||||||
// Installations
|
// Installations
|
||||||
["POST", "/1/installations"],
|
["POST", "/1/installations"],
|
||||||
["GET", "/1/installations/[i:objectId]"],
|
["GET", "/1/installations/[i:objectId]"],
|
||||||
["PUT", "/1/installations/[i:objectId]"],
|
["PUT", "/1/installations/[i:objectId]"],
|
||||||
["GET", "/1/installations"],
|
["GET", "/1/installations"],
|
||||||
["DELETE", "/1/installations/[i:objectId]"],
|
["DELETE", "/1/installations/[i:objectId]"],
|
||||||
|
|
||||||
// Cloud Functions
|
// Cloud Functions
|
||||||
["POST", "/1/functions"],
|
["POST", "/1/functions"],
|
||||||
];
|
];
|
||||||
$total_time = 0;
|
$total_time = 0;
|
||||||
$router = new AltoRouter();
|
$router = new AltoRouter();
|
||||||
|
Reference in New Issue
Block a user