Allow iterable objects in vec/dict/keyset casts
[hiphop-php.git] / hphp / test / slow / vec / to-vec.php
blobc771565694854f62bf675c2c005554f27ce218bf
1 <?hh
3 class IObj implements Iterator {
4 public function __construct(private dict $arr) {}
5 public function rewind() { reset($this->arr); }
6 public function current() { return current($this->arr); }
7 public function key() { return key($this->arr); }
8 public function next() { return next($this->arr); }
9 public function valid() { return key($this->arr); }
12 function gen() {
13 yield 'a' => 'b';
14 yield '1' => 'one';
15 yield 1 => 'ONE';
18 $arr = dict['q' => 'r', 1 => 'un', '1' => 'uno'];
20 var_dump(vec(new IObj($arr)));
21 var_dump(vec(gen()));