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