xref: /php-ast/tests/php81_readonly.phpt (revision 260678d4)
1--TEST--
2Readonly properties in php 8.1
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 80100) die('skip PHP >= 8.1 only'); ?>
5--FILE--
6<?php
7
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12class X {
13    public readonly int $var;
14}
15PHP;
16
17$node = ast\parse_code($code, $version=60);
18echo ast_dump($node), "\n";
19$node = ast\parse_code($code, $version=85);
20echo ast_dump($node), "\n";
21--EXPECTF--
22Deprecated: ast\parse_code(): Version 60 is deprecated in %sphp81_readonly.php on line 12
23AST_STMT_LIST
24    0: AST_CLASS
25        name: "X"
26        docComment: null
27        extends: null
28        implements: null
29        stmts: AST_STMT_LIST
30            0: AST_PROP_DECL
31                flags: MODIFIER_PUBLIC | MODIFIER_READONLY (%d)
32                0: AST_PROP_ELEM
33                    name: "var"
34                    default: null
35                    docComment: null
36        __declId: 0
37AST_STMT_LIST
38    0: AST_CLASS
39        name: "X"
40        docComment: null
41        extends: null
42        implements: null
43        stmts: AST_STMT_LIST
44            0: AST_PROP_GROUP
45                flags: MODIFIER_PUBLIC | MODIFIER_READONLY (%d)
46                type: AST_TYPE
47                    flags: TYPE_LONG (%d)
48                props: AST_PROP_DECL
49                    0: AST_PROP_ELEM
50                        name: "var"
51                        default: null
52                        docComment: null
53                attributes: null
54        attributes: null
55        type: null
56        __declId: 0