xref: /php-src/ext/opcache/tests/jit/gh8863.phpt (revision c16ad918)
1--TEST--
2Bug GH-8863: RW operation on readonly property doesn't throw with JIT
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7--FILE--
8<?php
9class Test {
10    public readonly int $prop;
11
12    public function __construct() {
13        $this->prop = 1;
14    }
15
16    public function rw() {
17        $this->prop += 1;
18        echo "Done\n";
19    }
20}
21
22$test = new Test();
23try {
24    $test->rw();
25} catch (Error $e) {
26    echo $e->getMessage(), "\n";
27}
28?>
29DONE
30--EXPECT--
31Cannot modify readonly property Test::$prop
32DONE
33