2020use VeeWee \Reflecta \Lens \Lens ;
2121use function is_array ;
2222use function Psl \Dict \map ;
23- use function Psl \Dict \pull ;
23+ use function Psl \Dict \map_with_key ;
2424use function Psl \Dict \reindex ;
2525use function Psl \Iter \any ;
2626use function Psl \Vec \sort_by ;
@@ -102,16 +102,16 @@ private function to(Context $context, array $properties, object|array $data): st
102102 XsiTypeDetector::detectFromValue ($ context , []),
103103 includeXsiTargetNamespace: !$ isAnyPropertyQualified ,
104104 )),
105- ...map (
105+ ...map_with_key (
106106 $ properties ,
107- function (Property $ property ) use ($ context , $ data , $ defaultAction ) : Closure {
107+ function (string $ normalizePropertyName , Property $ property ) use ($ context , $ data , $ defaultAction ) : Closure {
108108 $ type = $ property ->getType ();
109109 $ meta = $ type ->getMeta ();
110110 $ isAttribute = $ meta ->isAttribute ()->unwrapOr (false );
111111
112112 /** @var mixed $value */
113113 $ value = $ this ->runLens (
114- property (PhpPropertyNameNormalizer:: normalize ( $ property -> getName ()) ),
114+ property ($ normalizePropertyName ),
115115 $ meta ,
116116 $ data ,
117117 null
@@ -146,7 +146,7 @@ private function from(Context $context, array $properties, Element $data): objec
146146 $ objectData = object_data ($ this ->className );
147147
148148 return $ objectData ->from (
149- pull (
149+ map (
150150 $ properties ,
151151 function (Property $ property ) use ($ context , $ nodes ): mixed {
152152 $ type = $ property ->getType ();
@@ -167,7 +167,6 @@ function (Property $property) use ($context, $nodes): mixed {
167167 default => $ value !== null ? $ this ->grabIsoForProperty ($ context , $ property )->from ($ value ) : $ defaultValue ,
168168 };
169169 },
170- static fn (Property $ property ) => PhpPropertyNameNormalizer::normalize ($ property ->getName ()),
171170 )
172171 );
173172 }
@@ -178,9 +177,9 @@ function (Property $property) use ($context, $nodes): mixed {
178177 private function grabIsoForProperty (Context $ context , Property $ property ): Iso
179178 {
180179 $ propertyContext = $ context ->withType ($ property ->getType ());
181- $ encoder = $ context ->registry ->detectEncoderForContext ($ propertyContext );
182180
183- return $ encoder ->iso ($ propertyContext );
181+ return $ context ->registry ->detectEncoderForContext ($ propertyContext )
182+ ->iso ($ propertyContext );
184183 }
185184
186185 private function runLens (Lens $ lens , TypeMeta $ meta , mixed $ data , mixed $ default ): mixed
@@ -229,7 +228,7 @@ private function detectProperties(Context $context): array
229228 $ type ->getProperties (),
230229 static fn (Property $ property ): bool => !$ property ->getType ()->getMeta ()->isAttribute ()->unwrapOr (false ),
231230 ),
232- static fn (Property $ property ): string => $ property ->getName (),
231+ static fn (Property $ property ): string => PhpPropertyNameNormalizer:: normalize ( $ property ->getName () ),
233232 );
234233 }
235234}
0 commit comments