@@ -64,14 +64,14 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
6464 $ attribute = $ a ->newInstance ();
6565 if ($ attribute instanceof DiscriminatorMap) {
6666 $ classMetadata ->setClassDiscriminatorMapping (new ClassDiscriminatorMapping (
67- property_exists ($ attribute , 'typeProperty ' ) ? $ attribute ->typeProperty : $ attribute ->getTypeProperty () ,
68- property_exists ($ attribute , 'mapping ' ) ? $ attribute ->mapping : $ attribute ->getMapping ()
67+ method_exists ($ attribute , 'getTypeProperty ' ) ? $ attribute ->getTypeProperty () : $ attribute ->typeProperty ,
68+ method_exists ($ attribute , 'getMapping ' ) ? $ attribute ->getMapping () : $ attribute ->mapping
6969 ));
7070 continue ;
7171 }
7272
7373 if ($ attribute instanceof Groups) {
74- $ classGroups = property_exists ($ attribute , 'groups ' ) ? $ attribute ->groups : $ attribute ->getGroups () ;
74+ $ classGroups = method_exists ($ attribute , 'getGroups ' ) ? $ attribute ->getGroups () : $ attribute ->groups ;
7575
7676 continue ;
7777 }
@@ -116,17 +116,17 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
116116 // This code is adapted from Symfony\Component\Serializer\Mapping\Loader\AttributeLoader
117117 foreach ($ attributes [$ propertyName ] as $ attr ) {
118118 if ($ attr instanceof Groups) {
119- $ groups = property_exists ($ attr , 'groups ' ) ? $ attr ->groups : $ attr ->getGroups () ;
119+ $ groups = method_exists ($ attr , 'getGroups ' ) ? $ attr ->getGroups () : $ attr ->groups ;
120120 foreach ($ groups as $ group ) {
121121 $ attributeMetadata ->addGroup ($ group );
122122 }
123123 continue ;
124124 }
125125
126126 match (true ) {
127- $ attr instanceof MaxDepth => $ attributeMetadata ->setMaxDepth (property_exists ($ attr , 'maxDepth ' ) ? $ attr ->maxDepth : $ attr ->getMaxDepth () ),
128- $ attr instanceof SerializedName => $ attributeMetadata ->setSerializedName (property_exists ($ attr , 'serializedName ' ) ? $ attr ->serializedName : $ attr ->getSerializedName () ),
129- $ attr instanceof SerializedPath => $ attributeMetadata ->setSerializedPath (property_exists ($ attr , 'serializedPath ' ) ? $ attr ->serializedPath : $ attr ->getSerializedPath () ),
127+ $ attr instanceof MaxDepth => $ attributeMetadata ->setMaxDepth (method_exists ($ attr , 'getMaxDepth ' ) ? $ attr ->getMaxDepth () : $ attr ->maxDepth ),
128+ $ attr instanceof SerializedName => $ attributeMetadata ->setSerializedName (method_exists ($ attr , 'getSerializedName ' ) ? $ attr ->getSerializedName () : $ attr ->serializedName ),
129+ $ attr instanceof SerializedPath => $ attributeMetadata ->setSerializedPath (method_exists ($ attr , 'getSerializedPath ' ) ? $ attr ->getSerializedPath () : $ attr ->serializedPath ),
130130 $ attr instanceof Ignore => $ attributeMetadata ->setIgnore (true ),
131131 $ attr instanceof Context => $ this ->setAttributeContextsForGroups ($ attr , $ attributeMetadata ),
132132 default => null ,
@@ -149,10 +149,10 @@ private function addAttributeMetadata(ApiProperty $attribute, array &$attributes
149149
150150 private function setAttributeContextsForGroups (Context $ annotation , AttributeMetadataInterface $ attributeMetadata ): void
151151 {
152- $ context = property_exists ($ annotation , 'context ' ) ? $ annotation ->context : $ annotation ->getContext () ;
153- $ groups = property_exists ($ annotation , 'groups ' ) ? $ annotation ->groups : $ annotation ->getGroups () ;
154- $ normalizationContext = property_exists ($ annotation , 'normalizationContext ' ) ? $ annotation ->normalizationContext : $ annotation ->getNormalizationContext () ;
155- $ denormalizationContext = property_exists ($ annotation , 'denormalizationContext ' ) ? $ annotation ->denormalizationContext : $ annotation ->getDenormalizationContext () ;
152+ $ context = method_exists ($ annotation , 'getContext ' ) ? $ annotation ->getContext () : $ annotation ->context ;
153+ $ groups = method_exists ($ annotation , 'getGroups ' ) ? $ annotation ->getGroups () : $ annotation ->groups ;
154+ $ normalizationContext = method_exists ($ annotation , 'getNormalizationContext ' ) ? $ annotation ->getNormalizationContext () : $ annotation ->normalizationContext ;
155+ $ denormalizationContext = method_exists ($ annotation , 'getDenormalizationContext ' ) ? $ annotation ->getDenormalizationContext () : $ annotation ->denormalizationContext ;
156156
157157 if ($ normalizationContext || $ context ) {
158158 $ attributeMetadata ->setNormalizationContextForGroups ($ normalizationContext ?: $ context , $ groups );
0 commit comments