function DocParser::collectAttributeTypeMetadata
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::collectAttributeTypeMetadata()
- 10 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::collectAttributeTypeMetadata()
- 11.x core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::collectAttributeTypeMetadata()
Collects parsing metadata for a given attribute.
Parameters
array $metadata:
Attribute $attribute:
Return value
void
1 call to DocParser::collectAttributeTypeMetadata()
- DocParser::collectAnnotationMetadata in core/
lib/ Drupal/ Component/ Annotation/ Doctrine/ DocParser.php - Collects parsing metadata for a given annotation class
File
-
core/
lib/ Drupal/ Component/ Annotation/ Doctrine/ DocParser.php, line 565
Class
- DocParser
- A parser for docblock annotations.
Namespace
Drupal\Component\Annotation\DoctrineCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.