@@ -150,7 +150,7 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
150
150
return \is_object ($ data ) && !$ data instanceof \Traversable;
151
151
}
152
152
153
- public function normalize (mixed $ object , ?string $ format = null , array $ context = []): array |string |int |float |bool |\ArrayObject |null
153
+ public function normalize (mixed $ data , ?string $ format = null , array $ context = []): array |string |int |float |bool |\ArrayObject |null
154
154
{
155
155
$ context ['_read_attributes ' ] = true ;
156
156
@@ -160,14 +160,14 @@ public function normalize(mixed $object, ?string $format = null, array $context
160
160
161
161
$ this ->validateCallbackContext ($ context );
162
162
163
- if ($ this ->isCircularReference ($ object , $ context )) {
164
- return $ this ->handleCircularReference ($ object , $ format , $ context );
163
+ if ($ this ->isCircularReference ($ data , $ context )) {
164
+ return $ this ->handleCircularReference ($ data , $ format , $ context );
165
165
}
166
166
167
- $ data = [];
167
+ $ normalized = [];
168
168
$ stack = [];
169
- $ attributes = $ this ->getAttributes ($ object , $ format , $ context );
170
- $ class = ($ this ->objectClassResolver )($ object );
169
+ $ attributes = $ this ->getAttributes ($ data , $ format , $ context );
170
+ $ class = ($ this ->objectClassResolver )($ data );
171
171
$ classMetadata = $ this ->classMetadataFactory ?->getMetadataFor($ class );
172
172
$ attributesMetadata = $ this ->classMetadataFactory ?->getMetadataFor($ class )->getAttributesMetadata ();
173
173
if (isset ($ context [self ::MAX_DEPTH_HANDLER ])) {
@@ -185,12 +185,12 @@ public function normalize(mixed $object, ?string $format = null, array $context
185
185
continue ;
186
186
}
187
187
188
- $ attributeContext = $ this ->getAttributeNormalizationContext ($ object , $ attribute , $ context );
188
+ $ attributeContext = $ this ->getAttributeNormalizationContext ($ data , $ attribute , $ context );
189
189
190
190
try {
191
- $ attributeValue = $ attribute === $ this ->classDiscriminatorResolver ?->getMappingForMappedObject($ object )?->getTypeProperty()
192
- ? $ this ->classDiscriminatorResolver ?->getTypeForMappedObject($ object )
193
- : $ this ->getAttributeValue ($ object , $ attribute , $ format , $ attributeContext );
191
+ $ attributeValue = $ attribute === $ this ->classDiscriminatorResolver ?->getMappingForMappedObject($ data )?->getTypeProperty()
192
+ ? $ this ->classDiscriminatorResolver ?->getTypeForMappedObject($ data )
193
+ : $ this ->getAttributeValue ($ data , $ attribute , $ format , $ attributeContext );
194
194
} catch (UninitializedPropertyException |\Error $ e ) {
195
195
if (($ context [self ::SKIP_UNINITIALIZED_VALUES ] ?? $ this ->defaultContext [self ::SKIP_UNINITIALIZED_VALUES ] ?? true ) && $ this ->isUninitializedValueError ($ e )) {
196
196
continue ;
@@ -199,17 +199,17 @@ public function normalize(mixed $object, ?string $format = null, array $context
199
199
}
200
200
201
201
if ($ maxDepthReached ) {
202
- $ attributeValue = $ maxDepthHandler ($ attributeValue , $ object , $ attribute , $ format , $ attributeContext );
202
+ $ attributeValue = $ maxDepthHandler ($ attributeValue , $ data , $ attribute , $ format , $ attributeContext );
203
203
}
204
204
205
- $ stack [$ attribute ] = $ this ->applyCallbacks ($ attributeValue , $ object , $ attribute , $ format , $ attributeContext );
205
+ $ stack [$ attribute ] = $ this ->applyCallbacks ($ attributeValue , $ data , $ attribute , $ format , $ attributeContext );
206
206
}
207
207
208
208
foreach ($ stack as $ attribute => $ attributeValue ) {
209
- $ attributeContext = $ this ->getAttributeNormalizationContext ($ object , $ attribute , $ context );
209
+ $ attributeContext = $ this ->getAttributeNormalizationContext ($ data , $ attribute , $ context );
210
210
211
211
if (null === $ attributeValue || \is_scalar ($ attributeValue )) {
212
- $ data = $ this ->updateData ( $ data , $ attribute , $ attributeValue , $ class , $ format , $ attributeContext , $ attributesMetadata , $ classMetadata );
212
+ $ normalized = $ this ->updateNormalizedData ( $ normalized , $ attribute , $ attributeValue , $ class , $ format , $ attributeContext , $ attributesMetadata , $ classMetadata );
213
213
continue ;
214
214
}
215
215
@@ -219,15 +219,15 @@ public function normalize(mixed $object, ?string $format = null, array $context
219
219
220
220
$ childContext = $ this ->createChildContext ($ attributeContext , $ attribute , $ format );
221
221
222
- $ data = $ this ->updateData ( $ data , $ attribute , $ this ->serializer ->normalize ($ attributeValue , $ format , $ childContext ), $ class , $ format , $ attributeContext , $ attributesMetadata , $ classMetadata );
222
+ $ normalized = $ this ->updateNormalizedData ( $ normalized , $ attribute , $ this ->serializer ->normalize ($ attributeValue , $ format , $ childContext ), $ class , $ format , $ attributeContext , $ attributesMetadata , $ classMetadata );
223
223
}
224
224
225
225
$ preserveEmptyObjects = $ context [self ::PRESERVE_EMPTY_OBJECTS ] ?? $ this ->defaultContext [self ::PRESERVE_EMPTY_OBJECTS ] ?? false ;
226
- if ($ preserveEmptyObjects && !$ data ) {
226
+ if ($ preserveEmptyObjects && !$ normalized ) {
227
227
return new \ArrayObject ();
228
228
}
229
229
230
- return $ data ;
230
+ return $ normalized ;
231
231
}
232
232
233
233
protected function instantiateObject (array &$ data , string $ class , array &$ context , \ReflectionClass $ reflectionClass , array |bool $ allowedAttributes , ?string $ format = null ): object
@@ -888,7 +888,7 @@ private function getPropertyType(string $className, string $property): Type|arra
888
888
/**
889
889
* Sets an attribute and apply the name converter if necessary.
890
890
*/
891
- private function updateData (array $ data , string $ attribute , mixed $ attributeValue , string $ class , ?string $ format , array $ context , ?array $ attributesMetadata , ?ClassMetadataInterface $ classMetadata ): array
891
+ private function updateNormalizedData (array $ data , string $ attribute , mixed $ attributeValue , string $ class , ?string $ format , array $ context , ?array $ attributesMetadata , ?ClassMetadataInterface $ classMetadata ): array
892
892
{
893
893
if (null === $ attributeValue && ($ context [self ::SKIP_NULL_VALUES ] ?? $ this ->defaultContext [self ::SKIP_NULL_VALUES ] ?? false )) {
894
894
return $ data ;
0 commit comments