function SimpleAnnotationReader::getPropertyAnnotation

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Component/Annotation/Doctrine/SimpleAnnotationReader.php \Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader::getPropertyAnnotation()
  2. 10 core/lib/Drupal/Component/Annotation/Doctrine/SimpleAnnotationReader.php \Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader::getPropertyAnnotation()
  3. 9 core/lib/Drupal/Component/Annotation/Doctrine/SimpleAnnotationReader.php \Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader::getPropertyAnnotation()
  4. 8.9.x core/lib/Drupal/Component/Annotation/Doctrine/SimpleAnnotationReader.php \Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader::getPropertyAnnotation()

Gets a property annotation.

@template T

Parameters

ReflectionProperty $property The ReflectionProperty to read the annotations from.:

class-string<T> $annotationName The name of the annotation.:

Return value

T|null The Annotation or NULL, if the requested annotation does not exist.

File

core/lib/Drupal/Component/Annotation/Doctrine/SimpleAnnotationReader.php, line 186

Class

SimpleAnnotationReader
Simple Annotation Reader.

Namespace

Drupal\Component\Annotation\Doctrine

Code

public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) {
  foreach ($this->getPropertyAnnotations($property) as $annotation) {
    if ($annotation instanceof $annotationName) {
      return $annotation;
    }
  }
  return null;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.