PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/standard/tests/file/touch_variation4.php

http://github.com/facebook/hiphop-php
PHP | 103 lines | 58 code | 22 blank | 23 comment | 2 complexity | f6e0094ff336b7d5acc449e5eeeb2ba2 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /* Prototype : bool touch(string filename [, int time [, int atime]])
  3. * Description: Set modification time of file
  4. * Source code: ext/standard/filestat.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing touch() : usage variation ***\n";
  8. // Define error handler
  9. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  10. if (error_reporting() != 0) {
  11. // report non-silenced errors
  12. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  13. }
  14. }
  15. set_error_handler('test_error_handler');
  16. // Initialise function arguments not being substituted (if any)
  17. $filename = 'touchVar3.tmp';
  18. $time = 10;
  19. //get an unset variable
  20. $unset_var = 10;
  21. unset ($unset_var);
  22. // define some classes
  23. class classWithToString
  24. {
  25. public function __toString() {
  26. return "Class A object";
  27. }
  28. }
  29. class classWithoutToString
  30. {
  31. }
  32. // heredoc string
  33. $heredoc = <<<EOT
  34. hello world
  35. EOT;
  36. // add arrays
  37. $index_array = array (1, 2, 3);
  38. $assoc_array = array ('one' => 1, 'two' => 2);
  39. //array of values to iterate over
  40. $inputs = array(
  41. // float data
  42. 'float 10.5' => 10.5,
  43. 'float 12.3456789000e10' => 12.3456789000e10,
  44. 'float .5' => .5,
  45. // array data
  46. 'empty array' => array(),
  47. 'int indexed array' => $index_array,
  48. 'associative array' => $assoc_array,
  49. 'nested arrays' => array('foo', $index_array, $assoc_array),
  50. // null data
  51. 'uppercase NULL' => NULL,
  52. 'lowercase null' => null,
  53. // boolean data
  54. 'lowercase true' => true,
  55. 'lowercase false' =>false,
  56. 'uppercase TRUE' =>TRUE,
  57. 'uppercase FALSE' =>FALSE,
  58. // empty data
  59. 'empty string DQ' => "",
  60. 'empty string SQ' => '',
  61. // string data
  62. 'string DQ' => "string",
  63. 'string SQ' => 'string',
  64. 'mixed case string' => "sTrInG",
  65. 'heredoc' => $heredoc,
  66. // object data
  67. 'instance of classWithToString' => new classWithToString(),
  68. 'instance of classWithoutToString' => new classWithoutToString(),
  69. // undefined data
  70. 'undefined var' => @$undefined_var,
  71. // unset data
  72. 'unset var' => @$unset_var,
  73. );
  74. // loop through each element of the array for atime
  75. foreach($inputs as $key =>$value) {
  76. echo "\n--$key--\n";
  77. var_dump( touch($filename, $time, $value) );
  78. };
  79. unlink($filename);
  80. ?>
  81. ===DONE===