phar_gobyebye.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
  3. --EXTENSIONS--
  4. phar
  5. --SKIPIF--
  6. <?php
  7. if (defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip");
  8. ?>
  9. --INI--
  10. phar.readonly=0
  11. --FILE--
  12. <?php
  13. Phar::interceptFileFuncs();
  14. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  15. $fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.php';
  16. $pname = 'phar://' . $fname;
  17. file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
  18. file_put_contents($pname . '/foo/hi', '<?php
  19. include "' . addslashes($fname2) . '";
  20. readfile("foo/hi");
  21. fopen("foo/hi", "r");
  22. echo file_get_contents("foo/hi");
  23. var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
  24. opendir("foo/hi");
  25. ?>
  26. ');
  27. include $pname . '/foo/hi';
  28. ?>
  29. --CLEAN--
  30. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  31. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
  32. --EXPECTF--
  33. Warning: readfile(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
  34. Warning: fopen(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
  35. Warning: file_get_contents(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
  36. Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
  37. bool(false)
  38. bool(false)
  39. bool(false)
  40. bool(false)
  41. bool(false)
  42. Warning: opendir(foo/hi): Failed to open directory: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d