@@ -12,7 +12,7 @@ module.exports = {
12
12
* class ::= class_scope? T_CLASS T_STRING (T_EXTENDS NAMESPACE_NAME)? (T_IMPLEMENTS (NAMESPACE_NAME ',')* NAMESPACE_NAME)? '{' CLASS_BODY '}'
13
13
* ```
14
14
*/
15
- read_class_declaration_statement : function ( ) {
15
+ read_class_declaration_statement : function ( attrs ) {
16
16
const result = this . node ( "class" ) ;
17
17
const flag = this . read_class_modifiers ( ) ;
18
18
// graceful mode : ignore token & go next
@@ -30,7 +30,9 @@ module.exports = {
30
30
const propImplements = this . read_implements_list ( ) ;
31
31
this . expect ( "{" ) ;
32
32
const body = this . next ( ) . read_class_body ( ) ;
33
- return result ( propName , propExtends , propImplements , body , flag ) ;
33
+ const node = result ( propName , propExtends , propImplements , body , flag ) ;
34
+ if ( attrs ) node . attrs = attrs ;
35
+ return node ;
34
36
} ,
35
37
36
38
read_class_modifiers : function ( ) {
@@ -59,7 +61,7 @@ module.exports = {
59
61
*/
60
62
read_class_body : function ( ) {
61
63
let result = [ ] ;
62
-
64
+ let attrs = [ ] ;
63
65
while ( this . token !== this . EOF && this . token !== "}" ) {
64
66
if ( this . token === this . tok . T_COMMENT ) {
65
67
result . push ( this . read_comment ( ) ) ;
@@ -77,6 +79,9 @@ module.exports = {
77
79
continue ;
78
80
}
79
81
82
+ if ( this . token === this . tok . T_ATTRIBUTE ) {
83
+ attrs = this . read_attr_list ( ) ;
84
+ }
80
85
// read member flags
81
86
const flags = this . read_member_flags ( false ) ;
82
87
@@ -99,7 +104,7 @@ module.exports = {
99
104
100
105
if ( this . token === this . tok . T_FUNCTION ) {
101
106
// reads a function
102
- result . push ( this . read_function ( false , flags ) ) ;
107
+ result . push ( this . read_function ( false , flags , attrs ) ) ;
103
108
} else if (
104
109
this . token === this . tok . T_VARIABLE ||
105
110
// support https://wiki.php.net/rfc/typed_properties_v2
0 commit comments