Doctrine\Common\Annotations\AnnotationReader::getPropertyAnnotations PHP Méthode

getPropertyAnnotations() public méthode

{@inheritDoc}
public getPropertyAnnotations ( ReflectionProperty $property )
$property ReflectionProperty
    public function getPropertyAnnotations(ReflectionProperty $property)
    {
        $class = $property->getDeclaringClass();
        $context = 'property ' . $class->getName() . "::\$" . $property->getName();
        $this->parser->setTarget(Target::TARGET_PROPERTY);
        $this->parser->setImports($this->getPropertyImports($property));
        $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
        $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
        return $this->parser->parse($property->getDocComment(), $context);
    }

Usage Example

 /**
  * @param ReflectionProperty $property
  * @return PropertyMetadata
  */
 private function loadPropertyMetadata(ReflectionProperty $property)
 {
     $propertyMetadata = new PropertyMetadata($property->getDeclaringClass()->getName(), $property->getName());
     foreach ($this->reader->getPropertyAnnotations($property) as $propertyAnnotation) {
         if ($propertyAnnotation instanceof Type) {
             $propertyMetadata->type = $propertyAnnotation->name;
         }
         if ($propertyAnnotation instanceof ReferenceOne) {
             $propertyMetadata->reference = PropertyMetadata::REFERENCE_ONE;
             $propertyMetadata->target = $propertyAnnotation->target;
         }
         if ($propertyAnnotation instanceof ReferenceMany) {
             $propertyMetadata->reference = PropertyMetadata::REFERENCE_MANY;
             $propertyMetadata->target = $propertyAnnotation->target;
         }
         if ($propertyAnnotation instanceof ReferenceKey) {
             $propertyMetadata->reference = PropertyMetadata::REFERENCE_KEY;
             $propertyMetadata->target = $propertyAnnotation->target;
             if ($propertyAnnotation->value instanceof Type) {
                 $propertyMetadata->value = ['type' => 'type', 'name' => $propertyAnnotation->value->name];
             }
         }
         if ($propertyAnnotation instanceof EmbedOne) {
             $propertyMetadata->embed = PropertyMetadata::EMBED_ONE;
             $propertyMetadata->target = $propertyAnnotation->target;
             $propertyMetadata->mapping = $propertyAnnotation->mapping;
         }
         if ($propertyAnnotation instanceof EmbedMany) {
             $propertyMetadata->embed = PropertyMetadata::EMBED_MANY;
             $propertyMetadata->target = $propertyAnnotation->target;
             $propertyMetadata->mapping = $propertyAnnotation->mapping;
         }
     }
     return $propertyMetadata;
 }
All Usage Examples Of Doctrine\Common\Annotations\AnnotationReader::getPropertyAnnotations