File tree Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ module.exports = {
3232 }
3333 }
3434
35+ // https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1546
3536 if ( id === this . tok . T_ENUM ) {
3637 if ( this . version < 801 ) {
3738 return this . tok . T_STRING ;
@@ -41,10 +42,16 @@ module.exports = {
4142 while ( ch == " " ) {
4243 ch = this . input ( ) ;
4344 }
45+ let isEnum = false ;
46+ if ( this . is_LABEL_START ( ) ) {
47+ while ( this . is_LABEL ( ) ) {
48+ ch += this . input ( ) ;
49+ }
50+ isEnum = ! ch . startsWith ( "extends" ) && ! ch . startsWith ( "implements" ) ;
51+ }
4452
45- const is_enum = this . is_LABEL_START ( ) ;
4653 this . unput ( this . offset - initial ) ;
47- return is_enum ? this . tok . T_ENUM : this . tok . T_STRING ;
54+ return isEnum ? this . tok . T_ENUM : this . tok . T_STRING ;
4855 }
4956
5057 if ( this . offset < this . size && id !== this . tok . T_YIELD_FROM ) {
Original file line number Diff line number Diff line change @@ -351,6 +351,44 @@ Program {
351351 " nullable" : false ,
352352 " type" : null ,
353353 },
354+ Class {
355+ " attrGroups" : Array [],
356+ " body" : Array [],
357+ " extends" : Name {
358+ " kind" : " name" ,
359+ " name" : " Foo" ,
360+ " resolution" : " uqn" ,
361+ },
362+ " implements" : null ,
363+ " isAbstract" : false ,
364+ " isAnonymous" : false ,
365+ " isFinal" : false ,
366+ " kind" : " class" ,
367+ " name" : Identifier {
368+ " kind" : " identifier" ,
369+ " name" : " Enum" ,
370+ },
371+ },
372+ Class {
373+ " attrGroups" : Array [],
374+ " body" : Array [],
375+ " extends" : null ,
376+ " implements" : Array [
377+ Name {
378+ " kind" : " name" ,
379+ " name" : " Foo" ,
380+ " resolution" : " uqn" ,
381+ },
382+ ],
383+ " isAbstract" : false ,
384+ " isAnonymous" : false ,
385+ " isFinal" : false ,
386+ " kind" : " class" ,
387+ " name" : Identifier {
388+ " kind" : " identifier" ,
389+ " name" : " Enum" ,
390+ },
391+ },
354392 ],
355393 " errors" : Array [],
356394 " kind" : " program" ,
Original file line number Diff line number Diff line change @@ -98,6 +98,8 @@ describe("Test enums", function () {
9898 interface Enum {}
9999 trait Enum {}
100100 function enum() {}
101+ class Enum extends Foo {}
102+ class Enum implements Foo {}
101103 ` )
102104 ) . toMatchSnapshot ( ) ;
103105 } ) ;
You can’t perform that action at this time.
0 commit comments