Skip to content

Commit 65c4a78

Browse files
committed
Merge branch 'PHP-8.0'
2 parents 77d1447 + a8e92e3 commit 65c4a78

File tree

3 files changed

+127
-31
lines changed

3 files changed

+127
-31
lines changed

Zend/tests/arginfo_zpp_mismatch.inc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
function skipFunction($function): bool {
4+
if (false
5+
/* expect input / hang */
6+
|| $function === 'readline'
7+
|| $function === 'readline_read_history'
8+
|| $function === 'readline_write_history'
9+
/* intentionally violate invariants */
10+
|| $function === 'zend_create_unterminated_string'
11+
|| $function === 'zend_test_array_return'
12+
|| $function === 'zend_leak_bytes'
13+
/* mess with output */
14+
|| (is_string($function) && str_starts_with($function, 'ob_'))
15+
|| $function === 'output_add_rewrite_var'
16+
|| $function === 'error_log'
17+
/* may spend a lot of time waiting for connection timeouts */
18+
|| (is_string($function) && str_contains($function, 'connect'))
19+
|| (is_string($function) && str_starts_with($function, 'snmp'))
20+
|| (is_array($function) && get_class($function[0]) === mysqli::class
21+
&& in_array($function[1], ['__construct', 'connect', 'real_connect']))
22+
/* misc */
23+
|| $function === 'mail'
24+
|| $function === 'mb_send_mail'
25+
|| $function === 'pcntl_fork'
26+
|| $function === 'posix_kill'
27+
|| $function === 'posix_setrlimit'
28+
|| $function === 'sapi_windows_generate_ctrl_event'
29+
|| $function === 'imagegrabscreen'
30+
) {
31+
return true;
32+
}
33+
if ($function[0] instanceof SoapServer) {
34+
/* TODO: Uses fatal errors */
35+
return true;
36+
}
37+
38+
return false;
39+
}

Zend/tests/arginfo_zpp_mismatch.phpt

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,10 @@ if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions")
77
--FILE--
88
<?php
99

10+
require __DIR__ . "/arginfo_zpp_mismatch.inc";
11+
1012
function test($function) {
11-
if (false
12-
/* expect input / hang */
13-
|| $function === 'readline'
14-
|| $function === 'readline_read_history'
15-
|| $function === 'readline_write_history'
16-
/* intentionally violate invariants */
17-
|| $function === 'zend_create_unterminated_string'
18-
|| $function === 'zend_test_array_return'
19-
|| $function === 'zend_leak_bytes'
20-
/* mess with output */
21-
|| (is_string($function) && str_starts_with($function, 'ob_'))
22-
|| $function === 'output_add_rewrite_var'
23-
|| $function === 'error_log'
24-
/* may spend a lot of time waiting for connection timeouts */
25-
|| (is_string($function) && str_contains($function, 'connect'))
26-
|| (is_string($function) && str_starts_with($function, 'snmp'))
27-
|| (is_array($function) && get_class($function[0]) === mysqli::class
28-
&& in_array($function[1], ['__construct', 'connect', 'real_connect']))
29-
/* misc */
30-
|| $function === 'mail'
31-
|| $function === 'mb_send_mail'
32-
|| $function === 'pcntl_fork'
33-
|| $function === 'posix_kill'
34-
|| $function === 'posix_setrlimit'
35-
|| $function === 'sapi_windows_generate_ctrl_event'
36-
|| $function === 'imagegrabscreen'
37-
) {
38-
return;
39-
}
40-
if ($function[0] instanceof SoapServer) {
41-
/* TODO: Uses fatal errors */
13+
if (skipFunction($function)) {
4214
return;
4315
}
4416

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
--TEST--
2+
Test that there is no arginfo/zpp mismatch in strict mode
3+
--SKIPIF--
4+
<?php
5+
if (getenv('SKIP_MSAN')) die("skip msan misses interceptors for some functions");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
declare(strict_types=1);
11+
12+
require __DIR__ . "/arginfo_zpp_mismatch.inc";
13+
14+
function test($function) {
15+
if (skipFunction($function)) {
16+
return;
17+
}
18+
19+
ob_start();
20+
if (is_string($function)) {
21+
echo "Testing $function\n";
22+
} else {
23+
echo "Testing " . get_class($function[0]) . "::$function[1]\n";
24+
}
25+
try {
26+
@$function();
27+
} catch (Throwable) {
28+
}
29+
try {
30+
@$function(null);
31+
} catch (Throwable) {
32+
}
33+
try {
34+
@$function(null, null);
35+
} catch (Throwable) {
36+
}
37+
try {
38+
@$function(null, null, null);
39+
} catch (Throwable) {
40+
}
41+
try {
42+
@$function(null, null, null, null);
43+
} catch (Throwable) {
44+
}
45+
try {
46+
@$function(null, null, null, null, null);
47+
} catch (Throwable) {
48+
}
49+
try {
50+
@$function(null, null, null, null, null, null);
51+
} catch (Throwable) {
52+
}
53+
try {
54+
@$function(null, null, null, null, null, null, null);
55+
} catch (Throwable) {
56+
}
57+
try {
58+
@$function(null, null, null, null, null, null, null, null);
59+
} catch (Throwable) {
60+
}
61+
ob_end_clean();
62+
}
63+
64+
foreach (get_defined_functions()["internal"] as $function) {
65+
test($function);
66+
}
67+
68+
foreach (get_declared_classes() as $class) {
69+
try {
70+
$rc = new ReflectionClass($class);
71+
$obj = $rc->newInstanceWithoutConstructor();
72+
} catch (Throwable) {
73+
continue;
74+
}
75+
76+
foreach (get_class_methods($class) as $method) {
77+
test([$obj, $method]);
78+
}
79+
}
80+
81+
// var_dump() and debug_zval_dump() print all arguments
82+
?>
83+
===DONE===
84+
--EXPECT--
85+
===DONE===

0 commit comments

Comments
 (0)