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