vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Driver/AttributeReader.php line 103
<?phpdeclare(strict_types=1);namespace Doctrine\ODM\MongoDB\Mapping\Driver;use Doctrine\Common\Annotations\Reader;use Doctrine\ODM\MongoDB\Mapping\Annotations\Annotation;use ReflectionAttribute;use ReflectionClass;use ReflectionMethod;use ReflectionProperty;use function assert;use function is_subclass_of;/*** @internal*/final class AttributeReader implements Reader{public function getClassAnnotations(ReflectionClass $class): array{return $this->convertToAttributeInstances($class->getAttributes());}/*** @param class-string<T> $annotationName** @return T|null** @template T*/public function getClassAnnotation(ReflectionClass $class, $annotationName){foreach ($this->getClassAnnotations($class) as $annotation) {if ($annotation instanceof $annotationName) {return $annotation;}}return null;}public function getMethodAnnotations(ReflectionMethod $method): array{return $this->convertToAttributeInstances($method->getAttributes());}/*** @param class-string<T> $annotationName** @return T|null** @template T*/public function getMethodAnnotation(ReflectionMethod $method, $annotationName){foreach ($this->getMethodAnnotations($method) as $annotation) {if ($annotation instanceof $annotationName) {return $annotation;}}return null;}public function getPropertyAnnotations(ReflectionProperty $property): array{return $this->convertToAttributeInstances($property->getAttributes());}/*** @param class-string<T> $annotationName** @return T|null** @template T*/public function getPropertyAnnotation(ReflectionProperty $property, $annotationName){foreach ($this->getPropertyAnnotations($property) as $annotation) {if ($annotation instanceof $annotationName) {return $annotation;}}return null;}/*** @param ReflectionAttribute<object>[] $attributes** @return Annotation[]*/private function convertToAttributeInstances(array $attributes): array{$instances = [];foreach ($attributes as $attribute) {$attributeName = $attribute->getName();// Make sure we only get Doctrine Annotationsif (! is_subclass_of($attributeName, Annotation::class)) {continue;}$instance = $attribute->newInstance();assert($instance instanceof Annotation);$instances[] = $instance;}return $instances;}}