xref: /PHP-8.1/ext/opcache/tests/jit/gh8461-006.phpt (revision 6c254131)
1--TEST--
2Bug GH-8461 006 (JIT does not account for function re-compile)
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.jit_buffer_size=1M
9opcache.jit=1255
10opcache.file_update_protection=0
11opcache.revalidate_freq=0
12opcache.protect_memory=1
13--FILE--
14<?php
15
16namespace {
17    $x = 0;
18
19    function test() {
20        global $x;
21        $x += 1;
22    }
23}
24
25namespace test {
26
27    if (!isset(opcache_get_status()['scripts'][__DIR__ . '/gh8461-006.inc'])) {
28        $initialRequest = true;
29        require __DIR__ . '/gh8461-006.inc';
30
31    } else {
32        $initialRequest = false;
33        $y = 0;
34        function test() {
35            global $y;
36            $y += 1;
37        }
38    }
39
40    for ($i = 0; $i < 10; $i++) {
41        test();
42    }
43
44    var_dump($initialRequest ? $x : $y);
45    print "OK";
46}
47--EXPECT--
48int(10)
49OK
50