Skip to content

Commit 8e74483

Browse files
committed
RouteList: Countable and IteratorAggregate are deprecated
1 parent 34b9bc9 commit 8e74483

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Application/Routers/RouteList.php

Lines changed: 5 additions & 1 deletion
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
}

tests/Bridges.DI/RoutingExtension.basic.phpt

Lines changed: 1 addition & 1 deletion
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)