1--TEST--
2Phar with metadata (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);
26var_dump($phar->getMetadata());
27$phar->setMetadata(array('my' => 'friend'));
28$phar->setMetadata(array('my' => 'friend'));
29var_dump($phar->getMetadata());
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
39unset($phar);
40
41foreach($files as $name => $cont) {
42    var_dump(file_get_contents($pname.'/'.$name));
43}
44?>
45--CLEAN--
46<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
47--EXPECT--
48string(1) "a"
49string(1) "b"
50string(1) "c"
51string(1) "d"
52NULL
53array(1) {
54  ["my"]=>
55  string(6) "friend"
56}
57int(42)
58NULL
59array(2) {
60  [0]=>
61  int(25)
62  ["foo"]=>
63  string(3) "bar"
64}
65bool(true)
66string(1) "a"
67string(1) "b"
68string(1) "c"
69string(1) "d"
70