Skip to content

Commit 115b818

Browse files
committed
Don't use deprecated #[Route] methods
1 parent d247368 commit 115b818

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Controller/Annotations/Route.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ public function __construct(
123123
);
124124
}
125125

126-
if (!$this->getMethods()) {
126+
if (isset($this->methods)) {
127+
if (!$this->methods) {
128+
$this->methods = (array) $this->getMethod();
129+
}
130+
} elseif (!$this->getMethods()) {
127131
$this->setMethods((array) $this->getMethod());
128132
}
129133
}

Tests/Controller/Annotations/RouteTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ public function testCanInstantiate()
4141
$condition
4242
);
4343

44-
$this->assertEquals($path, $route->getPath());
45-
$this->assertEquals($name, $route->getName());
46-
$this->assertEquals($requirements, $route->getRequirements());
47-
$this->assertEquals($options, $route->getOptions());
48-
$this->assertEquals($defaults, $route->getDefaults());
49-
$this->assertEquals($host, $route->getHost());
50-
$this->assertEquals($methods, $route->getMethods());
51-
$this->assertEquals($schemes, $route->getSchemes());
52-
$this->assertEquals($condition, $route->getCondition());
44+
$isPublic = isset($route->methods);
45+
46+
$this->assertEquals($path, $isPublic ? $route->path : $route->getPath());
47+
$this->assertEquals($name, $isPublic ? $route->name : $route->getName());
48+
$this->assertEquals($requirements, $isPublic ? $route->requirements : $route->getRequirements());
49+
$this->assertEquals($options, $isPublic ? $route->options : $route->getOptions());
50+
$this->assertEquals($defaults, $isPublic ? $route->defaults : $route->getDefaults());
51+
$this->assertEquals($host, $isPublic ? $route->host : $route->getHost());
52+
$this->assertEquals($methods, $isPublic ? $route->methods : $route->getMethods());
53+
$this->assertEquals($schemes, $isPublic ? $route->schemes : $route->getSchemes());
54+
$this->assertEquals($condition, $isPublic ? $route->condition : $route->getCondition());
5355
}
5456
}

0 commit comments

Comments
 (0)