@@ -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- $ attribute ->typeProperty ,
68- $ attribute ->mapping
67+ property_exists ( $ attribute, ' typeProperty ' ) ? $ attribute ->typeProperty : $ attribute -> getTypeProperty () ,
68+ property_exists ( $ attribute, ' mapping ' ) ? $ attribute ->mapping : $ attribute -> getMapping ()
6969 ));
7070 continue ;
7171 }
7272
7373 if ($ attribute instanceof Groups) {
74- $ classGroups = $ attribute ->groups ;
74+ $ classGroups = property_exists ( $ attribute, ' groups ' ) ? $ attribute ->groups : $ attribute -> getGroups () ;
7575
7676 continue ;
7777 }
@@ -116,16 +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- foreach ($ attr ->groups as $ group ) {
119+ $ groups = property_exists ($ attr , 'groups ' ) ? $ attr ->groups : $ attr ->getGroups ();
120+ foreach ($ groups as $ group ) {
120121 $ attributeMetadata ->addGroup ($ group );
121122 }
122123 continue ;
123124 }
124125
125126 match (true ) {
126- $ attr instanceof MaxDepth => $ attributeMetadata ->setMaxDepth ($ attr ->maxDepth ),
127- $ attr instanceof SerializedName => $ attributeMetadata ->setSerializedName ($ attr ->serializedName ),
128- $ attr instanceof SerializedPath => $ attributeMetadata ->setSerializedPath ($ attr ->serializedPath ),
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 () ),
129130 $ attr instanceof Ignore => $ attributeMetadata ->setIgnore (true ),
130131 $ attr instanceof Context => $ this ->setAttributeContextsForGroups ($ attr , $ attributeMetadata ),
131132 default => null ,
@@ -148,10 +149,11 @@ private function addAttributeMetadata(ApiProperty $attribute, array &$attributes
148149
149150 private function setAttributeContextsForGroups (Context $ annotation , AttributeMetadataInterface $ attributeMetadata ): void
150151 {
151- $ context = $ annotation ->context ;
152- $ groups = $ annotation ->groups ;
153- $ normalizationContext = $ annotation ->normalizationContext ;
154- $ denormalizationContext = $ annotation ->denormalizationContext ;
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 ();
156+
155157 if ($ normalizationContext || $ context ) {
156158 $ attributeMetadata ->setNormalizationContextForGroups ($ normalizationContext ?: $ context , $ groups );
157159 }
0 commit comments