php-parser/test/code/parser/stmt/class/enum_with_string.test
Tomas Votruba f68e1a43ff
[PHP 8.1] Add support for enums (#758)
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-04-25 21:11:36 +02:00

67 lines
1.4 KiB
Plaintext

Enum
-----
<?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds;
case Clubs = 'C';
case Spades = 'S';
}
-----
!!php7
array(
0: Stmt_Enum(
attrGroups: array(
)
name: Identifier(
name: Suit
)
scalarType: Identifier(
name: string
)
implements: array(
)
stmts: array(
0: Stmt_EnumCase(
attrGroups: array(
)
name: Identifier(
name: Hearts
)
expr: Scalar_String(
value: H
)
)
1: Stmt_EnumCase(
attrGroups: array(
)
name: Identifier(
name: Diamonds
)
expr: null
)
2: Stmt_EnumCase(
attrGroups: array(
)
name: Identifier(
name: Clubs
)
expr: Scalar_String(
value: C
)
)
3: Stmt_EnumCase(
attrGroups: array(
)
name: Identifier(
name: Spades
)
expr: Scalar_String(
value: S
)
)
)
)
)