xref: /PHP-8.3/ext/opcache/tests/jit/gh8461-008.phpt (revision 6c254131)
1--TEST--
2Bug GH-8461 008 (JIT does not account for function 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$x = 0;
17
18class UniqueList
19{
20    const A = 1;
21    const B = 1;
22
23    private $foo;
24
25    public function __construct($b)
26    {
27        global $x;
28        $x++;
29
30        $this->foo = self::A + $b;
31    }
32
33    public static function foo()
34    {
35        global $x;
36        $x += self::A;
37    }
38}
39
40class UniqueListLast extends UniqueList
41{
42    public function __construct()
43    {
44        parent::__construct(self::B);
45    }
46
47    public static function bar() {
48        parent::foo();
49    }
50}
51
52function test() {
53        global $x;
54        $x += 1;
55}
56
57for ($i = 0; $i < 100; $i++) {
58    UniqueListLast::bar();
59}
60
61for ($i = 0; $i < 100; $i++) {
62    new UniqueListLast();
63}
64
65for ($i = 0; $i < 10; $i++) {
66    test();
67}
68
69print "OK";
70--EXPECT--
71OK
72