bug66405.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. SPL: RecursiveDirectoryIterator with CURRENT_AS_PATHNAME flag
  3. --CREDITS--
  4. Paul Garvin pgarvin76@gmail.com
  5. --FILE--
  6. <?php
  7. $td = __DIR__ . '/bug66405';
  8. mkdir($td);
  9. touch($td . '/file1.txt');
  10. touch($td . '/file2.md');
  11. mkdir($td . '/testsubdir');
  12. touch($td . '/testsubdir/file3.csv');
  13. class Bug66405 extends RecursiveDirectoryIterator
  14. {
  15. public function current(): string|SplFileInfo|FilesystemIterator
  16. {
  17. $current = parent::current();
  18. echo gettype($current) . " $current\n";
  19. return $current;
  20. }
  21. public function getChildren(): RecursiveDirectoryIterator
  22. {
  23. $children = parent::getChildren();
  24. if (is_object($children)) {
  25. echo get_class($children) . " $children\n";
  26. } else {
  27. echo gettype($children) . " $children\n";
  28. }
  29. return $children;
  30. }
  31. }
  32. $rdi = new Bug66405($td, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
  33. $rii = new RecursiveIteratorIterator($rdi);
  34. ob_start();
  35. foreach ($rii as $file) {
  36. //noop
  37. }
  38. $results = explode("\n", ob_get_clean());
  39. sort($results);
  40. echo implode("\n", $results);
  41. ?>
  42. --CLEAN--
  43. <?php
  44. $td = __DIR__ . '/bug66405';
  45. unlink($td . '/testsubdir/file3.csv');
  46. unlink($td . '/file2.md');
  47. unlink($td . '/file1.txt');
  48. rmdir($td . '/testsubdir');
  49. rmdir($td);
  50. ?>
  51. --EXPECTF--
  52. Bug66405 file3.csv
  53. string %sbug66405%efile1.txt
  54. string %sbug66405%efile2.md
  55. string %sbug66405%etestsubdir%efile3.csv