Doctrine\Common\Annotations\DocParser::collectAttributeTypeMetadata PHP Method

collectAttributeTypeMetadata() private method

Collects parsing metadata for a given attribute.
private collectAttributeTypeMetadata ( array &$metadata, Doctrine\Common\Annotations\Annotation\Attribute $attribute ) : void
$metadata array
$attribute Doctrine\Common\Annotations\Annotation\Attribute
return void
    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[]
            // 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;
    }