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