1--TEST-- 2Phar with meta-data (write) zip-based 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 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip.php'; 13$f2name = __DIR__ . '/files/metadata.phar.zip'; 14$pname = 'phar://' . $fname; 15$p2name = 'phar://' . $f2name; 16 17$file = "<?php __HALT_COMPILER(); ?>"; 18 19$files = array(); 20$files['a'] = array('cont' => 'a'); 21$files['b'] = array('cont' => 'b', 'meta' => 'hi there'); 22$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there')); 23$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); 24 25foreach($files as $name => $cont) { 26 var_dump(file_get_contents($p2name.'/'.$name)); 27} 28 29copy($f2name, $fname); 30$phar = new Phar($fname); 31$phar->startBuffering(); 32$phar['a']->setMetadata(42); 33$phar['b']->setMetadata(NULL); 34$phar['c']->setMetadata(array(25, 'foo'=>'bar')); 35$phar['d']->setMetadata(true); 36$phar->setMetadata('hi'); 37 38foreach($files as $name => $cont) { 39 var_dump($phar[$name]->getMetadata()); 40} 41$phar->stopBuffering(); 42 43unset($phar); 44 45$phar = new Phar($fname); 46 47foreach($files as $name => $cont) { 48 var_dump(file_get_contents($pname.'/'.$name)); 49} 50 51foreach($files as $name => $cont) { 52 var_dump($phar[$name]->getMetadata()); 53} 54var_dump($phar->getMetadata()); 55?> 56===DONE=== 57--CLEAN-- 58<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?> 59--EXPECT-- 60string(1) "a" 61string(1) "b" 62string(1) "c" 63string(1) "d" 64int(42) 65NULL 66array(2) { 67 [0]=> 68 int(25) 69 ["foo"]=> 70 string(3) "bar" 71} 72bool(true) 73string(1) "a" 74string(1) "b" 75string(1) "c" 76string(1) "d" 77int(42) 78NULL 79array(2) { 80 [0]=> 81 int(25) 82 ["foo"]=> 83 string(3) "bar" 84} 85bool(true) 86string(2) "hi" 87===DONE=== 88