@@ -129,11 +129,20 @@ private function buildMetadataFromReflection(\ReflectionClass $ref): ClassMetada
129129 {
130130 $ attributes = [];
131131 foreach ($ ref ->getAttributes () as $ attr ) {
132+ $ instance = null ;
133+
134+ try {
135+ $ instance = $ attr ->newInstance ();
136+ } catch (\Throwable ) {
137+ // Attribute has unresolvable constructor args — store args only
138+ }
139+
132140 $ attributes [$ attr ->getName ()] = new AttributeMetadata (
133141 name: $ attr ->getName (),
134142 target: AttributeTarget::Class_,
135143 arguments: $ attr ->getArguments (),
136144 isRepeated: $ attr ->isRepeated (),
145+ instance: $ instance ,
137146 );
138147 }
139148
@@ -145,12 +154,21 @@ private function buildMetadataFromReflection(\ReflectionClass $ref): ClassMetada
145154
146155 $ methodAttrs = [];
147156 foreach ($ method ->getAttributes () as $ attr ) {
157+ $ methodInstance = null ;
158+
159+ try {
160+ $ methodInstance = $ attr ->newInstance ();
161+ } catch (\Throwable ) {
162+ // Attribute has unresolvable constructor args — store args only
163+ }
164+
148165 $ methodAttrs [$ attr ->getName ()] = new AttributeMetadata (
149166 name: $ attr ->getName (),
150167 target: AttributeTarget::Method,
151168 arguments: $ attr ->getArguments (),
152169 isRepeated: $ attr ->isRepeated (),
153170 targetName: $ method ->getName (),
171+ instance: $ methodInstance ,
154172 );
155173 }
156174
@@ -183,12 +201,21 @@ private function buildMetadataFromReflection(\ReflectionClass $ref): ClassMetada
183201
184202 $ propAttrs = [];
185203 foreach ($ prop ->getAttributes () as $ attr ) {
204+ $ propInstance = null ;
205+
206+ try {
207+ $ propInstance = $ attr ->newInstance ();
208+ } catch (\Throwable ) {
209+ // Attribute has unresolvable constructor args — store args only
210+ }
211+
186212 $ propAttrs [$ attr ->getName ()] = new AttributeMetadata (
187213 name: $ attr ->getName (),
188214 target: AttributeTarget::Property,
189215 arguments: $ attr ->getArguments (),
190216 isRepeated: $ attr ->isRepeated (),
191217 targetName: $ prop ->getName (),
218+ instance: $ propInstance ,
192219 );
193220 }
194221
0 commit comments