@@ -73,26 +73,26 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
7373 }
7474
7575 /**
76- * @param string|null $format
76+ * {@inheritdoc}
7777 */
78- public function getSupportedTypes ($ format ): array
78+ public function getSupportedTypes (? string $ format ): array
7979 {
8080 return self ::FORMAT === $ format ? parent ::getSupportedTypes ($ format ) : [];
8181 }
8282
8383 /**
8484 * {@inheritdoc}
8585 */
86- public function normalize (mixed $ object , ?string $ format = null , array $ context = []): array |string |int |float |bool |\ArrayObject |null
86+ public function normalize (mixed $ data , ?string $ format = null , array $ context = []): array |string |int |float |bool |\ArrayObject |null
8787 {
88- $ resourceClass = $ this ->getObjectClass ($ object );
88+ $ resourceClass = $ this ->getObjectClass ($ data );
8989 if ($ this ->getOutputClass ($ context )) {
90- return parent ::normalize ($ object , $ format , $ context );
90+ return parent ::normalize ($ data , $ format , $ context );
9191 }
9292
9393 $ previousResourceClass = $ context ['resource_class ' ] ?? null ;
9494 if ($ this ->resourceClassResolver ->isResourceClass ($ resourceClass ) && (null === $ previousResourceClass || $ this ->resourceClassResolver ->isResourceClass ($ previousResourceClass ))) {
95- $ resourceClass = $ this ->resourceClassResolver ->getResourceClass ($ object , $ previousResourceClass );
95+ $ resourceClass = $ this ->resourceClassResolver ->getResourceClass ($ data , $ previousResourceClass );
9696 }
9797
9898 if (($ operation = $ context ['operation ' ] ?? null ) && method_exists ($ operation , 'getItemUriTemplate ' )) {
@@ -101,37 +101,37 @@ public function normalize(mixed $object, ?string $format = null, array $context
101101
102102 $ context = $ this ->initContext ($ resourceClass , $ context );
103103
104- $ iri = $ context ['iri ' ] ??= $ this ->iriConverter ->getIriFromResource ($ object , UrlGeneratorInterface::ABS_PATH , $ context ['operation ' ] ?? null , $ context );
105- $ context ['object ' ] = $ object ;
104+ $ iri = $ context ['iri ' ] ??= $ this ->iriConverter ->getIriFromResource ($ data , UrlGeneratorInterface::ABS_PATH , $ context ['operation ' ] ?? null , $ context );
105+ $ context ['object ' ] = $ data ;
106106 $ context ['format ' ] = $ format ;
107107 $ context ['api_normalize ' ] = true ;
108108
109109 if (!isset ($ context ['cache_key ' ])) {
110110 $ context ['cache_key ' ] = $ this ->getCacheKey ($ format , $ context );
111111 }
112112
113- $ data = parent ::normalize ($ object , $ format , $ context );
114- if (!\is_array ($ data )) {
115- return $ data ;
113+ $ normalizedData = parent ::normalize ($ data , $ format , $ context );
114+ if (!\is_array ($ normalizedData )) {
115+ return $ normalizedData ;
116116 }
117117
118118 // Get and populate relations
119- ['relationships ' => $ allRelationshipsData , 'links ' => $ links ] = $ this ->getComponents ($ object , $ format , $ context );
119+ ['relationships ' => $ allRelationshipsData , 'links ' => $ links ] = $ this ->getComponents ($ data , $ format , $ context );
120120 $ populatedRelationContext = $ context ;
121- $ relationshipsData = $ this ->getPopulatedRelations ($ object , $ format , $ populatedRelationContext , $ allRelationshipsData );
121+ $ relationshipsData = $ this ->getPopulatedRelations ($ data , $ format , $ populatedRelationContext , $ allRelationshipsData );
122122
123123 // Do not include primary resources
124124 $ context ['api_included_resources ' ] = [$ context ['iri ' ]];
125125
126- $ includedResourcesData = $ this ->getRelatedResources ($ object , $ format , $ context , $ allRelationshipsData );
126+ $ includedResourcesData = $ this ->getRelatedResources ($ data , $ format , $ context , $ allRelationshipsData );
127127
128128 $ resourceData = [
129129 'id ' => $ context ['iri ' ],
130130 'type ' => $ this ->getResourceShortName ($ resourceClass ),
131131 ];
132132
133- if ($ data ) {
134- $ resourceData ['attributes ' ] = $ data ;
133+ if ($ normalizedData ) {
134+ $ resourceData ['attributes ' ] = $ normalizedData ;
135135 }
136136
137137 if ($ relationshipsData ) {
@@ -166,7 +166,7 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form
166166 *
167167 * @throws NotNormalizableValueException
168168 */
169- public function denormalize (mixed $ data , string $ class , ?string $ format = null , array $ context = []): mixed
169+ public function denormalize (mixed $ data , string $ type , ?string $ format = null , array $ context = []): mixed
170170 {
171171 // Avoid issues with proxies if we populated the object
172172 if (!isset ($ context [self ::OBJECT_TO_POPULATE ]) && isset ($ data ['data ' ]['id ' ])) {
@@ -188,7 +188,7 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
188188
189189 return parent ::denormalize (
190190 $ dataToDenormalize ,
191- $ class ,
191+ $ type ,
192192 $ format ,
193193 $ context
194194 );
0 commit comments