Skip to content

Commit 22d5246

Browse files
committed
RouteList: Countable and IteratorAggregate are deprecated
1 parent c2c41c2 commit 22d5246

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/Application/Routers/RouteList.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ public function getModule(): ?string
9393
}
9494

9595

96+
/** @deprecated */
9697
public function count(): int
9798
{
99+
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
98100
return count($this->getRouters());
99101
}
100102

@@ -132,7 +134,7 @@ public function offsetGet($index)
132134
*/
133135
public function offsetExists($index): bool
134136
{
135-
return is_int($index) && $index >= 0 && $index < $this->count();
137+
return is_int($index) && $index >= 0 && $index < count($this->getRouters());
136138
}
137139

138140

@@ -149,8 +151,10 @@ public function offsetUnset($index): void
149151
}
150152

151153

154+
/** @deprecated */
152155
public function getIterator(): \ArrayIterator
153156
{
157+
trigger_error(__METHOD__ . '() is deprecated, use getRouters().', E_USER_DEPRECATED);
154158
return new \ArrayIterator($this->getRouters());
155159
}
156160
}

src/Bridges/ApplicationTracy/RoutingPanel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function analyse(Nette\Routing\Router $router, string $module = ''): voi
100100
{
101101
if ($router instanceof Routers\RouteList) {
102102
if ($router->match($this->httpRequest)) {
103-
foreach ($router as $subRouter) {
103+
foreach ($router->getRouters() as $subRouter) {
104104
$this->analyse($subRouter, $module . $router->getModule());
105105
}
106106
}

tests/Bridges.DI/RoutingExtension.basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test(function () {
3636
$container = new Container1;
3737
$router = $container->getService('router');
3838
Assert::type(Nette\Application\Routers\RouteList::class, $router);
39-
Assert::count(2, $router);
39+
@Assert::count(2, $router); // @ is deprecated
4040
Assert::same('index.php', $router[0]->getMask());
4141
Assert::same('item/<id>', $router[1]->getMask());
4242

0 commit comments

Comments
 (0)