diff --git a/src/Tempest/Router/src/Connect.php b/src/Tempest/Router/src/Connect.php index 822520476..527c72da8 100644 --- a/src/Tempest/Router/src/Connect.php +++ b/src/Tempest/Router/src/Connect.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Connect implements RouteInterface +final class Connect implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Delete.php b/src/Tempest/Router/src/Delete.php index 6daaacb0e..77837cada 100644 --- a/src/Tempest/Router/src/Delete.php +++ b/src/Tempest/Router/src/Delete.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Delete implements RouteInterface +final class Delete implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/GenericRouter.php b/src/Tempest/Router/src/GenericRouter.php index 3aa84cc62..057234c6d 100644 --- a/src/Tempest/Router/src/GenericRouter.php +++ b/src/Tempest/Router/src/GenericRouter.php @@ -116,8 +116,8 @@ public function toUri(array|string $action, ...$params): string $controllerMethod = $reflection->getMethod('__invoke'); } - /** @var RouteInterface|null $routeAttribute */ - $routeAttribute = $controllerMethod->getAttribute(RouteInterface::class); + /** @var Route|null $routeAttribute */ + $routeAttribute = $controllerMethod->getAttribute(Route::class); $uri = $routeAttribute->uri(); } catch (ReflectionException) { diff --git a/src/Tempest/Router/src/Get.php b/src/Tempest/Router/src/Get.php index a7ae94461..ce32591ab 100644 --- a/src/Tempest/Router/src/Get.php +++ b/src/Tempest/Router/src/Get.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Get implements RouteInterface +final class Get implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Head.php b/src/Tempest/Router/src/Head.php index 86317a405..dc0a8f141 100644 --- a/src/Tempest/Router/src/Head.php +++ b/src/Tempest/Router/src/Head.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Head implements RouteInterface +final class Head implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Options.php b/src/Tempest/Router/src/Options.php index 5764756ea..d894009f7 100644 --- a/src/Tempest/Router/src/Options.php +++ b/src/Tempest/Router/src/Options.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Options implements RouteInterface +final class Options implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Patch.php b/src/Tempest/Router/src/Patch.php index bd3a2ed3c..416ac602f 100644 --- a/src/Tempest/Router/src/Patch.php +++ b/src/Tempest/Router/src/Patch.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Patch implements RouteInterface +final class Patch implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Post.php b/src/Tempest/Router/src/Post.php index 8af6800b7..ecc585dab 100644 --- a/src/Tempest/Router/src/Post.php +++ b/src/Tempest/Router/src/Post.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Post implements RouteInterface +final class Post implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/Put.php b/src/Tempest/Router/src/Put.php index 37f61eae1..68b9c84af 100644 --- a/src/Tempest/Router/src/Put.php +++ b/src/Tempest/Router/src/Put.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Put implements RouteInterface +final class Put implements Route { use IsRoute; diff --git a/src/Tempest/Router/src/RouteInterface.php b/src/Tempest/Router/src/Route.php similarity index 91% rename from src/Tempest/Router/src/RouteInterface.php rename to src/Tempest/Router/src/Route.php index baa29f640..eedd0d2c9 100644 --- a/src/Tempest/Router/src/RouteInterface.php +++ b/src/Tempest/Router/src/Route.php @@ -6,7 +6,7 @@ use Tempest\Http\Method; -interface RouteInterface +interface Route { public function method(): Method; diff --git a/src/Tempest/Router/src/RouteDiscovery.php b/src/Tempest/Router/src/RouteDiscovery.php index bfc82d186..323c334b5 100644 --- a/src/Tempest/Router/src/RouteDiscovery.php +++ b/src/Tempest/Router/src/RouteDiscovery.php @@ -24,7 +24,7 @@ public function __construct( public function discover(DiscoveryLocation $location, ClassReflector $class): void { foreach ($class->getPublicMethods() as $method) { - $routeAttributes = $method->getAttributes(RouteInterface::class); + $routeAttributes = $method->getAttributes(Route::class); foreach ($routeAttributes as $routeAttribute) { $this->discoveryItems->add($location, [$method, $routeAttribute]); diff --git a/src/Tempest/Router/src/Routing/Construction/DiscoveredRoute.php b/src/Tempest/Router/src/Routing/Construction/DiscoveredRoute.php index 1192e9f4a..8b5aadf74 100644 --- a/src/Tempest/Router/src/Routing/Construction/DiscoveredRoute.php +++ b/src/Tempest/Router/src/Routing/Construction/DiscoveredRoute.php @@ -6,9 +6,9 @@ use Tempest\Http\Method; use Tempest\Reflection\MethodReflector; -use Tempest\Router\RouteInterface; +use Tempest\Router\Route; -final class DiscoveredRoute implements RouteInterface +final class DiscoveredRoute implements Route { public const string DEFAULT_MATCHING_GROUP = '[^/]++'; @@ -16,7 +16,7 @@ final class DiscoveredRoute implements RouteInterface public const string ROUTE_PARAM_CUSTOM_REGEX = '(?::([^{}]*(?:\{(?-1)\}[^{}]*)*))?'; - public static function fromRoute(RouteInterface $route, MethodReflector $methodReflector): self + public static function fromRoute(Route $route, MethodReflector $methodReflector): self { return new self( $route->uri(), diff --git a/src/Tempest/Router/src/Routing/Construction/DuplicateRouteException.php b/src/Tempest/Router/src/Routing/Construction/DuplicateRouteException.php index 0f615aa7c..ef1c06ba4 100644 --- a/src/Tempest/Router/src/Routing/Construction/DuplicateRouteException.php +++ b/src/Tempest/Router/src/Routing/Construction/DuplicateRouteException.php @@ -5,11 +5,11 @@ namespace Tempest\Router\Routing\Construction; use InvalidArgumentException; -use Tempest\Router\RouteInterface; +use Tempest\Router\Route; final class DuplicateRouteException extends InvalidArgumentException { - public function __construct(RouteInterface $route) + public function __construct(Route $route) { parent::__construct("Route '{$route->uri()}' already exists."); } diff --git a/src/Tempest/Router/src/Trace.php b/src/Tempest/Router/src/Trace.php index 53873ea64..7d4e2c4d2 100644 --- a/src/Tempest/Router/src/Trace.php +++ b/src/Tempest/Router/src/Trace.php @@ -8,7 +8,7 @@ use Tempest\Http\Method; #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)] -final class Trace implements RouteInterface +final class Trace implements Route { use IsRoute; diff --git a/src/Tempest/Router/tests/FakeRouteBuilder.php b/src/Tempest/Router/tests/FakeRouteBuilder.php index 777d9d9cc..41870e5d4 100644 --- a/src/Tempest/Router/tests/FakeRouteBuilder.php +++ b/src/Tempest/Router/tests/FakeRouteBuilder.php @@ -9,9 +9,9 @@ use Tempest\Router\Routing\Construction\DiscoveredRoute; use Tempest\Router\Routing\Construction\MarkedRoute; use Tempest\Reflection\MethodReflector; -use Tempest\Router\RouteInterface; +use Tempest\Router\Route; -final readonly class FakeRouteBuilder implements RouteInterface +final readonly class FakeRouteBuilder implements Route { private MethodReflector $handler; diff --git a/tests/Benchmark/Http/RouteConfigBench.php b/tests/Benchmark/Http/RouteConfigBench.php index 2b9d9e543..7e328bf93 100644 --- a/tests/Benchmark/Http/RouteConfigBench.php +++ b/tests/Benchmark/Http/RouteConfigBench.php @@ -6,8 +6,6 @@ use PhpBench\Attributes\Revs; use PhpBench\Attributes\Warmup; -use Tempest\Http\Method; -use Tempest\Router\Route; use Tempest\Router\RouteConfig; use Tempest\Router\Routing\Construction\RouteConfigurator; use Tempest\Router\Tests\FakeRouteBuilder;