You are here

private function DocParser::collectAttributeTypeMetadata in Plug 7

Collects parsing metadata for a given attribute.

Parameters

array $metadata:

Attribute $attribute:

Return value

void

1 call to DocParser::collectAttributeTypeMetadata()
DocParser::collectAnnotationMetadata in lib/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php
Collects parsing metadata for a given annotation class

File

lib/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php, line 566

Class

DocParser
A parser for docblock annotations.

Namespace

Doctrine\Common\Annotations

Code

private function collectAttributeTypeMetadata(&$metadata, Attribute $attribute) {

  // handle internal type declaration
  $type = isset(self::$typeMap[$attribute->type]) ? self::$typeMap[$attribute->type] : $attribute->type;

  // handle the case if the property type is mixed
  if ('mixed' === $type) {
    return;
  }

  // Evaluate type
  switch (true) {

    // Checks if the property has array<type>
    case false !== ($pos = strpos($type, '<')):
      $arrayType = substr($type, $pos + 1, -1);
      $type = 'array';
      if (isset(self::$typeMap[$arrayType])) {
        $arrayType = self::$typeMap[$arrayType];
      }
      $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType;
      break;

    // Checks if the property has type[]
    case false !== ($pos = strrpos($type, '[')):
      $arrayType = substr($type, 0, $pos);
      $type = 'array';
      if (isset(self::$typeMap[$arrayType])) {
        $arrayType = self::$typeMap[$arrayType];
      }
      $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType;
      break;
  }
  $metadata['attribute_types'][$attribute->name]['type'] = $type;
  $metadata['attribute_types'][$attribute->name]['value'] = $attribute->type;
  $metadata['attribute_types'][$attribute->name]['required'] = $attribute->required;
}