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