xref: /PHP-8.1/Zend/tests/dynamic_call_005.phpt (revision 675e9751)
1--TEST--
2Dynamic calls to scope introspection functions are forbidden
3--FILE--
4<?php
5
6function test_calls($func) {
7    $i = 1;
8
9    try {
10        array_map($func, [['i' => new stdClass]]);
11        var_dump($i);
12    } catch (\Error $e) {
13        echo $e->getMessage() . "\n";
14    }
15
16    try {
17        $func(['i' => new stdClass]);
18        var_dump($i);
19    } catch (\Error $e) {
20        echo $e->getMessage() . "\n";
21    }
22
23    try {
24        call_user_func($func, ['i' => new stdClass]);
25        var_dump($i);
26    } catch (\Error $e) {
27        echo $e->getMessage() . "\n";
28    }
29}
30test_calls('extract');
31
32?>
33--EXPECT--
34Cannot call extract() dynamically
35Cannot call extract() dynamically
36Cannot call extract() dynamically
37