@@ -147,38 +147,38 @@ public function normalize($object, $format = null, array $context = [])
147
147
$ attributesMetadata = $ this ->classMetadataFactory ? $ this ->classMetadataFactory ->getMetadataFor ($ class )->getAttributesMetadata () : null ;
148
148
$ maxDepthHandler = $ context [self ::MAX_DEPTH_HANDLER ] ?? $ this ->defaultContext [self ::MAX_DEPTH_HANDLER ] ?? $ this ->maxDepthHandler ;
149
149
150
- foreach ($ attributes as $ attributeName ) {
150
+ foreach ($ attributes as $ attribute ) {
151
151
$ maxDepthReached = false ;
152
- if (null !== $ attributesMetadata && ($ maxDepthReached = $ this ->isMaxDepthReached ($ attributesMetadata , $ class , $ attributeName , $ context )) && !$ maxDepthHandler ) {
152
+ if (null !== $ attributesMetadata && ($ maxDepthReached = $ this ->isMaxDepthReached ($ attributesMetadata , $ class , $ attribute , $ context )) && !$ maxDepthHandler ) {
153
153
continue ;
154
154
}
155
155
156
- $ attributeValue = $ this ->getAttributeValue ($ object , $ attributeName , $ format , $ context );
156
+ $ attributeValue = $ this ->getAttributeValue ($ object , $ attribute , $ format , $ context );
157
157
if ($ maxDepthReached ) {
158
- $ attributeValue = $ maxDepthHandler ($ attributeValue , $ object , $ attributeName , $ format , $ context );
158
+ $ attributeValue = $ maxDepthHandler ($ attributeValue , $ object , $ attribute , $ format , $ context );
159
159
}
160
160
161
161
/**
162
162
* @var callable|null
163
163
*/
164
- $ callback = $ context [self ::CALLBACKS ][$ attributeName ] ?? $ this ->defaultContext [self ::CALLBACKS ][$ attributeName ] ?? $ this ->callbacks [$ attributeName ] ?? null ;
164
+ $ callback = $ context [self ::CALLBACKS ][$ attribute ] ?? $ this ->defaultContext [self ::CALLBACKS ][$ attribute ] ?? $ this ->callbacks [$ attribute ] ?? null ;
165
165
if ($ callback ) {
166
- $ attributeValue = $ callback ($ attributeValue , $ object , $ attributeName , $ format , $ context );
166
+ $ attributeValue = $ callback ($ attributeValue , $ object , $ attribute , $ format , $ context );
167
167
}
168
168
169
169
if (null !== $ attributeValue && !is_scalar ($ attributeValue )) {
170
- $ stack [$ attributeName ] = $ attributeValue ;
170
+ $ stack [$ attribute ] = $ attributeValue ;
171
171
}
172
172
173
- $ data = $ this ->updateData ($ data , $ attributeName , $ attributeValue , $ class , $ format , $ context );
173
+ $ data = $ this ->updateData ($ data , $ attribute , $ attributeValue , $ class , $ format , $ context );
174
174
}
175
175
176
- foreach ($ stack as $ attributeName => $ attributeValue ) {
176
+ foreach ($ stack as $ attribute => $ attributeValue ) {
177
177
if (!$ this ->serializer instanceof NormalizerInterface) {
178
- throw new LogicException (sprintf ('Cannot normalize attribute "%s" because the injected serializer is not a normalizer ' , $ attributeName ));
178
+ throw new LogicException (sprintf ('Cannot normalize attribute "%s" because the injected serializer is not a normalizer ' , $ attribute ));
179
179
}
180
180
181
- $ data = $ this ->updateData ($ data , $ attributeName , $ this ->serializer ->normalize ($ attributeValue , $ format , $ this ->createChildContext ($ context , $ attributeName )), $ class , $ format , $ context );
181
+ $ data = $ this ->updateData ($ data , $ attribute , $ this ->serializer ->normalize ($ attributeValue , $ format , $ this ->createChildContext ($ context , $ attribute )), $ class , $ format , $ context );
182
182
}
183
183
184
184
return $ data ;
0 commit comments