Permalink
Browse files

- Fix tests

- Update README.PARAMETER_PARSING_API
  • Loading branch information...
Jani Taskinen
Jani Taskinen committed Nov 2, 2007
1 parent b489251 commit a541bb80788100606c59bf5a67478234a2045a6a
Showing with 4,995 additions and 2,506 deletions.
  1. +103 −45 README.PARAMETER_PARSING_API
  2. +1 −3 Zend/tests/bug31720.phpt
  3. +6 −6 Zend/tests/bug32290.phpt
  4. +9 −6 Zend/tests/bug36214.phpt
  5. +3 −3 Zend/tests/bug37212.phpt
  6. +2 −2 Zend/tests/bug37667.phpt
  7. +5 −5 ext/dom/tests/dom003.phpt
  8. +5 −5 ext/dom/tests/dom_set_attr_node.phpt
  9. +42 −30 ext/spl/tests/array_001.phpt
  10. +17 −11 ext/spl/tests/array_002.phpt
  11. +10 −6 ext/spl/tests/array_003.phpt
  12. +1 −1 ext/spl/tests/array_004.phpt
  13. +1 −1 ext/spl/tests/array_006.phpt
  14. +14 −6 ext/spl/tests/array_007.phpt
  15. +1 −1 ext/spl/tests/array_008.phpt
  16. +38 −26 ext/spl/tests/array_015.phpt
  17. +221 −51 ext/spl/tests/array_017.phpt
  18. +8 −2 ext/spl/tests/array_018.phpt
  19. +12 −2 ext/spl/tests/array_022.phpt
  20. +1 −1 ext/spl/tests/bug31185.phpt
  21. +11 −3 ext/spl/tests/bug33136.phpt
  22. +2 −2 ext/spl/tests/bug36258.phpt
  23. +2 −8 ext/spl/tests/bug36287.phpt
  24. +2 −0 ext/spl/tests/bug40872.phpt
  25. +40 −14 ext/spl/tests/bug41692.phpt
  26. +10 −2 ext/spl/tests/bug42364.phpt
  27. +78 −54 ext/spl/tests/bug42654.phpt
  28. +3 −1 ext/spl/tests/dit_001.phpt
  29. +33 −9 ext/spl/tests/fileobject_003.phpt
  30. +1 −1 ext/spl/tests/iterator_006.phpt
  31. +1 −1 ext/spl/tests/iterator_026.phpt
  32. +49 −28 ext/spl/tests/iterator_042.phpt
  33. +2 −2 ext/spl/tests/iterator_047.phpt
  34. +5 −2 ext/spl/tests/iterator_049.phpt
  35. BIN ext/spl/tests/iterator_049b.phpt
  36. +34 −31 ext/spl/tests/iterator_050.phpt
  37. +18 −15 ext/spl/tests/iterator_051.phpt
  38. +23 −20 ext/spl/tests/iterator_052.phpt
  39. +22 −19 ext/spl/tests/iterator_053.phpt
  40. +22 −19 ext/spl/tests/iterator_054.phpt
  41. +18 −15 ext/spl/tests/iterator_055.phpt
  42. +28 −2 ext/spl/tests/observer_004.phpt
  43. +64 −14 ext/spl/tests/observer_005.phpt
  44. +1 −1 ext/spl/tests/spl_003.phpt
  45. +1 −1 ext/spl/tests/spl_004.phpt
  46. +2 −2 ext/spl/tests/spl_autoload_002.phpt
  47. +1 −1 ext/spl/tests/sxe_001.phpt
  48. +1 −1 ext/spl/tests/sxe_002.phpt
  49. +1 −1 ext/spl/tests/sxe_003.phpt
  50. +1 −1 ext/spl/tests/sxe_004.phpt
  51. +1 −1 ext/spl/tests/sxe_005.phpt
  52. +1 −1 ext/standard/tests/array/002.phpt
  53. +1 −1 ext/standard/tests/array/004.phpt
  54. +4 −4 ext/standard/tests/array/005.phpt
  55. +11 −85 ext/standard/tests/array/007.phpt
  56. +40 −219 ext/standard/tests/array/009.phpt
  57. +6 −6 ext/standard/tests/array/array_change_key_case_errors.phpt
  58. +5 −14 ext/standard/tests/array/array_change_key_case_variation.phpt
  59. +0 −1 ext/standard/tests/array/array_count_values.phpt
  60. +2 −3 ext/standard/tests/array/array_fill_basic.phpt
  61. +9 −9 ext/standard/tests/array/array_fill_error.phpt
  62. +39 −39 ext/standard/tests/array/array_fill_object.phpt
  63. +34 −46 ext/standard/tests/array/array_fill_variation1.phpt
  64. +28 −35 ext/standard/tests/array/array_fill_variation2.phpt
  65. +2 −2 ext/standard/tests/array/array_fill_variation3.phpt
  66. +3 −3 ext/standard/tests/array/array_fill_variation4.phpt
  67. +1 −1 ext/standard/tests/array/array_fill_variation5.phpt
  68. +3 −3 ext/standard/tests/array/array_filter.phpt
  69. +3 −3 ext/standard/tests/array/array_filter_error.phpt
  70. +6 −6 ext/standard/tests/array/array_filter_object.phpt
  71. +24 −24 ext/standard/tests/array/array_filter_variation1.phpt
  72. +30 −30 ext/standard/tests/array/array_filter_variation2.phpt
  73. +2 −2 ext/standard/tests/array/array_filter_variation4.phpt
  74. +1 −1 ext/standard/tests/array/array_filter_variation7.phpt
  75. +2 −2 ext/standard/tests/array/array_filter_variation9.phpt
  76. +0 −21 ext/standard/tests/array/array_flip.phpt
  77. +2 −2 ext/standard/tests/array/array_flip_error.phpt
  78. +47 −46 ext/standard/tests/array/array_flip_variation1.phpt
  79. BIN ext/standard/tests/array/array_flip_variation2.phpt
  80. BIN ext/standard/tests/array/array_flip_variation3.phpt
  81. +2 −2 ext/standard/tests/array/array_flip_variation4.phpt
  82. +10 −306 ext/standard/tests/array/array_intersect_1.phpt
  83. +2 −2 ext/standard/tests/array/array_intersect_error.phpt
  84. +1 −1 ext/standard/tests/array/array_intersect_variation9.phpt
  85. +2 −2 ext/standard/tests/array/array_key_exists.phpt
  86. +27 −0 ext/standard/tests/array/array_keys_basic.phpt
  87. +5 −5 ext/standard/tests/array/array_keys_error.phpt
  88. +15 −1 ext/standard/tests/array/array_keys_variation_003.phpt
  89. +13 −18 ext/standard/tests/array/array_map.phpt
  90. +764 −0 ext/standard/tests/array/array_merge.phpt
  91. +4 −4 ext/standard/tests/array/array_pad.phpt
  92. +4 −4 ext/standard/tests/array/array_pop_errors.phpt
  93. +282 −0 ext/standard/tests/array/array_push.phpt
  94. +2 −2 ext/standard/tests/array/array_rand.phpt
  95. +1 −0 ext/standard/tests/array/array_rand_basic1.phpt
  96. +1 −0 ext/standard/tests/array/array_rand_basic2.phpt
  97. +3 −2 ext/standard/tests/array/array_rand_error.phpt
  98. +25 −24 ext/standard/tests/array/array_rand_variation1.phpt
  99. +8 −7 ext/standard/tests/array/array_rand_variation2.phpt
  100. +1 −0 ext/standard/tests/array/array_rand_variation3.phpt
  101. +1 −0 ext/standard/tests/array/array_rand_variation4.phpt
  102. +1 −0 ext/standard/tests/array/array_rand_variation5.phpt
  103. +1 −0 ext/standard/tests/array/array_rand_variation6.phpt
  104. +3 −3 ext/standard/tests/array/array_reverse_error.phpt
  105. +72 −72 ext/standard/tests/array/array_reverse_variation1.phpt
  106. +21 −98 ext/standard/tests/array/array_reverse_variation2.phpt
  107. +3 −3 ext/standard/tests/array/array_search1.phpt
  108. +7 −7 ext/standard/tests/array/array_search_errors.phpt
  109. +1 −1 ext/standard/tests/array/array_search_variation1.phpt
  110. +4 −4 ext/standard/tests/array/array_search_variation3.phpt
  111. +1 −1 ext/standard/tests/array/array_search_variation4.phpt
  112. +1,461 −0 ext/standard/tests/array/array_slice.phpt
  113. +6 −6 ext/standard/tests/array/array_splice_errors.phpt
  114. +1 −1 ext/standard/tests/array/array_splice_variation1.phpt
  115. +2 −2 ext/standard/tests/array/array_splice_variation2.phpt
  116. +1 −1 ext/standard/tests/array/array_splice_variation3.phpt
  117. +1 −1 ext/standard/tests/array/array_splice_variation4.phpt
  118. +1 −1 ext/standard/tests/array/array_unshift_basic1.phpt
  119. +15 −53 ext/standard/tests/array/array_unshift_object.phpt
  120. +1 −1 ext/standard/tests/array/array_unshift_variation7.phpt
  121. +1 −1 ext/standard/tests/array/array_unshift_variation8.phpt
  122. +5 −5 ext/standard/tests/array/array_values_errors.phpt
  123. +5 −3 ext/standard/tests/array/array_walk.phpt
  124. +5 −3 ext/standard/tests/array/array_walk_recursive1.phpt
  125. +1 −1 ext/standard/tests/array/bug14580.phpt
  126. +1 −1 ext/standard/tests/array/bug28739.phpt
  127. +2 −3 ext/standard/tests/array/bug29253.phpt
  128. +1 −2 ext/standard/tests/array/bug33940.phpt
  129. +1 −1 ext/standard/tests/array/bug34982.phpt
  130. +1 −2 ext/standard/tests/array/bug35014.phpt
  131. +1 −2 ext/standard/tests/array/bug35014_64bit.phpt
  132. +1 −0 ext/standard/tests/array/bug35821.phpt
  133. +15 −51 ext/standard/tests/array/compact.phpt
  134. +198 −14 ext/standard/tests/array/count_recursive.phpt
  135. +6 −6 ext/standard/tests/array/end.phpt
  136. +0 −1 ext/standard/tests/array/extract_variation6.phpt
  137. +7 −7 ext/standard/tests/array/in_array_errors.phpt
  138. +4 −4 ext/standard/tests/array/in_array_variation3.phpt
  139. +3 −0 ext/standard/tests/array/locale_sort.phpt
  140. +1 −1 ext/standard/tests/array/max_basic.phpt
  141. +2 −2 ext/standard/tests/array/max_error.phpt
  142. +1 −1 ext/standard/tests/array/max_variation1.phpt
  143. +1 −1 ext/standard/tests/array/max_variation2.phpt
  144. +1 −1 ext/standard/tests/array/min_basic.phpt
  145. +2 −2 ext/standard/tests/array/min_error.phpt
  146. +1 −1 ext/standard/tests/array/min_variation1.phpt
  147. +1 −1 ext/standard/tests/array/min_variation2.phpt
  148. +1 −0 ext/standard/tests/array/shuffle_basic1.phpt
  149. +1 −0 ext/standard/tests/array/shuffle_basic2.phpt
  150. +1 −0 ext/standard/tests/array/shuffle_error.phpt
  151. +3 −1 ext/standard/tests/array/shuffle_variation1.phpt
  152. +1 −0 ext/standard/tests/array/shuffle_variation2.phpt
  153. +2 −1 ext/standard/tests/array/shuffle_variation3.phpt
  154. +2 −1 ext/standard/tests/array/shuffle_variation4.phpt
  155. +1 −0 ext/standard/tests/array/shuffle_variation5.phpt
  156. +4 −6 ext/standard/tests/general_functions/bug40398.phpt
  157. BIN ext/standard/tests/general_functions/debug_zval_dump_b.phpt
  158. BIN ext/standard/tests/general_functions/debug_zval_dump_b_64bit.phpt
  159. +78 −78 ext/standard/tests/general_functions/debug_zval_dump_o.phpt
  160. +82 −82 ext/standard/tests/general_functions/print_r.phpt
  161. +82 −82 ext/standard/tests/general_functions/print_r_64bit.phpt
  162. +192 −192 ext/standard/tests/general_functions/var_dump.phpt
  163. +192 −192 ext/standard/tests/general_functions/var_dump_64bit.phpt
  164. +1 −1 tests/classes/__set__get_005.phpt
  165. +4 −4 tests/classes/array_access_009.phpt
  166. +4 −4 tests/classes/array_access_010.phpt
  167. +6 −6 tests/classes/array_access_011.phpt
  168. +2 −2 tests/classes/bug27504.phpt
  169. +2 −2 tests/classes/clone_003.phpt
  170. +7 −7 tests/classes/private_members.phpt
@@ -31,28 +31,38 @@ resources cannot be auto-converted.
Type specifiers
---------------
- a - array
- b - boolean, stored in zend_bool
- d - double
- f - function or array containing php method call info (returned as
- zend_fcall_info* and zend_fcall_info_cache*)
- h - array (returned as HashTable*)
- l - long
- o - object (of any type)
- O - object (of specific type, specified by class entry)
- r - resource (stored in zval)
- s - string (with possible null bytes) and its length
- z - the actual zval
+ The following list shows the type specifier, its meaning and the parameter
+ types that need to be passed by address. All passed paramaters are set
+ if the PHP parameter is non optional and untouched if optional and the
+ parameter is not present. The only exception is O where the zend_class_entry*
+ has to be provided on input and is used to verify the PHP parameter is an
+ instance of that class.
+
+ a - array (zval*)
+ b - boolean (zend_bool)
+ C - class (zend_class_entry*)
+ d - double (double)
+ f - function or array containing php method call info (returned as
+ zend_fcall_info and zend_fcall_info_cache)
+ h - array (returned as HashTable*)
+ l - long (long)
+ o - object of any type (zval*)
+ O - object of specific type given by class entry (zval*, zend_class_entry)
+ r - resource (zval*)
+ s - string (with possible null bytes) and its length (char*, int)
+ z - the actual zval (zval*)
+ Z - the actual zval (zval**)
+ * - variable arguments list
The following characters also have a meaning in the specifier string:
- | - indicates that the remaining parameters are optional, they
- should be initialized to default values by the extension since they
- will not be touched by the parsing function if they are not
- passed to it.
- / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows
- ! - the parameter it follows can be of specified type or NULL (only applies
- to 's', 'a', 'o', 'O', 'r', 'h', 'C', 'z', and 'Z'). If NULL is passed,
- the results pointer is set to NULL as well.
+ | - indicates that the remaining parameters are optional, they
+ should be initialized to default values by the extension since they
+ will not be touched by the parsing function if they are not
+ passed to it.
+ / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows
+ ! - the parameter it follows can be of specified type or NULL (applies
+ to all specifiers except for 'b', 'l', and 'd'). If NULL is passed, the
+ results pointer is set to NULL as well.
Examples
--------
@@ -62,8 +72,8 @@ char *s;
int s_len;
zval *param;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsz",
- &l, &s, &s_len, &param) == FAILURE) {
- return;
+ &l, &s, &s_len, &param) == FAILURE) {
+ return;
}
@@ -72,8 +82,8 @@ zval *obj;
double d = 0.5;
zend_class_entry *my_ce;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
- &obj, my_ce, &d) == FAILURE) {
- return;
+ &obj, my_ce, &d) == FAILURE) {
+ return;
}
@@ -82,29 +92,18 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
zval *obj;
zval *arr;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!a",
- &obj, &arr) == FAILURE) {
- return;
+ &obj, &arr) == FAILURE) {
+ return;
}
/* Gets a separated array which can also be null. */
zval *arr;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!",
- &arr) == FAILURE) {
- return;
+ &arr) == FAILURE) {
+ return;
}
-
-/* Get only the first three parameters (useful for varargs functions). */
-zval *z;
-zend_bool b;
-zval *r;
-if (zend_parse_parameters(3 TSRMLS_CC, "zbr!",
- &z, &b, &r) == FAILURE) {
- return;
-}
-
-
/* Get either a set of 3 longs or a string. */
long l1, l2, l3;
char *s;
@@ -118,13 +117,72 @@ char *s;
int length;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
- "lll", &l1, &l2, &l3) == SUCCESS) {
- /* manipulate longs */
+ "lll", &l1, &l2, &l3) == SUCCESS) {
+ /* manipulate longs */
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
- "s", &s, &length) == SUCCESS) {
- /* manipulate string */
+ "s", &s, &length) == SUCCESS) {
+ /* manipulate string */
} else {
- /* output error */
+ /* output error */
+
+ return;
+}
+
+
+/* Function that accepts only varargs (0 or more) */
+
+int i, num_varargs;
+zval ***varargs = NULL;
+
+
+if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &varargs, &num_varargs) == FAILURE) {
+ return;
+}
+
+for (i = 0; i < num_varargs; i++) {
+ /* do something with varargs[i] */
+}
+
+if (varargs) {
+ efree(varargs);
+}
- return;
+
+/* Function that accepts a string, followed by varargs (1 or more) */
+
+char *str;
+int str_len;
+int i, num_varargs;
+zval ***varargs = NULL;
+
+if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s+", &str, &str_len, &varargs, &num_varargs) == FAILURE) {
+ return;
+}
+
+for (i = 0; i < num_varargs; i++) {
+ /* do something with varargs[i] */
+}
+
+if (varargs) {
+ efree(varargs);
+}
+
+
+/* Function that takes an array, followed by varargs, and ending with a long */
+long num;
+zval *array;
+int i, num_varargs;
+zval ***varargs = NULL;
+
+if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a*l", &array, &varargs, &num_varargs, &num) == FAILURE) {
+ return;
+}
+
+for (i = 0; i < num_varargs; i++) {
+ /* do something with varargs[i] */
+}
+
+if (varargs) {
+ efree(varargs);
}
+
View
@@ -10,7 +10,5 @@ array_walk($array, array($nonesuchvar,'show'));
--EXPECTF--
Notice: Undefined variable: nonesuchvar in %s on line %d
-Notice: Non-callable array passed to zend_call_function() in %s on line %d
-
-Warning: array_walk(): Unable to call Array() - function does not exist in %s on line %d
+Warning: array_walk() expects parameter 2 to be valid callback, array given in %s on line %d
===DONE===
View
@@ -1,5 +1,7 @@
--TEST--
Bug #32290 (calling call_user_func_array() ends in infinite loop within child class)
+--INI--
+error_reporting=8191
--FILE--
<?php
@@ -98,9 +100,8 @@ var_dump($x->doSomethingStatic(1));
===A===
TestB::doSomething(1)
-Strict Standards: Non-static method TestA::doSomething() cannot be called statically, assuming $this from compatible context TestB in %sbug32290.php on line %d
-TestA::doSomething(2)
-int(1)
+Warning: call_user_func_array() expects parameter 1 to be valid callback, array given in %s on line %d
+NULL
===B===
TestB::doSomethingThis(1)
@@ -110,9 +111,8 @@ int(1)
===C===
TestB::doSomethingParent(1)
-Strict Standards: Non-static method TestA::doSomethingParent() cannot be called statically, assuming $this from compatible context TestB in %sbug32290.php on line %d
-TestA::doSomethingParent(2)
-int(1)
+Warning: call_user_func_array() expects parameter 1 to be valid callback, array given in %s on line %d
+NULL
===D===
TestB::doSomethingParentThis(1)
View
@@ -33,7 +33,7 @@ $ctx->comment_preview[0] = 1;
$ctx->comment_preview[1] = 2;
var_dump($ctx->comment_preview);
?>
---EXPECT--
+--EXPECTF--
array(2) {
[0]=>
int(1)
@@ -46,9 +46,12 @@ array(2) {
[1]=>
int(2)
}
-object(ArrayObject)#2 (2) {
- [0]=>
- int(1)
- [1]=>
- int(2)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ }
}
View
@@ -41,15 +41,15 @@ var_dump($B);
===DONE===
--EXPECTF--
object(B)#%d (1) {
- ["value:protected"]=>
+ ["value":protected]=>
string(1) "B"
}
object(C)#%d (1) {
- ["value:protected"]=>
+ ["value":protected]=>
string(1) "C"
}
object(B)#%d (1) {
- ["value:protected"]=>
+ ["value":protected]=>
string(1) "C"
}
===DONE===
View
@@ -33,7 +33,7 @@ string(3) "bar"
Notice: Undefined offset: 2 in %sbug37667.php on line 16
NULL
object(Test)#%d (1) {
- ["property:protected"]=>
+ ["property":protected]=>
array(1) {
["foo"]=>
string(3) "bar"
@@ -44,7 +44,7 @@ Notice: Indirect modification of overloaded property Test::$property has no effe
Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21
object(Test)#%d (1) {
- ["property:protected"]=>
+ ["property":protected]=>
array(1) {
["foo"]=>
string(3) "bar"
View
@@ -22,15 +22,15 @@ $rootNode->appendChild($rootNode);
--EXPECTF--
--- Catch exception with try/catch
object(DOMException)#%d (6) {
- ["message:protected"]=>
+ ["message":protected]=>
string(23) "Hierarchy Request Error"
- ["string:private"]=>
+ ["string":"Exception":private]=>
string(0) ""
- ["file:protected"]=>
+ ["file":protected]=>
string(%d) "%sdom003.php"
- ["line:protected"]=>
+ ["line":protected]=>
int(8)
- ["trace:private"]=>
+ ["trace":"Exception":private]=>
array(1) {
[0]=>
array(6) {
@@ -32,15 +32,15 @@ try {
?>
--EXPECTF--
object(DOMException)#%d (6) {
- ["message:protected"]=>
+ ["message":protected]=>
string(20) "Wrong Document Error"
- ["string:private"]=>
+ ["string":"Exception":private]=>
string(0) ""
- ["file:protected"]=>
+ ["file":protected]=>
string(%d) "%sdom_set_attr_node.php"
- ["line:protected"]=>
+ ["line":protected]=>
int(%d)
- ["trace:private"]=>
+ ["trace":"Exception":private]=>
array(1) {
[0]=>
array(6) {
Oops, something went wrong.

0 comments on commit a541bb8

Please sign in to comment.