1--TEST--
2Phar: create and modify phar
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=1
8--FILE--
9<?php
10
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://' . $fname;
13
14@unlink($fname);
15
16file_put_contents($pname . '/a.php', "brand new!\n");
17
18$phar = new Phar($fname);
19$sig1 = $phar->getSignature();
20
21include $pname . '/a.php';
22
23if (function_exists("opcache_get_status")) {
24	$status = opcache_get_status();
25	if ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"])) {
26		ini_set("opcache.revalidate_freq", "0");
27		sleep(2);
28	}
29}
30
31file_put_contents($pname .'/a.php', "modified!\n");
32file_put_contents($pname .'/b.php', "another!\n");
33
34$phar = new Phar($fname);
35$sig2 = $phar->getSignature();
36
37var_dump($sig1['hash']);
38var_dump($sig2['hash']);
39var_dump($sig1['hash'] != $sig2['hash']);
40
41include $pname . '/a.php';
42include $pname . '/b.php';
43
44?>
45===DONE===
46--CLEAN--
47<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
48--EXPECTF--
49brand new!
50string(40) "%s"
51string(40) "%s"
52bool(true)
53modified!
54another!
55===DONE===
56