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 Apr 2, 2020
1 parent 34b9bc9 commit 8e74483
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion 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 @@ -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());
}


Expand All @@ -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());
}
}
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 8e74483

Please sign in to comment.