1--TEST-- 2SPL: DirectoryIterator defaults 3--SKIPIF-- 4<?php if (!extension_loaded("spl") || !extension_loaded('reflection') || !defined('GLOB_ERR')) print "skip"; ?> 5--FILE-- 6<?php 7 8$classes = array( 9 'DirectoryIterator' => 0, 10 'FilesystemIterator' => 1, 11 'RecursiveDirectoryIterator' => 1, 12 'GlobIterator' => 1, 13); 14 15foreach ($classes as $class => $flags) { 16 echo "===$class===\n"; 17 $ref = new ReflectionClass($class); 18 $obj = $ref->newInstance('glob://*'); 19 echo get_class($obj->current()) . "\n"; 20 if ($flags) 21 { 22 var_dump($obj->getFlags()); 23 $flags = array( 24 FilesystemIterator::CURRENT_AS_FILEINFO => 0, 25 FilesystemIterator::CURRENT_AS_SELF => 0, 26 FilesystemIterator::CURRENT_AS_PATHNAME => 1, 27 ); 28 foreach($flags as $flag => $isstring) { 29 $obj->setFlags($flag); 30 $obj->rewind(); 31 var_dump($obj->getFlags()); 32 if ($isstring) { 33 $val = $obj->current(); 34 if (is_string($val)) { 35 var_dump(true); 36 } else { 37 var_dump($val); 38 } 39 } else { 40 echo get_class($obj->current()) . "\n"; 41 } 42 } 43 } 44} 45?> 46===DONE=== 47--EXPECTF-- 48===DirectoryIterator=== 49DirectoryIterator 50===FilesystemIterator=== 51SplFileInfo 52int(%d) 53int(0) 54SplFileInfo 55int(16) 56FilesystemIterator 57int(32) 58bool(true) 59===RecursiveDirectoryIterator=== 60SplFileInfo 61int(0) 62int(0) 63SplFileInfo 64int(16) 65RecursiveDirectoryIterator 66int(32) 67bool(true) 68===GlobIterator=== 69SplFileInfo 70int(0) 71int(0) 72SplFileInfo 73int(16) 74GlobIterator 75int(32) 76bool(true) 77===DONE=== 78