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