phar_oo_007.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. --TEST--
  2. Phar object: access through SplFileObject
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. --FILE--
  8. <?php
  9. require_once 'files/phar_oo_test.inc';
  10. class MyFile extends SplFileObject
  11. {
  12. function __construct($name)
  13. {
  14. echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', __DIR__), '*', $name) . ")\n";
  15. parent::__construct($name);
  16. }
  17. }
  18. $phar = new Phar($fname);
  19. $phar->setInfoClass('MyFile');
  20. $f = $phar['a.php'];
  21. $s = $f->fstat();
  22. var_dump($s['atime']);
  23. var_dump($s['ctime']);
  24. var_dump($s['mtime']);
  25. var_dump($f->ftell());
  26. var_dump($f->eof());
  27. var_dump($f->fgets());
  28. var_dump($f->eof());
  29. var_dump($f->fseek(20));
  30. var_dump($f->ftell());
  31. var_dump($f->fgets());
  32. var_dump($f->rewind());
  33. var_dump($f->ftell());
  34. var_dump($f->fgets());
  35. var_dump($f->ftell());
  36. ?>
  37. ===AGAIN===
  38. <?php
  39. $f = $phar['a.php'];
  40. var_dump($f->ftell());
  41. var_dump($f->eof());
  42. var_dump($f->fgets());
  43. var_dump($f->eof());
  44. //unset($f); without unset we check for working refcounting
  45. ?>
  46. --CLEAN--
  47. <?php
  48. unlink(__DIR__ . '/files/phar_oo_007.phar.php');
  49. __halt_compiler();
  50. ?>
  51. --EXPECTF--
  52. MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
  53. int(%d)
  54. int(%d)
  55. int(%d)
  56. int(0)
  57. bool(false)
  58. string(32) "<?php echo "This is a.php\n"; ?>"
  59. bool(true)
  60. int(0)
  61. int(20)
  62. string(12) "a.php\n"; ?>"
  63. NULL
  64. int(0)
  65. string(32) "<?php echo "This is a.php\n"; ?>"
  66. int(32)
  67. ===AGAIN===
  68. MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php)
  69. int(0)
  70. bool(false)
  71. string(32) "<?php echo "This is a.php\n"; ?>"
  72. bool(true)