1--TEST-- 2Phar: create and modify tar-based phar 3--EXTENSIONS-- 4phar 5--INI-- 6phar.readonly=0 7opcache.validate_timestamps=1 8--FILE-- 9<?php 10 11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar.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 (is_array($status) && ($status["opcache_enabled"] || (isset($status["file_cache_only"]) && $status["file_cache_only"]))) { 21 opcache_invalidate($pname . '/a.php', true); 22 // opcache_invalidate is buggy and doesn't work as expected so we add a 23 // minor delay here. 24 sleep(2); 25 } 26} 27 28$phar = new Phar($fname); 29var_dump($phar->isFileFormat(Phar::TAR)); 30$sig1 = md5_file($fname); 31 32include $pname . '/a.php'; 33 34file_put_contents($pname .'/a.php', "modified!\n"); 35file_put_contents($pname .'/b.php', "another!\n"); 36 37$phar = new Phar($fname); 38$sig2 = md5_file($fname); 39 40var_dump($sig1 != $sig2); 41 42include $pname . '/a.php'; 43include $pname . '/b.php'; 44 45?> 46--CLEAN-- 47<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php'); ?> 48--EXPECT-- 49bool(true) 50brand new! 51bool(true) 52modified! 53another! 54