Skip to content

Commit

Permalink
RouteList: Countable and IteratorAggregate are deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 25, 2020
1 parent c2c41c2 commit e23d6da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Application/Routers/RouteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ public function getModule(): ?string
}


/** @deprecated */
public function count(): int
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
return count($this->getRouters());
}

Expand Down Expand Up @@ -149,8 +151,10 @@ public function offsetUnset($index): void
}


/** @deprecated */
public function getIterator(): \ArrayIterator
{
trigger_error(__METHOD__ . '() is deprecated, use getRouters().', E_USER_DEPRECATED);
return new \ArrayIterator($this->getRouters());
}
}
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationTracy/RoutingPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function analyse(Nette\Routing\Router $router, string $module = ''): voi
{
if ($router instanceof Routers\RouteList) {
if ($router->match($this->httpRequest)) {
foreach ($router as $subRouter) {
foreach ($router->getRouters() as $subRouter) {
$this->analyse($subRouter, $module . $router->getModule());
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Bridges.DI/RoutingExtension.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test(function () {
$container = new Container1;
$router = $container->getService('router');
Assert::type(Nette\Application\Routers\RouteList::class, $router);
Assert::count(2, $router);
@Assert::count(2, $router); // @ is deprecated
Assert::same('index.php', $router[0]->getMask());
Assert::same('item/<id>', $router[1]->getMask());

Expand Down

0 comments on commit e23d6da

Please sign in to comment.