Skip to content
Permalink
Browse files

RouteList: Countable and IteratorAggregate are deprecated

  • Loading branch information
dg committed Mar 10, 2020
1 parent c2c41c2 commit 22d5246db316cf49aa99b04f80eede2399c38d30
@@ -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());
}

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


@@ -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());
}
}
@@ -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());
}
}
@@ -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());

0 comments on commit 22d5246

Please sign in to comment.
You can’t perform that action at this time.