File: dump_property_hooks.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (70 lines) | stat: -rw-r--r-- 1,402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--TEST--
Optimizer optimizes hooks, OpCache dump emits them
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.opt_debug_level=0x20000
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (PHP_OS_FAMILY === 'Windows') {
    die('skip Windows emits additional DECLARE_CLASS_DELAYED opcode');
}
?>
--FILE--
<?php

class A {
    public int $prop {
        get {
            return 42;
            echo 'Dead code';
        }
        set {
            echo "Setting $value";
            return;
            echo 'Dead code';
        }
    }
}

$a = new A();
var_dump($a->prop);
$a->prop = 41;

?>
--EXPECTF--
$_main:
     ; (lines=10, args=0, vars=1, tmps=%d)
     ; (after optimizer)
     ; %sdump_property_hooks.php:1-22
0000 V1 = NEW 0 string("A")
0001 DO_FCALL
0002 ASSIGN CV0($a) V1
0003 INIT_FCALL 1 %d string("var_dump")
0004 T1 = FETCH_OBJ_R CV0($a) string("prop")
0005 SEND_VAL T1 1
0006 DO_ICALL
0007 ASSIGN_OBJ CV0($a) string("prop")
0008 OP_DATA int(41)
0009 RETURN int(1)
LIVE RANGES:
     1: 0001 - 0002 (new)

A::$prop::get:
     ; (lines=1, args=0, vars=0, tmps=%d)
     ; (after optimizer)
     ; %sdump_property_hooks.php:5-8
0000 RETURN int(42)

A::$prop::set:
     ; (lines=4, args=1, vars=1, tmps=%d)
     ; (after optimizer)
     ; %sdump_property_hooks.php:9-13
0000 CV0($value) = RECV 1
0001 T1 = FAST_CONCAT string("Setting ") CV0($value)
0002 ECHO T1
0003 RETURN null
int(42)
Setting 41