PageRenderTime 46ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/date/tests/date_sunrise_variation3.php

http://github.com/facebook/hiphop-php
PHP | 96 lines | 57 code | 19 blank | 20 comment | 0 complexity | 6d758df45b478c43d0fa3f6e69869788 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 : mixed date_sunrise(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
  3. * Description: Returns time of sunrise for a given day and location
  4. * Source code: ext/date/php_date.c
  5. */
  6. echo "*** Testing date_sunrise() : usage variation ***\n";
  7. // Initialise function arguments not being substituted (if any)
  8. date_default_timezone_set("Asia/Calcutta");
  9. $time = mktime(8, 8, 8, 8, 8, 2008);
  10. $longitude = -9;
  11. $zenith = 90;
  12. $gmt_offset = -5.5;
  13. //get an unset variable
  14. $unset_var = 10;
  15. unset ($unset_var);
  16. // define some classes
  17. class classWithToString
  18. {
  19. public function __toString() {
  20. return "Class A object";
  21. }
  22. }
  23. class classWithoutToString
  24. {
  25. }
  26. // heredoc string
  27. $heredoc = <<<EOT
  28. hello world
  29. EOT;
  30. // add arrays
  31. $index_array = array (1, 2, 3);
  32. $assoc_array = array ('one' => 1, 'two' => 2);
  33. //array of values to iterate over
  34. $inputs = array(
  35. // int data
  36. 'int 0' => 0,
  37. 'int 1' => 1,
  38. 'int 12345' => 12345,
  39. 'int -12345' => -12345,
  40. // array data
  41. 'empty array' => array(),
  42. 'int indexed array' => $index_array,
  43. 'associative array' => $assoc_array,
  44. 'nested arrays' => array('foo', $index_array, $assoc_array),
  45. // null data
  46. 'uppercase NULL' => NULL,
  47. 'lowercase null' => null,
  48. // boolean data
  49. 'lowercase true' => true,
  50. 'lowercase false' =>false,
  51. 'uppercase TRUE' =>TRUE,
  52. 'uppercase FALSE' =>FALSE,
  53. // empty data
  54. 'empty string DQ' => "",
  55. 'empty string SQ' => '',
  56. // string data
  57. 'string DQ' => "string",
  58. 'string SQ' => 'string',
  59. 'mixed case string' => "sTrInG",
  60. 'heredoc' => $heredoc,
  61. // object data
  62. 'instance of classWithToString' => new classWithToString(),
  63. 'instance of classWithoutToString' => new classWithoutToString(),
  64. // undefined data
  65. 'undefined var' => @$undefined_var,
  66. // unset data
  67. 'unset var' => @$unset_var,
  68. );
  69. // loop through each element of the array for latitude
  70. foreach($inputs as $key =>$value) {
  71. echo "\n--$key--\n";
  72. var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value, $longitude, $zenith, $gmt_offset) );
  73. var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, $value, $longitude, $zenith, $gmt_offset) );
  74. var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $value, $longitude, $zenith, $gmt_offset) );
  75. };
  76. ?>
  77. ===DONE===