From 115b81801062c10a7fcb16c1299560fda965dea0 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Tue, 18 Nov 2025 19:34:30 +0100 Subject: [PATCH] Don't use deprecated `#[Route]` methods --- Controller/Annotations/Route.php | 6 +++++- Tests/Controller/Annotations/RouteTest.php | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Controller/Annotations/Route.php b/Controller/Annotations/Route.php index b3682e875..caac132a5 100644 --- a/Controller/Annotations/Route.php +++ b/Controller/Annotations/Route.php @@ -123,7 +123,11 @@ public function __construct( ); } - if (!$this->getMethods()) { + if (isset($this->methods)) { + if (!$this->methods) { + $this->methods = (array) $this->getMethod(); + } + } elseif (!$this->getMethods()) { $this->setMethods((array) $this->getMethod()); } } diff --git a/Tests/Controller/Annotations/RouteTest.php b/Tests/Controller/Annotations/RouteTest.php index 394e72c1e..7ee9f6c57 100644 --- a/Tests/Controller/Annotations/RouteTest.php +++ b/Tests/Controller/Annotations/RouteTest.php @@ -41,14 +41,16 @@ public function testCanInstantiate() $condition ); - $this->assertEquals($path, $route->getPath()); - $this->assertEquals($name, $route->getName()); - $this->assertEquals($requirements, $route->getRequirements()); - $this->assertEquals($options, $route->getOptions()); - $this->assertEquals($defaults, $route->getDefaults()); - $this->assertEquals($host, $route->getHost()); - $this->assertEquals($methods, $route->getMethods()); - $this->assertEquals($schemes, $route->getSchemes()); - $this->assertEquals($condition, $route->getCondition()); + $isPublic = isset($route->methods); + + $this->assertEquals($path, $isPublic ? $route->path : $route->getPath()); + $this->assertEquals($name, $isPublic ? $route->name : $route->getName()); + $this->assertEquals($requirements, $isPublic ? $route->requirements : $route->getRequirements()); + $this->assertEquals($options, $isPublic ? $route->options : $route->getOptions()); + $this->assertEquals($defaults, $isPublic ? $route->defaults : $route->getDefaults()); + $this->assertEquals($host, $isPublic ? $route->host : $route->getHost()); + $this->assertEquals($methods, $isPublic ? $route->methods : $route->getMethods()); + $this->assertEquals($schemes, $isPublic ? $route->schemes : $route->getSchemes()); + $this->assertEquals($condition, $isPublic ? $route->condition : $route->getCondition()); } }