xref: /PHP-8.2/ext/opcache/tests/jit/gh8591-002.phpt (revision 69d263e2)
1--TEST--
2Bug GH-8591 002 (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 changes and Model is re-linked.
18
19if (!isset(opcache_get_status()['scripts'][__DIR__ . '/gh8591-002.inc'])) {
20    require __DIR__ . '/gh8591-001.inc';
21} else {
22    interface ModelInterace
23    {
24    }
25}
26
27class Model implements ModelInterface
28{
29    protected static int $field = 1;
30
31    public function __construct()
32    {
33        for ($i = 0; $i < 10; $i++) {
34            $this->cast();
35        }
36    }
37
38    private function cast()
39    {
40        global $x;
41        $x = static::$field;
42    }
43}
44
45new Model();
46
47var_dump($x);
48
49print "OK";
50--EXPECT--
51int(1)
52OK
53