@@ -82,7 +82,7 @@ private function setupInheritance(ClassLike $class, \ReflectionClass $from): voi
8282 }
8383
8484 $ class ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
85- $ class ->setAttributes ($ this ->getAttributes ($ from ));
85+ $ class ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
8686 if ($ from ->getParentClass ()) {
8787 $ class ->setExtends ($ from ->getParentClass ()->name );
8888 $ class ->setImplements (array_values (array_diff ($ class ->getImplements (), $ from ->getParentClass ()->getInterfaceNames ())));
@@ -188,7 +188,7 @@ public function fromMethodReflection(\ReflectionMethod $from): Method
188188 $ method ->setReturnReference ($ from ->returnsReference ());
189189 $ method ->setVariadic ($ from ->isVariadic ());
190190 $ method ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
191- $ method ->setAttributes ($ this ->getAttributes ($ from ));
191+ $ method ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
192192 $ method ->setReturnType ((string ) $ from ->getReturnType ());
193193
194194 return $ method ;
@@ -205,7 +205,7 @@ public function fromFunctionReflection(\ReflectionFunction $from, bool $withBody
205205 $ function ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
206206 }
207207
208- $ function ->setAttributes ($ this ->getAttributes ($ from ));
208+ $ function ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
209209 $ function ->setReturnType ((string ) $ from ->getReturnType ());
210210
211211 if ($ withBody ) {
@@ -259,7 +259,7 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
259259 }
260260 }
261261
262- $ param ->setAttributes ($ this ->getAttributes ($ from ));
262+ $ param ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
263263 return $ param ;
264264 }
265265
@@ -271,7 +271,7 @@ public function fromConstantReflection(\ReflectionClassConstant $from): Constant
271271 $ const ->setVisibility ($ this ->getVisibility ($ from ));
272272 $ const ->setFinal ($ from ->isFinal ());
273273 $ const ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
274- $ const ->setAttributes ($ this ->getAttributes ($ from ));
274+ $ const ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
275275 return $ const ;
276276 }
277277
@@ -281,7 +281,7 @@ public function fromCaseReflection(\ReflectionClassConstant $from): EnumCase
281281 $ const = new EnumCase ($ from ->name );
282282 $ const ->setValue ($ from ->getValue ()->value ?? null );
283283 $ const ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
284- $ const ->setAttributes ($ this ->getAttributes ($ from ));
284+ $ const ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
285285 return $ const ;
286286 }
287287
@@ -297,7 +297,7 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
297297 $ prop ->setInitialized ($ from ->hasType () && array_key_exists ($ prop ->getName (), $ defaults ));
298298 $ prop ->setReadOnly ($ from ->isReadOnly ());
299299 $ prop ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
300- $ prop ->setAttributes ($ this ->getAttributes ($ from ));
300+ $ prop ->setAttributes ($ this ->formatAttributes ($ from-> getAttributes () ));
301301
302302 if (PHP_VERSION_ID >= 80400 ) {
303303 $ this ->addHooks ($ from , $ prop );
@@ -341,7 +341,7 @@ private function addHooks(\ReflectionProperty $from, Property|PromotedParameter
341341 ->setFinal ($ hook ->isFinal ())
342342 ->setReturnReference ($ hook ->returnsReference ())
343343 ->setComment (Helpers::unformatDocComment ((string ) $ hook ->getDocComment ()))
344- ->setAttributes ($ this ->getAttributes ($ hook ));
344+ ->setAttributes ($ this ->formatAttributes ($ hook-> getAttributes () ));
345345 }
346346 }
347347
@@ -367,18 +367,19 @@ public function fromCode(string $code): PhpFile
367367
368368
369369 /** @return Attribute[] */
370- private function getAttributes ( $ from ): array
370+ private function formatAttributes ( array $ attrs ): array
371371 {
372- return array_map (function ($ attr ) {
372+ $ res = [];
373+ foreach ($ attrs as $ attr ) {
373374 $ args = $ attr ->getArguments ();
374375 foreach ($ args as &$ arg ) {
375376 if (is_object ($ arg )) {
376377 $ arg = $ this ->fromObject ($ arg );
377378 }
378379 }
379-
380- return new Attribute ( $ attr -> getName (), $ args );
381- }, $ from -> getAttributes ()) ;
380+ $ res [] = new Attribute ( $ attr -> getName (), $ args );
381+ }
382+ return $ res ;
382383 }
383384
384385
0 commit comments