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