function DocParser::resolvePositionalValues
Resolve positional arguments (without name) to named ones
@psalm-param Arguments $arguments
Return value
array<string,mixed>
1 call to DocParser::resolvePositionalValues()
- DocParser::Annotation in vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ DocParser.php - Annotation ::= "@" AnnotationName MethodCall AnnotationName ::= QualifiedName | SimpleName QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName NameSpacePart ::= identifier | null | false |…
File
-
vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ DocParser.php, line 1424
Class
- DocParser
- A parser for docblock annotations.
Namespace
Doctrine\Common\AnnotationsCode
private function resolvePositionalValues(array $arguments, string $name) : array {
$positionalArguments = $arguments['positional_arguments'] ?? [];
$values = $arguments['named_arguments'] ?? [];
if (self::$annotationMetadata[$name]['has_named_argument_constructor'] && self::$annotationMetadata[$name]['default_property'] !== null) {
// We must ensure that we don't have positional arguments after named ones
$positions = array_keys($positionalArguments);
$lastPosition = null;
foreach ($positions as $position) {
if ($lastPosition === null && $position !== 0 || $lastPosition !== null && $position !== $lastPosition + 1) {
throw $this->syntaxError('Positional arguments after named arguments is not allowed');
}
$lastPosition = $position;
}
foreach (self::$annotationMetadata[$name]['constructor_args'] as $property => $parameter) {
$position = $parameter['position'];
if (isset($values[$property]) || !isset($positionalArguments[$position])) {
continue;
}
$values[$property] = $positionalArguments[$position];
}
}
else {
if (count($positionalArguments) > 0 && !isset($values['value'])) {
if (count($positionalArguments) === 1) {
$value = array_pop($positionalArguments);
}
else {
$value = array_values($positionalArguments);
}
$values['value'] = $value;
}
}
return $values;
}