bug69720.phpt 1021 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Phar - bug #69720 - Null pointer dereference in phar_get_fp_offset()
  3. --EXTENSIONS--
  4. phar
  5. --FILE--
  6. <?php
  7. try {
  8. // open an existing phar
  9. $p = new Phar(__DIR__."/bug69720.phar",0);
  10. // Phar extends SPL's DirectoryIterator class
  11. echo $p->getMetadata();
  12. foreach (new RecursiveIteratorIterator($p) as $file) {
  13. // $file is a PharFileInfo class, and inherits from SplFileInfo
  14. $temp="";
  15. $temp= $file->getFileName() . "\n";
  16. $temp.=file_get_contents($file->getPathName()) . "\n"; // display contents
  17. var_dump($file->getMetadata());
  18. }
  19. }
  20. catch (Exception $e) {
  21. echo 'Could not open Phar: ', $e;
  22. }
  23. ?>
  24. --EXPECTF--
  25. MY_METADATA_NULL
  26. Warning: file_get_contents(phar://%s): Failed to open stream: phar error: "test.php" is not a file in phar "%s.phar" in %s.php on line %d
  27. array(1) {
  28. ["whatever"]=>
  29. int(123)
  30. }
  31. object(DateTime)#6 (3) {
  32. ["date"]=>
  33. string(26) "2000-01-01 00:00:00.000000"
  34. ["timezone_type"]=>
  35. int(3)
  36. ["timezone"]=>
  37. string(3) "UTC"
  38. }