xref: /PHP-8.2/ext/opcache/tests/jit/gh8461-006.phpt (revision c16ad918)
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=1255
9opcache.file_update_protection=0
10opcache.revalidate_freq=0
11opcache.protect_memory=1
12--FILE--
13<?php
14
15namespace {
16    $x = 0;
17
18    function test() {
19        global $x;
20        $x += 1;
21    }
22}
23
24namespace test {
25
26    if (!isset(opcache_get_status()['scripts'][__DIR__ . '/gh8461-006.inc'])) {
27        $initialRequest = true;
28        require __DIR__ . '/gh8461-006.inc';
29
30    } else {
31        $initialRequest = false;
32        $y = 0;
33        function test() {
34            global $y;
35            $y += 1;
36        }
37    }
38
39    for ($i = 0; $i < 10; $i++) {
40        test();
41    }
42
43    var_dump($initialRequest ? $x : $y);
44    print "OK";
45}
46?>
47--EXPECT--
48int(10)
49OK
50