xref: /PHP-8.2/ext/opcache/tests/jit/gh8591-001.phpt (revision 69d263e2)
1--TEST--
2Bug GH-8591 001 (JIT does not account for class 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
16// Checks that JITed code does not crash in --repeat 2 after the ModelInterface
17// interface is recompiled and Model is re-linked.
18
19require __DIR__ . '/gh8591-001.inc';
20
21class Model implements ModelInterface
22{
23    protected static int $field = 1;
24
25    public function __construct()
26    {
27        for ($i = 0; $i < 10; $i++) {
28            $this->cast();
29        }
30    }
31
32    private function cast()
33    {
34        global $x;
35        $x = static::$field;
36    }
37}
38
39new Model();
40
41// mark the file as changed (important)
42touch(__DIR__ . '/gh8591-001.inc');
43
44var_dump($x);
45
46print "OK";
47--EXPECT--
48int(1)
49OK
50