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