function DocParser::Constant
Same name in this branch
- 11.1.x core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::Constant()
Constant ::= integer | string | float | boolean
Return value
mixed
Throws
2 calls to DocParser::Constant()
- DocParser::ArrayEntry in vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ DocParser.php - ArrayEntry ::= Value | KeyValuePair KeyValuePair ::= Key ("=" | ":") PlainValue | Constant Key ::= string | integer | Constant
- DocParser::PlainValue in vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ DocParser.php - PlainValue ::= integer | string | float | boolean | Array | Annotation
File
-
vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ DocParser.php, line 1100
Class
- DocParser
- A parser for docblock annotations.
Namespace
Doctrine\Common\AnnotationsCode
private function Constant() {
$identifier = $this->Identifier();
if (!defined($identifier) && strpos($identifier, '::') !== false && $identifier[0] !== '\\') {
[
$className,
$const,
] = explode('::', $identifier);
$pos = strpos($className, '\\');
$alias = $pos === false ? $className : substr($className, 0, $pos);
$found = false;
$loweredAlias = strtolower($alias);
switch (true) {
case !empty($this->namespaces):
foreach ($this->namespaces as $ns) {
if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) {
$className = $ns . '\\' . $className;
$found = true;
break;
}
}
break;
case isset($this->imports[$loweredAlias]):
$found = true;
$className = $pos !== false ? $this->imports[$loweredAlias] . substr($className, $pos) : $this->imports[$loweredAlias];
break;
default:
if (isset($this->imports['__NAMESPACE__'])) {
$ns = $this->imports['__NAMESPACE__'];
if (class_exists($ns . '\\' . $className) || interface_exists($ns . '\\' . $className)) {
$className = $ns . '\\' . $className;
$found = true;
}
}
break;
}
if ($found) {
$identifier = $className . '::' . $const;
}
}
/**
* Checks if identifier ends with ::class and remove the leading backslash if it exists.
*/
if ($this->identifierEndsWithClassConstant($identifier) && !$this->identifierStartsWithBackslash($identifier)) {
return substr($identifier, 0, $this->getClassConstantPositionInIdentifier($identifier));
}
if ($this->identifierEndsWithClassConstant($identifier) && $this->identifierStartsWithBackslash($identifier)) {
return substr($identifier, 1, $this->getClassConstantPositionInIdentifier($identifier) - 1);
}
if (!defined($identifier)) {
throw AnnotationException::semanticalErrorConstants($identifier, $this->context);
}
return constant($identifier);
}