bug80933.phpt 580 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR)
  3. --FILE--
  4. <?php
  5. $lines = [
  6. "Lorem ipsum \0 dolor sit amet", // string with NUL
  7. "Lorem ipsum \r dolor sit amet", // string with CR
  8. ];
  9. foreach ($lines as $line) {
  10. $temp = new SplTempFileObject();
  11. $temp->fwrite($line);
  12. $temp->rewind();
  13. $read = $temp->fgets();
  14. var_dump($line === $read);
  15. $temp->rewind();
  16. $temp->setFlags(SplFileObject::DROP_NEW_LINE);
  17. $read = $temp->fgets();
  18. var_dump($line === $read);
  19. }
  20. ?>
  21. --EXPECT--
  22. bool(true)
  23. bool(true)
  24. bool(true)
  25. bool(true)