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