001.phpt 2.6 KB

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