__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Slim Framework (https://slimframework.com)
*
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
*/
declare(strict_types=1);
namespace Slim\Routing;
use FastRoute\Dispatcher\GroupCountBased;
class FastRouteDispatcher extends GroupCountBased
{
/**
* @var string[][]
*/
private array $allowedMethods = [];
/**
* @param string $httpMethod
* @param string $uri
*
* @return array{int, string|null, array<string, string>}
*/
public function dispatch($httpMethod, $uri): array
{
$routingResults = $this->routingResults($httpMethod, $uri);
if ($routingResults[0] === self::FOUND) {
return $routingResults;
}
// For HEAD requests, attempt fallback to GET
if ($httpMethod === 'HEAD') {
$routingResults = $this->routingResults('GET', $uri);
if ($routingResults[0] === self::FOUND) {
return $routingResults;
}
}
// If nothing else matches, try fallback routes
$routingResults = $this->routingResults('*', $uri);
if ($routingResults[0] === self::FOUND) {
return $routingResults;
}
if (!empty($this->getAllowedMethods($uri))) {
return [self::METHOD_NOT_ALLOWED, null, []];
}
return [self::NOT_FOUND, null, []];
}
/**
* @param string $httpMethod
* @param string $uri
*
* @return array{int, string|null, array<string, string>}
*/
private function routingResults(string $httpMethod, string $uri): array
{
if (isset($this->staticRouteMap[$httpMethod][$uri])) {
/** @var string $routeIdentifier */
$routeIdentifier = $this->staticRouteMap[$httpMethod][$uri];
return [self::FOUND, $routeIdentifier, []];
}
if (isset($this->variableRouteData[$httpMethod])) {
/** @var array{0: int, 1?: string, 2?: array<string, string>} $result */
$result = $this->dispatchVariableRoute($this->variableRouteData[$httpMethod], $uri);
if ($result[0] === self::FOUND) {
/** @var array{int, string, array<string, string>} $result */
return [self::FOUND, $result[1], $result[2]];
}
}
return [self::NOT_FOUND, null, []];
}
/**
* @param string $uri
*
* @return string[]
*/
public function getAllowedMethods(string $uri): array
{
if (isset($this->allowedMethods[$uri])) {
return $this->allowedMethods[$uri];
}
$allowedMethods = [];
foreach ($this->staticRouteMap as $method => $uriMap) {
if (isset($uriMap[$uri])) {
$allowedMethods[$method] = true;
}
}
foreach ($this->variableRouteData as $method => $routeData) {
$result = $this->dispatchVariableRoute($routeData, $uri);
if ($result[0] === self::FOUND) {
$allowedMethods[$method] = true;
}
}
return $this->allowedMethods[$uri] = array_keys($allowedMethods);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Dispatcher.php | File | 2.41 KB | 0777 |
|
| FastRouteDispatcher.php | File | 3.1 KB | 0777 |
|
| Route.php | File | 8.82 KB | 0777 |
|
| RouteCollector.php | File | 7.47 KB | 0777 |
|
| RouteCollectorProxy.php | File | 4.52 KB | 0777 |
|
| RouteContext.php | File | 2.36 KB | 0777 |
|
| RouteGroup.php | File | 2.47 KB | 0777 |
|
| RouteParser.php | File | 3.81 KB | 0777 |
|
| RouteResolver.php | File | 1.48 KB | 0777 |
|
| RouteRunner.php | File | 2.34 KB | 0777 |
|
| RoutingResults.php | File | 2.32 KB | 0777 |
|