1--TEST--
2Directory Streams
3--FILE--
4<?php
5class test {
6    public $idx = 0;
7    public $context;
8
9    function dir_opendir($path, $options) {
10        print "Opening\n";
11        $this->idx = 0;
12
13        return true;
14    }
15
16    function dir_readdir() {
17        $sample = array('first','second','third','fourth');
18
19        if ($this->idx >= count($sample)) return false;
20                                    else  return $sample[$this->idx++];
21    }
22
23    function dir_rewinddir() {
24        $this->idx = 0;
25
26        return true;
27    }
28
29    function dir_closedir() {
30        print "Closing up!\n";
31
32        return true;
33    }
34}
35
36stream_wrapper_register('test', 'test');
37
38var_dump(scandir('test://example.com/path/to/test'));
39?>
40--EXPECT--
41Opening
42Closing up!
43array(4) {
44  [0]=>
45  string(5) "first"
46  [1]=>
47  string(6) "fourth"
48  [2]=>
49  string(6) "second"
50  [3]=>
51  string(5) "third"
52}
53