No KeyedIteratorAggregate<Tk, Tv>?
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
How come there is `Iterator`, `KeyedIterator` and `IteratorAggregate`, but no `KeyedIteratorAggregate`?
Defining it and using it seems to satisfy both the typechecker and the runtime:
```php
// definition
interface KeyedIteratorAggregate<+Tk, +Tv>
extends KeyedTraversable, IteratorAggregate {
public function getIterator(): KeyedIterator;
}
// test
class Bar {
public function barMethod(): void {
echo __METHOD__, "\n";
}
}
class FooIterator implements KeyedIterator {
public function valid(): bool {
return true;
}
public function key(): Bar {
return new Bar();
}
public function current(): string {
return 'hello';
}
public function next(): void {}
public function rewind(): void {}
}
class Foo implements KeyedIteratorAggregate {
public function getIterator(): FooIterator {
return new FooIterator();
}
}
class Testtt {
public static function main(): void {
$foo = new Foo();
foreach ($foo as $k => $v) {
$k->barMethod();
}
}
}
Testtt::main();
```
```
Bar::barMethod
Bar::barMethod
Bar::barMethod
Bar::barMethod
Bar::barMethod
Bar::barMethod
...
```
### HHVM Version
```
HipHop VM 3.18.0-dev (rel)
Compiler: heads/master-0-g0f6803df27b27f929f5edc175e11d302643f3a2c
Repo schema: 1733dfccb8791a77b6ce7b894ddd66e3238c2106
```
Contributor guide
Assessment
This issue has not been assessed yet.