007.phpt 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. strip comments and whitespace with -w
  3. --SKIPIF--
  4. <?php
  5. include "skipif.inc";
  6. if (substr(PHP_OS, 0, 3) == 'WIN') {
  7. die ("skip not for Windows");
  8. }
  9. ?>
  10. --FILE--
  11. <?php
  12. $php = getenv('TEST_PHP_EXECUTABLE');
  13. $filename = __DIR__.'/007.test.php';
  14. $code ='
  15. <?php
  16. /* some test script */
  17. class test { /* {{{ */
  18. public $var = "test"; //test var
  19. #perl style comment
  20. private $pri; /* private attr */
  21. function foo(/* void */) {
  22. }
  23. }
  24. /* }}} */
  25. ?>
  26. ';
  27. file_put_contents($filename, $code);
  28. var_dump(`$php -n -w "$filename"`);
  29. var_dump(`$php -n -w "wrong"`);
  30. var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`);
  31. @unlink($filename);
  32. echo "Done\n";
  33. ?>
  34. --EXPECT--
  35. string(81) "
  36. <?php
  37. class test { public $var = "test"; private $pri; function foo() { } } ?>
  38. "
  39. string(33) "Could not open input file: wrong
  40. "
  41. string(43) "<?php class test { function foo() {} } ?>
  42. "
  43. Done