@@ -53,15 +53,15 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
5353 $ className = $ reflectionClass ->name ;
5454 $ loaded = false ;
5555 $ classGroups = [];
56- $ classContextAnnotation = null ;
56+ $ classContextAttribute = null ;
5757
5858 $ attributesMetadata = $ classMetadata ->getAttributesMetadata ();
5959
60- foreach ($ this ->loadAttributes ($ reflectionClass ) as $ annotation ) {
60+ foreach ($ this ->loadAttributes ($ reflectionClass ) as $ attribute ) {
6161 match (true ) {
62- $ annotation instanceof DiscriminatorMap => $ classMetadata ->setClassDiscriminatorMapping (new ClassDiscriminatorMapping ($ annotation ->getTypeProperty (), $ annotation ->getMapping ())),
63- $ annotation instanceof Groups => $ classGroups = $ annotation ->getGroups (),
64- $ annotation instanceof Context => $ classContextAnnotation = $ annotation ,
62+ $ attribute instanceof DiscriminatorMap => $ classMetadata ->setClassDiscriminatorMapping (new ClassDiscriminatorMapping ($ attribute ->getTypeProperty (), $ attribute ->getMapping ())),
63+ $ attribute instanceof Groups => $ classGroups = $ attribute ->getGroups (),
64+ $ attribute instanceof Context => $ classContextAttribute = $ attribute ,
6565 default => null ,
6666 };
6767 }
@@ -74,31 +74,31 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
7474
7575 $ attributeMetadata = $ attributesMetadata [$ property ->name ];
7676 if ($ property ->getDeclaringClass ()->name === $ className ) {
77- if ($ classContextAnnotation ) {
78- $ this ->setAttributeContextsForGroups ($ classContextAnnotation , $ attributeMetadata );
77+ if ($ classContextAttribute ) {
78+ $ this ->setAttributeContextsForGroups ($ classContextAttribute , $ attributeMetadata );
7979 }
8080
8181 foreach ($ classGroups as $ group ) {
8282 $ attributeMetadata ->addGroup ($ group );
8383 }
8484
85- foreach ($ this ->loadAttributes ($ property ) as $ annotation ) {
85+ foreach ($ this ->loadAttributes ($ property ) as $ attribute ) {
8686 $ loaded = true ;
8787
88- if ($ annotation instanceof Groups) {
89- foreach ($ annotation ->getGroups () as $ group ) {
88+ if ($ attribute instanceof Groups) {
89+ foreach ($ attribute ->getGroups () as $ group ) {
9090 $ attributeMetadata ->addGroup ($ group );
9191 }
9292
9393 continue ;
9494 }
9595
9696 match (true ) {
97- $ annotation instanceof MaxDepth => $ attributeMetadata ->setMaxDepth ($ annotation ->getMaxDepth ()),
98- $ annotation instanceof SerializedName => $ attributeMetadata ->setSerializedName ($ annotation ->getSerializedName ()),
99- $ annotation instanceof SerializedPath => $ attributeMetadata ->setSerializedPath ($ annotation ->getSerializedPath ()),
100- $ annotation instanceof Ignore => $ attributeMetadata ->setIgnore (true ),
101- $ annotation instanceof Context => $ this ->setAttributeContextsForGroups ($ annotation , $ attributeMetadata ),
97+ $ attribute instanceof MaxDepth => $ attributeMetadata ->setMaxDepth ($ attribute ->getMaxDepth ()),
98+ $ attribute instanceof SerializedName => $ attributeMetadata ->setSerializedName ($ attribute ->getSerializedName ()),
99+ $ attribute instanceof SerializedPath => $ attributeMetadata ->setSerializedPath ($ attribute ->getSerializedPath ()),
100+ $ attribute instanceof Ignore => $ attributeMetadata ->setIgnore (true ),
101+ $ attribute instanceof Context => $ this ->setAttributeContextsForGroups ($ attribute , $ attributeMetadata ),
102102 default => null ,
103103 };
104104 }
@@ -126,43 +126,43 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
126126 }
127127 }
128128
129- foreach ($ this ->loadAttributes ($ method ) as $ annotation ) {
130- if ($ annotation instanceof Groups) {
129+ foreach ($ this ->loadAttributes ($ method ) as $ attribute ) {
130+ if ($ attribute instanceof Groups) {
131131 if (!$ accessorOrMutator ) {
132132 throw new MappingException (\sprintf ('Groups on "%s::%s()" cannot be added. Groups can only be added on methods beginning with "get", "is", "has" or "set". ' , $ className , $ method ->name ));
133133 }
134134
135- foreach ($ annotation ->getGroups () as $ group ) {
135+ foreach ($ attribute ->getGroups () as $ group ) {
136136 $ attributeMetadata ->addGroup ($ group );
137137 }
138- } elseif ($ annotation instanceof MaxDepth) {
138+ } elseif ($ attribute instanceof MaxDepth) {
139139 if (!$ accessorOrMutator ) {
140140 throw new MappingException (\sprintf ('MaxDepth on "%s::%s()" cannot be added. MaxDepth can only be added on methods beginning with "get", "is", "has" or "set". ' , $ className , $ method ->name ));
141141 }
142142
143- $ attributeMetadata ->setMaxDepth ($ annotation ->getMaxDepth ());
144- } elseif ($ annotation instanceof SerializedName) {
143+ $ attributeMetadata ->setMaxDepth ($ attribute ->getMaxDepth ());
144+ } elseif ($ attribute instanceof SerializedName) {
145145 if (!$ accessorOrMutator ) {
146146 throw new MappingException (\sprintf ('SerializedName on "%s::%s()" cannot be added. SerializedName can only be added on methods beginning with "get", "is", "has" or "set". ' , $ className , $ method ->name ));
147147 }
148148
149- $ attributeMetadata ->setSerializedName ($ annotation ->getSerializedName ());
150- } elseif ($ annotation instanceof SerializedPath) {
149+ $ attributeMetadata ->setSerializedName ($ attribute ->getSerializedName ());
150+ } elseif ($ attribute instanceof SerializedPath) {
151151 if (!$ accessorOrMutator ) {
152152 throw new MappingException (\sprintf ('SerializedPath on "%s::%s()" cannot be added. SerializedPath can only be added on methods beginning with "get", "is", "has" or "set". ' , $ className , $ method ->name ));
153153 }
154154
155- $ attributeMetadata ->setSerializedPath ($ annotation ->getSerializedPath ());
156- } elseif ($ annotation instanceof Ignore) {
155+ $ attributeMetadata ->setSerializedPath ($ attribute ->getSerializedPath ());
156+ } elseif ($ attribute instanceof Ignore) {
157157 if ($ accessorOrMutator ) {
158158 $ attributeMetadata ->setIgnore (true );
159159 }
160- } elseif ($ annotation instanceof Context) {
160+ } elseif ($ attribute instanceof Context) {
161161 if (!$ accessorOrMutator ) {
162162 throw new MappingException (\sprintf ('Context on "%s::%s()" cannot be added. Context can only be added on methods beginning with "get", "is", "has" or "set". ' , $ className , $ method ->name ));
163163 }
164164
165- $ this ->setAttributeContextsForGroups ($ annotation , $ attributeMetadata );
165+ $ this ->setAttributeContextsForGroups ($ attribute , $ attributeMetadata );
166166 }
167167
168168 $ loaded = true ;
@@ -195,12 +195,12 @@ private function loadAttributes(\ReflectionMethod|\ReflectionClass|\ReflectionPr
195195 }
196196 }
197197
198- private function setAttributeContextsForGroups (Context $ annotation , AttributeMetadataInterface $ attributeMetadata ): void
198+ private function setAttributeContextsForGroups (Context $ attribute , AttributeMetadataInterface $ attributeMetadata ): void
199199 {
200- $ context = $ annotation ->getContext ();
201- $ groups = $ annotation ->getGroups ();
202- $ normalizationContext = $ annotation ->getNormalizationContext ();
203- $ denormalizationContext = $ annotation ->getDenormalizationContext ();
200+ $ context = $ attribute ->getContext ();
201+ $ groups = $ attribute ->getGroups ();
202+ $ normalizationContext = $ attribute ->getNormalizationContext ();
203+ $ denormalizationContext = $ attribute ->getDenormalizationContext ();
204204
205205 if ($ normalizationContext || $ context ) {
206206 $ attributeMetadata ->setNormalizationContextForGroups ($ normalizationContext ?: $ context , $ groups );
0 commit comments