Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix AttributeReader:getPropertyAnnotation AttributeReader:getMethodAnnotation #1404

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Metadata/Driver/AttributeDriver/AttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName):
{
$attributes = $method->getAttributes($annotationName);

return $this->reader->getClassAnnotation($method, $annotationName) ?? $this->buildAnnotation($attributes);
return $this->reader->getClassAnnotation(new ReflectionClass($method->class), $annotationName)
?? $this->buildAnnotation($attributes);
Comment on lines +49 to +50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $this->reader->getClassAnnotation(new ReflectionClass($method->class), $annotationName)
?? $this->buildAnnotation($attributes);
return $this->reader->getMethodAnnotation($method, $annotationName) ?? $this->buildAnnotation($attributes);

}

public function getPropertyAnnotations(ReflectionProperty $property): array
Expand All @@ -60,7 +61,8 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN
{
$attributes = $property->getAttributes($annotationName);

return $this->reader->getClassAnnotation($property, $annotationName) ?? $this->buildAnnotation($attributes);
return $this->reader->getClassAnnotation(new ReflectionClass($property->class), $annotationName)
?? $this->buildAnnotation($attributes);
Comment on lines +64 to +65
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $this->reader->getClassAnnotation(new ReflectionClass($property->class), $annotationName)
?? $this->buildAnnotation($attributes);
return $this->reader->getPropertyAnnotation($property, $annotationName) ?? $this->buildAnnotation($attributes);

}

private function buildAnnotation(array $attributes): ?object
Expand Down