@@ -680,6 +680,60 @@ impl Backend {
680680 mixins,
681681 } ) ;
682682 }
683+ Statement :: Enum ( enum_def) => {
684+ let enum_name = enum_def. name . value . to_string ( ) ;
685+
686+ let ( mut methods, mut properties, constants, used_traits) =
687+ Self :: extract_class_like_members ( enum_def. members . iter ( ) , doc_ctx) ;
688+
689+ // Extract @property, @method, and @mixin tags from the enum-level docblock.
690+ let mut mixins = Vec :: new ( ) ;
691+ if let Some ( ctx) = doc_ctx
692+ && let Some ( doc_text) =
693+ docblock:: get_docblock_text_for_node ( ctx. trivias , ctx. content , enum_def)
694+ {
695+ for ( name, type_str) in docblock:: extract_property_tags ( doc_text) {
696+ if !properties. iter ( ) . any ( |p| p. name == name) {
697+ properties. push ( PropertyInfo {
698+ name,
699+ type_hint : if type_str. is_empty ( ) {
700+ None
701+ } else {
702+ Some ( type_str)
703+ } ,
704+ is_static : false ,
705+ visibility : Visibility :: Public ,
706+ } ) ;
707+ }
708+ }
709+
710+ for method_info in docblock:: extract_method_tags ( doc_text) {
711+ if !methods. iter ( ) . any ( |m| m. name == method_info. name ) {
712+ methods. push ( method_info) ;
713+ }
714+ }
715+
716+ mixins = docblock:: extract_mixin_tags ( doc_text) ;
717+ }
718+
719+ // Enums can implement interfaces but cannot extend classes.
720+ let parent_class = None ;
721+
722+ let start_offset = enum_def. left_brace . start . offset ;
723+ let end_offset = enum_def. right_brace . end . offset ;
724+
725+ classes. push ( ClassInfo {
726+ name : enum_name,
727+ methods,
728+ properties,
729+ constants,
730+ start_offset,
731+ end_offset,
732+ parent_class,
733+ used_traits,
734+ mixins,
735+ } ) ;
736+ }
683737 Statement :: Namespace ( namespace) => {
684738 Self :: extract_classes_from_statements (
685739 namespace. statements ( ) . iter ( ) ,
@@ -813,12 +867,19 @@ impl Backend {
813867 } ) ;
814868 }
815869 }
870+ ClassLikeMember :: EnumCase ( enum_case) => {
871+ let case_name = enum_case. item . name ( ) . value . to_string ( ) ;
872+ constants. push ( ConstantInfo {
873+ name : case_name,
874+ type_hint : None ,
875+ visibility : Visibility :: Public ,
876+ } ) ;
877+ }
816878 ClassLikeMember :: TraitUse ( trait_use) => {
817879 for trait_name_ident in trait_use. trait_names . iter ( ) {
818880 used_traits. push ( trait_name_ident. value ( ) . to_string ( ) ) ;
819881 }
820882 }
821- _ => { }
822883 }
823884 }
824885
@@ -861,7 +922,10 @@ impl Backend {
861922 Statement :: Use ( use_stmt) => {
862923 Self :: extract_use_items ( & use_stmt. items , & mut use_map) ;
863924 }
864- Statement :: Class ( _) | Statement :: Interface ( _) | Statement :: Trait ( _) => {
925+ Statement :: Class ( _)
926+ | Statement :: Interface ( _)
927+ | Statement :: Trait ( _)
928+ | Statement :: Enum ( _) => {
865929 Self :: extract_classes_from_statements (
866930 std:: iter:: once ( inner) ,
867931 & mut classes,
@@ -884,7 +948,10 @@ impl Backend {
884948 }
885949 }
886950 }
887- Statement :: Class ( _) | Statement :: Interface ( _) | Statement :: Trait ( _) => {
951+ Statement :: Class ( _)
952+ | Statement :: Interface ( _)
953+ | Statement :: Trait ( _)
954+ | Statement :: Enum ( _) => {
888955 Self :: extract_classes_from_statements (
889956 std:: iter:: once ( statement) ,
890957 & mut classes,
0 commit comments