1--TEST-- 2Phar: tar-based phar, valid 1 3--SKIPIF-- 4<?php if (!extension_loaded('phar')) die('skip'); ?> 5--INI-- 6phar.readonly=0 7phar.require_hash=0 8--FILE-- 9<?php 10include dirname(__FILE__) . '/files/tarmaker.php.inc'; 11 12$fname = dirname(__FILE__) . '/tar_003.phar.tar'; 13$alias = 'phar://' . $fname; 14 15$tar = new tarmaker($fname, 'none'); 16$tar->init(); 17$tar->addFile('.phar/stub.php', "<?php // tar-based phar archive stub file\n__HALT_COMPILER();"); 18$tar->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r')); 19$tar->addFile('internal/file/here', "hi there!\n"); 20$tar->mkDir('internal/dir'); 21$tar->mkDir('dir'); 22$tar->close(); 23 24fclose($g); 25 26echo file_get_contents($alias . '/internal/file/here'); 27 28try { 29$tar = opendir($alias . '/'); 30} catch (Exception $e) { 31echo $e->getMessage()."\n"; 32} 33 34while (false !== ($v = readdir($tar))) { 35 echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); 36 echo $v . "\n"; 37} 38closedir($tar); 39 40/* ensure none of the dir tar files were freed */ 41echo "second round\n"; 42$tar = opendir($alias . '/'); 43while (false !== ($v = readdir($tar))) { 44 echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); 45 echo $v . "\n"; 46} 47closedir($tar); 48 49?> 50===DONE=== 51--CLEAN-- 52<?php 53@unlink(dirname(__FILE__) . '/tar_003.phar.tar'); 54?> 55--EXPECT-- 56hi there! 57dir 58dir 59dir 60internal 61file 62tar_003.phpt 63second round 64dir 65dir 66dir 67internal 68file 69tar_003.phpt 70===DONE=== 71