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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
--TEST--
PHP 8.3 class constant types
--SKIPIF--
<?php if (PHP_VERSION_ID < 80300) die('skip PHP >= 8.3 only'); ?>
--FILE--
<?php
require __DIR__ . '/../util.php';
$code = <<<'PHP'
<?php
class Test {
public const int X = 1, Y = 2;
const ?Foo BAR = XYZ;
}
PHP;
echo ast_dump(ast\parse_code($code, $version=90));
echo "\n\nIn version 100\n";
echo ast_dump(ast\parse_code($code, $version=100));
--EXPECT--
AST_STMT_LIST
0: AST_CLASS
name: "Test"
docComment: null
extends: null
implements: null
stmts: AST_STMT_LIST
0: AST_CLASS_CONST_GROUP
flags: MODIFIER_PUBLIC (1)
const: AST_CLASS_CONST_DECL
0: AST_CONST_ELEM
name: "X"
value: 1
docComment: null
1: AST_CONST_ELEM
name: "Y"
value: 2
docComment: null
attributes: null
1: AST_CLASS_CONST_GROUP
flags: MODIFIER_PUBLIC (1)
const: AST_CLASS_CONST_DECL
0: AST_CONST_ELEM
name: "BAR"
value: AST_CONST
name: AST_NAME
flags: NAME_NOT_FQ (1)
name: "XYZ"
docComment: null
attributes: null
attributes: null
type: null
__declId: 0
In version 100
AST_STMT_LIST
0: AST_CLASS
name: "Test"
docComment: null
extends: null
implements: null
stmts: AST_STMT_LIST
0: AST_CLASS_CONST_GROUP
flags: MODIFIER_PUBLIC (1)
const: AST_CLASS_CONST_DECL
0: AST_CONST_ELEM
name: "X"
value: 1
docComment: null
1: AST_CONST_ELEM
name: "Y"
value: 2
docComment: null
attributes: null
type: AST_TYPE
flags: TYPE_LONG (4)
1: AST_CLASS_CONST_GROUP
flags: MODIFIER_PUBLIC (1)
const: AST_CLASS_CONST_DECL
0: AST_CONST_ELEM
name: "BAR"
value: AST_CONST
name: AST_NAME
flags: NAME_NOT_FQ (1)
name: "XYZ"
docComment: null
attributes: null
type: AST_NULLABLE_TYPE
type: AST_NAME
flags: NAME_NOT_FQ (1)
name: "Foo"
attributes: null
type: null
__declId: 0
|