PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/hphp/test/zend/bad/ext/standard/tests/class_object/get_class_vars_variation1.php

http://github.com/facebook/hiphop-php
PHP | 90 lines | 51 code | 19 blank | 20 comment | 0 complexity | 9b0d5962ec93c59d407b96a188a32769 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 : array get_class_vars(string class_name)
  3. * Description: Returns an array of default properties of the class.
  4. * Source code: Zend/zend_builtin_functions.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing get_class_vars() : usage variation ***\n";
  8. //get an unset variable
  9. $unset_var = 10;
  10. unset ($unset_var);
  11. // define some classes
  12. class classWithToString
  13. {
  14. public function __toString() {
  15. return "Class A object";
  16. }
  17. }
  18. class classWithoutToString
  19. {
  20. }
  21. // heredoc string
  22. $heredoc = <<<EOT
  23. hello world
  24. EOT;
  25. // add arrays
  26. $index_array = array (1, 2, 3);
  27. $assoc_array = array ('one' => 1, 'two' => 2);
  28. //array of values to iterate over
  29. $inputs = array(
  30. // int data
  31. 'int 0' => 0,
  32. 'int 1' => 1,
  33. 'int 12345' => 12345,
  34. 'int -12345' => -2345,
  35. // float data
  36. 'float 10.5' => 10.5,
  37. 'float -10.5' => -10.5,
  38. 'float 12.3456789000e10' => 12.3456789000e10,
  39. 'float -12.3456789000e10' => -12.3456789000e10,
  40. 'float .5' => .5,
  41. // array data
  42. 'empty array' => array(),
  43. 'int indexed array' => $index_array,
  44. 'associative array' => $assoc_array,
  45. 'nested arrays' => array('foo', $index_array, $assoc_array),
  46. // null data
  47. 'uppercase NULL' => NULL,
  48. 'lowercase null' => null,
  49. // boolean data
  50. 'lowercase true' => true,
  51. 'lowercase false' =>false,
  52. 'uppercase TRUE' =>TRUE,
  53. 'uppercase FALSE' =>FALSE,
  54. // empty data
  55. 'empty string DQ' => "",
  56. 'empty string SQ' => '',
  57. // object data
  58. 'instance of classWithToString' => new classWithToString(),
  59. 'instance of classWithoutToString' => new classWithoutToString(),
  60. // undefined data
  61. 'undefined var' => @$undefined_var,
  62. // unset data
  63. 'unset var' => @$unset_var,
  64. );
  65. // loop through each element of the array for method_name
  66. foreach($inputs as $key =>$value) {
  67. echo "\n--$key--\n";
  68. var_dump( get_class_vars($value) );
  69. };
  70. ?>
  71. ===DONE===