phar_buildfromiterator7.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Phar::buildFromIterator() iterator, file can't be opened
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. phar.readonly=0
  8. --FILE--
  9. <?php
  10. class myIterator implements Iterator
  11. {
  12. var $a;
  13. function __construct(array $a)
  14. {
  15. $this->a = $a;
  16. }
  17. function next(): void {
  18. echo "next\n";
  19. next($this->a);
  20. }
  21. function current(): mixed {
  22. echo "current\n";
  23. return current($this->a);
  24. }
  25. function key(): mixed {
  26. echo "key\n";
  27. return key($this->a);
  28. }
  29. function valid(): bool {
  30. echo "valid\n";
  31. return current($this->a);
  32. }
  33. function rewind(): void {
  34. echo "rewind\n";
  35. reset($this->a);
  36. }
  37. }
  38. try {
  39. chdir(__DIR__);
  40. $phar = new Phar(__DIR__ . '/buildfromiterator7.phar');
  41. var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt'))));
  42. } catch (Exception $e) {
  43. var_dump(get_class($e));
  44. echo $e->getMessage() . "\n";
  45. }
  46. ?>
  47. --CLEAN--
  48. <?php
  49. unlink(__DIR__ . '/buildfromiterator7.phar');
  50. __HALT_COMPILER();
  51. ?>
  52. --EXPECTF--
  53. rewind
  54. valid
  55. current
  56. key
  57. %s(24) "UnexpectedValueException"
  58. Iterator myIterator returned a file that could not be opened "phar_buildfromiterator7./oopsie/there.phpt"