Skip to content

Commit 0832376

Browse files
committed
More arginfo/zpp verification
Run all functions with a varying number of null arguments, which helps us flush out all kinds of bugs. Closes GH-5881.
1 parent 5e34744 commit 0832376

File tree

1 file changed

+75
-16
lines changed

1 file changed

+75
-16
lines changed

Zend/tests/arginfo_zpp_mismatch.phpt

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,83 @@ Test that there is no arginfo/zpp mismatch
44
<?php
55

66
function test($function) {
7+
if (false
8+
/* expect input / hang */
9+
|| $function === 'readline'
10+
|| $function === 'readline_read_history'
11+
|| $function === 'readline_write_history'
12+
/* intentionally violate invariants */
13+
|| $function === 'zend_create_unterminated_string'
14+
|| $function === 'zend_test_array_return'
15+
|| $function === 'zend_leak_bytes'
16+
/* mess with output */
17+
|| (is_string($function) && str_starts_with($function, 'ob_'))
18+
|| $function === 'output_add_rewrite_var'
19+
|| $function === 'error_log'
20+
/* may spend a lot of time waiting for connection timeouts */
21+
|| (is_string($function) && str_contains($function, 'connect'))
22+
|| (is_string($function) && str_starts_with($function, 'snmp'))
23+
|| (is_array($function) && get_class($function[0]) === mysqli::class
24+
&& in_array($function[1], ['__construct', 'connect', 'real_connect']))
25+
/* misc */
26+
|| $function === 'mail'
27+
|| $function === 'mb_send_mail'
28+
|| $function === 'pcntl_fork'
29+
|| $function === 'posix_kill'
30+
|| $function === 'posix_setrlimit'
31+
|| $function === 'sapi_windows_generate_ctrl_event'
32+
|| $function === 'imagegrabscreen'
33+
) {
34+
return;
35+
}
36+
if ($function[0] instanceof SoapServer) {
37+
/* TODO: Uses fatal errors */
38+
return;
39+
}
40+
41+
ob_start();
42+
if (is_string($function)) {
43+
echo "Testing $function\n";
44+
} else {
45+
echo "Testing " . get_class($function[0]) . "::$function[1]\n";
46+
}
47+
try {
48+
@$function();
49+
} catch (Throwable) {
50+
}
51+
try {
52+
@$function(null);
53+
} catch (Throwable) {
54+
}
55+
try {
56+
@$function(null, null);
57+
} catch (Throwable) {
58+
}
59+
try {
60+
@$function(null, null, null);
61+
} catch (Throwable) {
62+
}
63+
try {
64+
@$function(null, null, null, null);
65+
} catch (Throwable) {
66+
}
67+
try {
68+
@$function(null, null, null, null, null);
69+
} catch (Throwable) {
70+
}
71+
try {
72+
@$function(null, null, null, null, null, null);
73+
} catch (Throwable) {
74+
}
75+
try {
76+
@$function(null, null, null, null, null, null, null);
77+
} catch (Throwable) {
78+
}
779
try {
880
@$function(null, null, null, null, null, null, null, null);
981
} catch (Throwable) {
1082
}
83+
ob_end_clean();
1184
}
1285

1386
foreach (get_defined_functions()["internal"] as $function) {
@@ -29,20 +102,6 @@ foreach (get_declared_classes() as $class) {
29102

30103
// var_dump() and debug_zval_dump() print all arguments
31104
?>
105+
===DONE===
32106
--EXPECT--
33-
NULL
34-
NULL
35-
NULL
36-
NULL
37-
NULL
38-
NULL
39-
NULL
40-
NULL
41-
NULL
42-
NULL
43-
NULL
44-
NULL
45-
NULL
46-
NULL
47-
NULL
48-
NULL
107+
===DONE===

0 commit comments

Comments
 (0)