1--TEST-- 2Phar with metadata (read) 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required"); 7?> 8--INI-- 9phar.readonly=0 10phar.require_hash=0 11--FILE-- 12<?php 13$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 14$pname = 'phar://' . $fname; 15$file = "<?php __HALT_COMPILER(); ?>"; 16 17$files = array(); 18$pmeta = 'hi there'; 19$files['a'] = array('cont' => 'a'); 20$files['b'] = array('cont' => 'b'); 21$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there')); 22$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); 23include 'files/phar_test.inc'; 24 25foreach($files as $name => $cont) { 26 var_dump(file_get_contents($pname.'/'.$name)); 27} 28 29$phar = new Phar($fname); 30var_dump($phar->hasMetaData()); 31var_dump($phar->getMetaData()); 32var_dump($phar->delMetaData()); 33var_dump($phar->getMetaData()); 34var_dump($phar->delMetaData()); 35var_dump($phar->getMetaData()); 36foreach($files as $name => $cont) { 37 echo " meta $name\n"; 38 var_dump($phar[$name]->hasMetadata()); 39 var_dump($phar[$name]->getMetadata()); 40 var_dump($phar[$name]->delMetadata()); 41 var_dump($phar[$name]->getMetadata()); 42} 43 44unset($phar); 45 46foreach($files as $name => $cont) { 47 var_dump(file_get_contents($pname.'/'.$name)); 48} 49?> 50===DONE=== 51--CLEAN-- 52<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 53--EXPECT-- 54string(1) "a" 55string(1) "b" 56string(1) "c" 57string(1) "d" 58bool(true) 59string(8) "hi there" 60bool(true) 61NULL 62bool(true) 63NULL 64 meta a 65bool(false) 66NULL 67bool(true) 68NULL 69 meta b 70bool(false) 71NULL 72bool(true) 73NULL 74 meta c 75bool(true) 76array(2) { 77 [0]=> 78 string(2) "hi" 79 [1]=> 80 string(5) "there" 81} 82bool(true) 83NULL 84 meta d 85bool(true) 86array(2) { 87 ["hi"]=> 88 string(5) "there" 89 ["foo"]=> 90 string(3) "bar" 91} 92bool(true) 93NULL 94string(1) "a" 95string(1) "b" 96string(1) "c" 97string(1) "d" 98===DONE=== 99