From 4d5a08856b2b4f7abe83fc6202979bbb3abd69be Mon Sep 17 00:00:00 2001 From: "a.navrotsky@educonlines.com" Date: Wed, 30 Mar 2022 18:16:57 +0300 Subject: [PATCH 1/2] fix AttributeReader getPropertyAnnotation getMethodAnnotation --- src/Metadata/Driver/AttributeDriver/AttributeReader.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Metadata/Driver/AttributeDriver/AttributeReader.php b/src/Metadata/Driver/AttributeDriver/AttributeReader.php index 0b5156b22..5361bdc3b 100644 --- a/src/Metadata/Driver/AttributeDriver/AttributeReader.php +++ b/src/Metadata/Driver/AttributeDriver/AttributeReader.php @@ -46,7 +46,8 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName): { $attributes = $method->getAttributes($annotationName); - return $this->reader->getClassAnnotation($method, $annotationName) ?? $this->buildAnnotation($attributes); + $classReflection = new ReflectionClass($method->class); + return $this->reader->getClassAnnotation($classReflection, $annotationName) ?? $this->buildAnnotation($attributes); } public function getPropertyAnnotations(ReflectionProperty $property): array @@ -60,7 +61,8 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN { $attributes = $property->getAttributes($annotationName); - return $this->reader->getClassAnnotation($property, $annotationName) ?? $this->buildAnnotation($attributes); + $classReflection = new ReflectionClass($property->class); + return $this->reader->getClassAnnotation($classReflection, $annotationName) ?? $this->buildAnnotation($attributes); } private function buildAnnotation(array $attributes): ?object From 2fde7cf26633090aa4bfd58e5036ea671d7466e7 Mon Sep 17 00:00:00 2001 From: "a.navrotsky@educonlines.com" Date: Thu, 31 Mar 2022 08:26:09 +0300 Subject: [PATCH 2/2] style improvement --- src/Metadata/Driver/AttributeDriver/AttributeReader.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Metadata/Driver/AttributeDriver/AttributeReader.php b/src/Metadata/Driver/AttributeDriver/AttributeReader.php index 5361bdc3b..ad8085d2b 100644 --- a/src/Metadata/Driver/AttributeDriver/AttributeReader.php +++ b/src/Metadata/Driver/AttributeDriver/AttributeReader.php @@ -46,8 +46,8 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName): { $attributes = $method->getAttributes($annotationName); - $classReflection = new ReflectionClass($method->class); - return $this->reader->getClassAnnotation($classReflection, $annotationName) ?? $this->buildAnnotation($attributes); + return $this->reader->getClassAnnotation(new ReflectionClass($method->class), $annotationName) + ?? $this->buildAnnotation($attributes); } public function getPropertyAnnotations(ReflectionProperty $property): array @@ -61,8 +61,8 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN { $attributes = $property->getAttributes($annotationName); - $classReflection = new ReflectionClass($property->class); - return $this->reader->getClassAnnotation($classReflection, $annotationName) ?? $this->buildAnnotation($attributes); + return $this->reader->getClassAnnotation(new ReflectionClass($property->class), $annotationName) + ?? $this->buildAnnotation($attributes); } private function buildAnnotation(array $attributes): ?object