1--TEST-- 2Phar: phar:// opendir 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6?> 7--INI-- 8phar.require_hash=0 9--FILE-- 10<?php 11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 12$pname = 'phar://' . $fname; 13$file = "<?php __HALT_COMPILER(); ?>"; 14 15$files = array(); 16$files['a.php'] = '<?php echo "This is a\n"; require \''.$pname.'/b.php\'; ?>'; 17$files['b.php'] = '<?php echo "This is b\n"; require \''.$pname.'/b/c.php\'; ?>'; 18$files['b/c.php'] = '<?php echo "This is b/c\n"; require \''.$pname.'/b/d.php\'; ?>'; 19$files['b/d.php'] = '<?php echo "This is b/d\n"; require \''.$pname.'/e.php\'; ?>'; 20$files['e.php'] = '<?php echo "This is e\n"; ?>'; 21 22include 'files/phar_test.inc'; 23 24function dump($phar, $base) 25{ 26 var_dump(str_replace(dirname(__FILE__), '*', $phar) . $base); 27 $dir = opendir($phar . $base); 28 if ($base == '/') 29 { 30 $base = ''; 31 } 32 while (false !== ($entry = readdir($dir))) { 33 $entry = $base . '/' . $entry; 34 var_dump($entry); 35 var_dump(is_dir($phar . $entry)); 36 if (is_dir($phar . $entry)) 37 { 38 dump($phar, $entry); 39 } 40 } 41} 42 43dump($pname, '/'); 44 45$a = opendir($pname); 46// this may stop working in future versions, but is here for code coverage purposes 47echo "fseek on dir handle\n"; 48var_dump(fseek($a, 0, SEEK_END), ftell($a)); 49var_dump(fseek($a, -1), ftell($a)); 50var_dump(fseek($a, 1), ftell($a)); 51echo "fwrite on dir handle\n"; 52var_dump(fwrite($a, 'hi')); 53var_dump(fstat($a)); 54closedir($a); 55echo "opendir edge cases\n"; 56var_dump(opendir("phar://")); 57var_dump(opendir("phar://foo.phar/hi")); 58?> 59===DONE=== 60--CLEAN-- 61<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 62--EXPECTF-- 63string(%d) "phar://*/027.phar.php/" 64string(6) "/a.php" 65bool(false) 66string(2) "/b" 67bool(true) 68string(%d) "phar://*/027.phar.php/b" 69string(8) "/b/c.php" 70bool(false) 71string(8) "/b/d.php" 72bool(false) 73string(6) "/b.php" 74bool(false) 75string(6) "/e.php" 76bool(false) 77fseek on dir handle 78int(0) 79int(4) 80int(-1) 81int(4) 82int(0) 83int(1) 84fwrite on dir handle 85int(0) 86bool(false) 87opendir edge cases 88 89Warning: opendir(phar://): failed to open dir: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar) 90phar url "phar://" is unknown in %s027.php on line %d 91bool(false) 92 93Warning: opendir(phar://foo.phar/hi): failed to open dir: phar error: invalid url or non-existent phar "phar://foo.phar/hi" 94phar url "phar://foo.phar/hi" is unknown in %s027.php on line %d 95bool(false) 96===DONE=== 97