1--TEST--
2Phar with object in metadata
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');
16include 'files/phar_test.inc';
17
18foreach($files as $name => $cont) {
19    var_dump(file_get_contents($pname.'/'.$name));
20}
21
22$phar = new Phar($fname);
23var_dump($phar->getMetadata());
24$phar->setMetadata((object) ['my' => 'friend']);
25unset($phar);
26// NOTE: Phar will use the cached value of metadata if setMetaData was called on that Phar path before.
27// Save the writes to the phar and use a different file path.
28$fname_new = "$fname.copy.php";
29copy($fname, $fname_new);
30$phar = new Phar($fname_new);
31var_dump($phar->getMetadata());
32
33?>
34--CLEAN--
35<?php
36unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
37unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php.copy.php');
38?>
39--EXPECT--
40string(1) "a"
41NULL
42object(stdClass)#2 (1) {
43  ["my"]=>
44  string(6) "friend"
45}
46