xref: /php-ast/tests/php84_property_hook.phpt (revision 1fc2c3a1)
1--TEST--
2Property hooks in php 8.4
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 80400) die('skip PHP >=8.4 only'); ?>
5--FILE--
6<?php
7
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12abstract class A {
13    abstract public $prop { get; set; }
14}
15PHP;
16
17$node = ast\parse_code($code, $version=110);
18echo ast_dump($node), "\n";
19--EXPECTF--
20AST_STMT_LIST
21    0: AST_CLASS
22        flags: CLASS_ABSTRACT (%d)
23        name: "A"
24        docComment: null
25        extends: null
26        implements: null
27        stmts: AST_STMT_LIST
28            0: AST_PROP_GROUP
29                flags: MODIFIER_PUBLIC | MODIFIER_ABSTRACT (%d)
30                type: null
31                props: AST_PROP_DECL
32                    0: AST_PROP_ELEM
33                        name: "prop"
34                        default: null
35                        docComment: null
36                        hooks: AST_STMT_LIST
37                            0: AST_PROPERTY_HOOK
38                                name: "get"
39                                docComment: null
40                                params: null
41                                stmts: null
42                                attributes: null
43                                __declId: 0
44                            1: AST_PROPERTY_HOOK
45                                name: "set"
46                                docComment: null
47                                params: null
48                                stmts: null
49                                attributes: null
50                                __declId: 1
51                attributes: null
52        attributes: null
53        type: null
54        __declId: 2
55