--- /dev/null
+--TEST--\r
+Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d\r
+--SKIPIF--\r
+<?php if (!extension_loaded("phar")) die("skip");\r
+if (strpos(PHP_OS, 'WIN') !== false) die("Extra warning on Windows.");\r
+?>\r
+--INI--\r
+phar.readonly=0\r
+--FILE--\r
+<?php\r
+Phar::interceptFileFuncs();\r
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';\r
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.php';\r
+$pname = 'phar://' . $fname;\r
+file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');\r
+file_put_contents($pname . '/foo/hi', '<?php\r
+include "' . addslashes($fname2) . '";\r
+readfile("foo/hi");\r
+fopen("foo/hi", "r");\r
+echo file_get_contents("foo/hi");\r
+var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));\r
+opendir("foo/hi");\r
+?>\r
+');\r
+include $pname . '/foo/hi';\r
+?>\r
+===DONE===\r
+--CLEAN--\r
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>\r
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>\r
+--EXPECTF--\r
+Warning: readfile(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+\r
+Warning: fopen(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+\r
+Warning: file_get_contents(foo/hi): failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+\r
+Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+bool(false)\r
+bool(false)\r
+bool(false)\r
+bool(false)\r
+bool(false)\r
+\r
+Warning: opendir(foo/hi,foo/hi): The system cannot find the path specified. (code: 3) in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+\r
+Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d\r
+===DONE===\r