xref: /PHP-8.1/ext/opcache/tests/jit/assign_040.phpt (revision 83f283f5)
1--TEST--
2JIT ASSIGN: Typed reference error with return value
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.jit_buffer_size=1M
8opcache.protect_memory=1
9--FILE--
10<?php
11class Test {
12    public string $x;
13}
14function test() {
15    $test = new Test;
16    $test->x = "";
17    $r =& $test->x;
18    +($r = $y);
19}
20try {
21    test();
22} catch (TypeError $e) {
23    echo $e->getMessage(), "\n";
24}
25--EXPECTF--
26Warning: Undefined variable $y in %s on line %d
27Cannot assign null to reference held by property Test::$x of type string
28