001.phpt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. --TEST--
  2. Test symfony_zval_info API
  3. --SKIPIF--
  4. <?php if (!extension_loaded("symfony_debug")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. $int = 42;
  8. $float = 42.42;
  9. $str = "foobar";
  10. $object = new StdClass;
  11. $array = array('foo', 'bar');
  12. $resource = tmpfile();
  13. $null = null;
  14. $bool = true;
  15. $anotherint = 42;
  16. $refcount2 = &$anotherint;
  17. $var = array('int' => $int,
  18. 'float' => $float,
  19. 'str' => $str,
  20. 'object' => $object,
  21. 'array' => $array,
  22. 'resource' => $resource,
  23. 'null' => $null,
  24. 'bool' => $bool,
  25. 'refcount' => &$refcount2);
  26. var_dump(symfony_zval_info('int', $var));
  27. var_dump(symfony_zval_info('float', $var));
  28. var_dump(symfony_zval_info('str', $var));
  29. var_dump(symfony_zval_info('object', $var));
  30. var_dump(symfony_zval_info('array', $var));
  31. var_dump(symfony_zval_info('resource', $var));
  32. var_dump(symfony_zval_info('null', $var));
  33. var_dump(symfony_zval_info('bool', $var));
  34. var_dump(symfony_zval_info('refcount', $var));
  35. var_dump(symfony_zval_info('not-exist', $var));
  36. ?>
  37. --EXPECTF--
  38. array(4) {
  39. ["type"]=>
  40. string(7) "integer"
  41. ["zval_hash"]=>
  42. string(16) "%s"
  43. ["zval_refcount"]=>
  44. int(2)
  45. ["zval_isref"]=>
  46. bool(false)
  47. }
  48. array(4) {
  49. ["type"]=>
  50. string(6) "double"
  51. ["zval_hash"]=>
  52. string(16) "%s"
  53. ["zval_refcount"]=>
  54. int(2)
  55. ["zval_isref"]=>
  56. bool(false)
  57. }
  58. array(5) {
  59. ["type"]=>
  60. string(6) "string"
  61. ["zval_hash"]=>
  62. string(16) "%s"
  63. ["zval_refcount"]=>
  64. int(2)
  65. ["zval_isref"]=>
  66. bool(false)
  67. ["strlen"]=>
  68. int(6)
  69. }
  70. array(8) {
  71. ["type"]=>
  72. string(6) "object"
  73. ["zval_hash"]=>
  74. string(16) "%s"
  75. ["zval_refcount"]=>
  76. int(2)
  77. ["zval_isref"]=>
  78. bool(false)
  79. ["object_class"]=>
  80. string(8) "stdClass"
  81. ["object_refcount"]=>
  82. int(1)
  83. ["object_hash"]=>
  84. string(32) "%s"
  85. ["object_handle"]=>
  86. int(%d)
  87. }
  88. array(5) {
  89. ["type"]=>
  90. string(5) "array"
  91. ["zval_hash"]=>
  92. string(16) "%s"
  93. ["zval_refcount"]=>
  94. int(2)
  95. ["zval_isref"]=>
  96. bool(false)
  97. ["array_count"]=>
  98. int(2)
  99. }
  100. array(7) {
  101. ["type"]=>
  102. string(8) "resource"
  103. ["zval_hash"]=>
  104. string(16) "%s"
  105. ["zval_refcount"]=>
  106. int(2)
  107. ["zval_isref"]=>
  108. bool(false)
  109. ["resource_handle"]=>
  110. int(%d)
  111. ["resource_type"]=>
  112. string(6) "stream"
  113. ["resource_refcount"]=>
  114. int(1)
  115. }
  116. array(4) {
  117. ["type"]=>
  118. string(4) "NULL"
  119. ["zval_hash"]=>
  120. string(16) "%s"
  121. ["zval_refcount"]=>
  122. int(2)
  123. ["zval_isref"]=>
  124. bool(false)
  125. }
  126. array(4) {
  127. ["type"]=>
  128. string(7) "boolean"
  129. ["zval_hash"]=>
  130. string(16) "%s"
  131. ["zval_refcount"]=>
  132. int(2)
  133. ["zval_isref"]=>
  134. bool(false)
  135. }
  136. array(4) {
  137. ["type"]=>
  138. string(7) "integer"
  139. ["zval_hash"]=>
  140. string(16) "%s"
  141. ["zval_refcount"]=>
  142. int(3)
  143. ["zval_isref"]=>
  144. bool(true)
  145. }
  146. NULL