xref: /PHP-8.3/ext/opcache/tests/jit/gh8461-004.phpt (revision 6c254131)
1--TEST--
2Bug GH-8461 004 (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 UniqueList
17// class changes.
18
19if (!isset(opcache_get_status()['scripts'][__DIR__ . '/gh8461-004.inc'])) {
20    $initialRequest = true;
21    require __DIR__ . '/gh8461-004.inc';
22
23} else {
24    $initialRequest = false;
25    $y = 0;
26
27    class UniqueList
28    {
29        public const A = 1;
30        public const B = 1;
31
32        private $foo;
33
34        public function __construct($b)
35        {
36            global $y;
37            $y++;
38
39            $this->foo = self::A + $b;
40        }
41    }
42}
43
44class UniqueListLast extends UniqueList
45{
46    public function __construct()
47    {
48        parent::__construct(self::B);
49    }
50}
51
52for ($i = 0; $i < 10; $i++) {
53    new UniqueListLast();
54}
55
56var_dump($initialRequest ? $x : $y);
57print "OK";
58--EXPECT--
59int(10)
60OK
61