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