1--TEST-- 2Phar with meta-data (write) 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (version_compare(PHP_VERSION, "6.0", "!=")) die("skip Unicode support required"); 7?> 8--INI-- 9phar.require_hash=0 10phar.readonly=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$files['a'] = array('cont' => 'a'); 19$files['b'] = array('cont' => 'b', 'meta' => 'hi there'); 20$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there')); 21$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); 22include 'files/phar_test.inc'; 23 24foreach($files as $name => $cont) { 25 var_dump(file_get_contents($pname.'/'.$name)); 26} 27 28$phar = new Phar($fname); 29$phar->startBuffering(); 30$phar['a']->setMetadata(42); 31$phar['b']->setMetadata(NULL); 32$phar['c']->setMetadata(array(25, 'foo'=>'bar')); 33$phar['d']->setMetadata(true); 34 35foreach($files as $name => $cont) { 36 var_dump($phar[$name]->getMetadata()); 37} 38$phar->stopBuffering(); 39 40unset($phar); 41 42$phar = new Phar($fname); 43 44foreach($files as $name => $cont) { 45 var_dump(file_get_contents($pname.'/'.$name)); 46} 47 48foreach($files as $name => $cont) { 49 var_dump($phar[$name]->getMetadata()); 50} 51?> 52===DONE=== 53--CLEAN-- 54<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 55--EXPECT-- 56string(1) "a" 57string(1) "b" 58string(1) "c" 59string(1) "d" 60int(42) 61NULL 62array(2) { 63 [0]=> 64 int(25) 65 [u"foo"]=> 66 unicode(3) "bar" 67} 68bool(true) 69string(1) "a" 70string(1) "b" 71string(1) "c" 72string(1) "d" 73int(42) 74NULL 75array(2) { 76 [0]=> 77 int(25) 78 [u"foo"]=> 79 unicode(3) "bar" 80} 81bool(true) 82===DONE=== 83