@@ -21,6 +21,7 @@ pub struct StructAttributes {
2121 rename : PhpRename ,
2222 #[ darling( multiple) ]
2323 extends : Vec < ClassEntryAttribute > ,
24+ attrs : Vec < syn:: Attribute > ,
2425}
2526
2627pub fn parser ( mut input : ItemTrait ) -> Result < TokenStream > {
@@ -46,6 +47,7 @@ struct InterfaceData<'a> {
4647 constructor : Option < Function < ' a > > ,
4748 methods : Vec < FnBuilder > ,
4849 constants : Vec < Constant < ' a > > ,
50+ docs : Vec < String > ,
4951}
5052
5153impl ToTokens for InterfaceData < ' _ > {
@@ -56,6 +58,7 @@ impl ToTokens for InterfaceData<'_> {
5658 let implements = & self . attrs . extends ;
5759 let methods_sig = & self . methods ;
5860 let constants = & self . constants ;
61+ let docs = & self . docs ;
5962
6063 let _constructor = self
6164 . constructor
@@ -81,6 +84,10 @@ impl ToTokens for InterfaceData<'_> {
8184 #( #implements, ) *
8285 ] ;
8386
87+ const DOC_COMMENTS : & ' static [ & ' static str ] = & [
88+ #( #docs, ) *
89+ ] ;
90+
8491 fn get_metadata( ) -> & ' static :: ext_php_rs:: class:: ClassMetadata <Self > {
8592 static METADATA : :: ext_php_rs:: class:: ClassMetadata <#interface_name> =
8693 :: ext_php_rs:: class:: ClassMetadata :: new( ) ;
@@ -108,7 +115,7 @@ impl ToTokens for InterfaceData<'_> {
108115 }
109116
110117 fn get_properties<' a>( ) -> :: std:: collections:: HashMap <& ' static str , :: ext_php_rs:: internal:: property:: PropertyInfo <' a, Self >> {
111- panic!( "Non supported for Interface" ) ;
118+ panic!( "Not supported for Interface" ) ;
112119 }
113120 }
114121
@@ -179,38 +186,26 @@ impl ToTokens for InterfaceData<'_> {
179186 }
180187}
181188
182- impl < ' a > InterfaceData < ' a > {
183- fn new (
184- ident : & ' a Ident ,
185- name : String ,
186- path : Path ,
187- attrs : StructAttributes ,
188- constructor : Option < Function < ' a > > ,
189- methods : Vec < FnBuilder > ,
190- constants : Vec < Constant < ' a > > ,
191- ) -> Self {
192- Self {
193- ident,
194- name,
195- path,
196- attrs,
197- constructor,
198- methods,
199- constants,
200- }
201- }
202- }
203-
204189impl < ' a > Parse < ' a , InterfaceData < ' a > > for ItemTrait {
205190 fn parse ( & ' a mut self ) -> Result < InterfaceData < ' a > > {
206191 let attrs = StructAttributes :: from_attributes ( & self . attrs ) ?;
207192 let ident = & self . ident ;
208193 let name = attrs. rename . rename ( ident. to_string ( ) , RenameRule :: Pascal ) ;
194+ let docs = get_docs ( & attrs. attrs ) ?;
209195 self . attrs . clean_php ( ) ;
210196 let interface_name = format_ident ! ( "PhpInterface{ident}" ) ;
211197 let ts = quote ! { #interface_name } ;
212198 let path: Path = syn:: parse2 ( ts) ?;
213- let mut data = InterfaceData :: new ( ident, name, path, attrs, None , Vec :: new ( ) , Vec :: new ( ) ) ;
199+ let mut data = InterfaceData {
200+ ident,
201+ name,
202+ path,
203+ attrs,
204+ constructor : None ,
205+ methods : Vec :: default ( ) ,
206+ constants : Vec :: default ( ) ,
207+ docs,
208+ } ;
214209
215210 for item in & mut self . items {
216211 match item {
0 commit comments