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