|
| 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 | +function test($function) { |
| 13 | + if (false |
| 14 | + /* expect input / hang */ |
| 15 | + || $function === 'readline' |
| 16 | + || $function === 'readline_read_history' |
| 17 | + || $function === 'readline_write_history' |
| 18 | + /* intentionally violate invariants */ |
| 19 | + || $function === 'zend_create_unterminated_string' |
| 20 | + || $function === 'zend_test_array_return' |
| 21 | + || $function === 'zend_leak_bytes' |
| 22 | + /* mess with output */ |
| 23 | + || (is_string($function) && str_starts_with($function, 'ob_')) |
| 24 | + || $function === 'output_add_rewrite_var' |
| 25 | + || $function === 'error_log' |
| 26 | + /* may spend a lot of time waiting for connection timeouts */ |
| 27 | + || (is_string($function) && str_contains($function, 'connect')) |
| 28 | + || (is_string($function) && str_starts_with($function, 'snmp')) |
| 29 | + || (is_array($function) && get_class($function[0]) === mysqli::class |
| 30 | + && in_array($function[1], ['__construct', 'connect', 'real_connect'])) |
| 31 | + /* misc */ |
| 32 | + || $function === 'mail' |
| 33 | + || $function === 'mb_send_mail' |
| 34 | + || $function === 'pcntl_fork' |
| 35 | + || $function === 'posix_kill' |
| 36 | + || $function === 'posix_setrlimit' |
| 37 | + || $function === 'sapi_windows_generate_ctrl_event' |
| 38 | + || $function === 'imagegrabscreen' |
| 39 | + ) { |
| 40 | + return; |
| 41 | + } |
| 42 | + if ($function[0] instanceof SoapServer) { |
| 43 | + /* TODO: Uses fatal errors */ |
| 44 | + return; |
| 45 | + } |
| 46 | + |
| 47 | + ob_start(); |
| 48 | + if (is_string($function)) { |
| 49 | + echo "Testing $function\n"; |
| 50 | + } else { |
| 51 | + echo "Testing " . get_class($function[0]) . "::$function[1]\n"; |
| 52 | + } |
| 53 | + try { |
| 54 | + @$function(); |
| 55 | + } catch (Throwable) { |
| 56 | + } |
| 57 | + try { |
| 58 | + @$function(null); |
| 59 | + } catch (Throwable) { |
| 60 | + } |
| 61 | + try { |
| 62 | + @$function(null, null); |
| 63 | + } catch (Throwable) { |
| 64 | + } |
| 65 | + try { |
| 66 | + @$function(null, null, null); |
| 67 | + } catch (Throwable) { |
| 68 | + } |
| 69 | + try { |
| 70 | + @$function(null, null, null, null); |
| 71 | + } catch (Throwable) { |
| 72 | + } |
| 73 | + try { |
| 74 | + @$function(null, null, null, null, null); |
| 75 | + } catch (Throwable) { |
| 76 | + } |
| 77 | + try { |
| 78 | + @$function(null, null, null, null, null, null); |
| 79 | + } catch (Throwable) { |
| 80 | + } |
| 81 | + try { |
| 82 | + @$function(null, null, null, null, null, null, null); |
| 83 | + } catch (Throwable) { |
| 84 | + } |
| 85 | + try { |
| 86 | + @$function(null, null, null, null, null, null, null, null); |
| 87 | + } catch (Throwable) { |
| 88 | + } |
| 89 | + ob_end_clean(); |
| 90 | +} |
| 91 | + |
| 92 | +foreach (get_defined_functions()["internal"] as $function) { |
| 93 | + test($function); |
| 94 | +} |
| 95 | + |
| 96 | +foreach (get_declared_classes() as $class) { |
| 97 | + try { |
| 98 | + $rc = new ReflectionClass($class); |
| 99 | + $obj = $rc->newInstanceWithoutConstructor(); |
| 100 | + } catch (Throwable) { |
| 101 | + continue; |
| 102 | + } |
| 103 | + |
| 104 | + foreach (get_class_methods($class) as $method) { |
| 105 | + test([$obj, $method]); |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +// var_dump() and debug_zval_dump() print all arguments |
| 110 | +?> |
| 111 | +===DONE=== |
| 112 | +--EXPECT-- |
| 113 | +===DONE=== |
0 commit comments