| Methods |
public
|
__construct()
Constructs a new DocParser.
Constructs a new DocParser.
|
#
|
public
|
setIgnoredAnnotationNames(bool[] $names): void
Sets the annotation names that are ignored during the parsing process.
Sets the annotation names that are ignored during the parsing process.
The names are supposed to be the raw names as used in the class, not the
fully qualified class names.
Parameters
| $names |
indexed by annotation name
|
|
#
|
public
|
setIgnoredAnnotationNamespaces(bool[] $ignoredAnnotationNamespaces): void
Sets the annotation namespaces that are ignored during the parsing process.
Sets the annotation namespaces that are ignored during the parsing process.
Parameters
| $ignoredAnnotationNamespaces |
indexed by annotation namespace name
|
|
#
|
public
|
setIgnoreNotImportedAnnotations(bool $bool): void
Sets ignore on not-imported annotations.
Sets ignore on not-imported annotations.
|
#
|
public
|
addNamespace(string $namespace): void
Sets the default namespaces.
Sets the default namespaces.
Throws
|
#
|
public
|
setImports(array<string, class-string> $imports): void
Sets the imports.
|
#
|
public
|
setTarget(int $target): void
Sets current target context as bitmask.
Sets current target context as bitmask.
|
#
|
public
|
parse(string $input, string $context = '')
Parses the given docblock string for annotations.
Parses the given docblock string for annotations.
Throws
|
#
|
private
|
findInitialTokenPosition(string $input): ?int
Finds the first valid annotation
Finds the first valid annotation
|
#
|
private
|
match(int $token): bool
Attempts to match the given token with the current lookahead token.
If they match, updates the lookahead token;…
Attempts to match the given token with the current lookahead token.
If they match, updates the lookahead token; otherwise raises a syntax error.
Parameters
Returns
True if tokens match; false otherwise.
Throws
|
#
|
private
|
matchAny(list<mixed[]> $tokens): bool
Attempts to match the current lookahead token with any of the given tokens.
Attempts to match the current lookahead token with any of the given tokens.
If any of them matches, this method updates the lookahead token; otherwise
a syntax error is raised.
Throws
|
#
|
private
|
syntaxError(string $expected, mixed[]|null $token = null): AnnotationException
Generates a new syntax error.
Generates a new syntax error.
Parameters
| $expected |
Expected string.
|
| $token |
Optional token.
|
|
#
|
private
|
classExists(class-string $fqcn): bool
Attempts to check if a class exists or not. This never goes through the PHP autoloading mechanism
but uses the {@link…
Attempts to check if a class exists or not. This never goes through the PHP autoloading mechanism
but uses the {@link AnnotationRegistry} to load classes.
|
#
|
private
|
collectAnnotationMetadata(class-string $name): void
Collects parsing metadata for a given annotation class
Collects parsing metadata for a given annotation class
Parameters
| $name |
The annotation name
|
Throws
|
#
|
private
|
collectAttributeTypeMetadata(mixed[] &$metadata, Attribute $attribute): void
Collects parsing metadata for a given attribute.
Collects parsing metadata for a given attribute.
|
#
|
private
|
Annotations(): array
Annotations ::= Annotation {[ "*" ]* [Annotation]}*
Annotations ::= Annotation {[ "" ] [Annotation]}*
Throws
|
#
|
private
|
Annotation(): object|false
Annotation ::= "@" AnnotationName MethodCall
AnnotationName ::= QualifiedName | SimpleName
QualifiedName ::=…
Annotation ::= "@" AnnotationName MethodCall
AnnotationName ::= QualifiedName | SimpleName
QualifiedName ::= NameSpacePart "" {NameSpacePart ""}* SimpleName
NameSpacePart ::= identifier | null | false | true
SimpleName ::= identifier | null | false | true
Returns
False if it is not a valid annotation.
Throws
|
#
|
private
|
MethodCall(): mixed[]
MethodCall ::= ["(" [Values] ")"]
MethodCall ::= ["(" [Values] ")"]
Throws
|
#
|
private
|
Values(): mixed[]
Values ::= Array | Value {"," Value}* [","]
Values ::= Array | Value {"," Value}* [","]
Throws
|
#
|
private
|
Constant(): mixed
Constant ::= integer | string | float | boolean
Constant ::= integer | string | float | boolean
Throws
|
#
|
private
|
identifierStartsWithBackslash(string $identifier): bool
|
#
|
private
|
identifierEndsWithClassConstant(string $identifier): bool
|
#
|
private
|
getClassConstantPositionInIdentifier(string $identifier): int|false
|
#
|
private
|
Identifier(): string
Identifier ::= string
|
#
|
private
|
Value(): mixed
Value ::= PlainValue | FieldAssignment
Value ::= PlainValue | FieldAssignment
Throws
|
#
|
private
|
PlainValue(): mixed
PlainValue ::= integer | string | float | boolean | Array | Annotation
PlainValue ::= integer | string | float | boolean | Array | Annotation
Throws
|
#
|
private
|
FieldAssignment(): stdClass
FieldAssignment ::= FieldName "=" PlainValue
FieldName ::= identifier
FieldAssignment ::= FieldName "=" PlainValue
FieldName ::= identifier
Throws
|
#
|
private
|
Arrayx(): mixed[]
Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}"
Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}"
Throws
|
#
|
private
|
ArrayEntry(): array
ArrayEntry ::= Value | KeyValuePair
KeyValuePair ::= Key ("=" | ":") PlainValue | Constant
Key ::= string | integer |…
ArrayEntry ::= Value | KeyValuePair
KeyValuePair ::= Key ("=" | ":") PlainValue | Constant
Key ::= string | integer | Constant
Throws
|
#
|
private
|
isIgnoredAnnotation(string $name): bool
Checks whether the given $name matches any ignored annotation name or namespace
Checks whether the given $name matches any ignored annotation name or namespace
|
#
|
private
|
resolvePositionalValues(array<string, mixed> $arguments, string $name): array<string, mixed>
Resolve positional arguments (without name) to named ones
Resolve positional arguments (without name) to named ones
|
#
|
private
|
instantiateAnnotiation(
string $originalName,
string $context,
class-string $name,
array<string, mixed> $arguments,
): object
Try to instantiate the annotation and catch and process any exceptions related to failure
Try to instantiate the annotation and catch and process any exceptions related to failure
Throws
|
#
|
| Properties |
private
static
|
|
$classIdentifiers = [DocLexer::T_IDENTIFIER, DocLexer::T_TRUE, DocLexer::T_FALSE, DocLexer::T_NULL]
An array of all valid tokens for a class name.
An array of all valid tokens for a class name.
|
#
|
private
|
DocLexer
|
$lexer
|
#
|
private
|
int
|
$target
|
#
|
private
static
|
DocParser
|
$metadataParser
|
#
|
private
|
bool
|
$isNestedAnnotation = false
|
#
|
private
|
array<string, class-string>
|
$imports = []
|
#
|
private
|
array<class-string, bool>
|
$classExists = []
|
#
|
private
|
bool
|
$ignoreNotImportedAnnotations = false
|
#
|
private
|
string[]
|
$namespaces = []
|
#
|
private
|
bool[]
|
$ignoredAnnotationNames = []
indexed by annotation name
indexed by annotation name
|
#
|
private
|
bool[]
|
$ignoredAnnotationNamespaces = []
indexed by namespace name
indexed by namespace name
|
#
|
private
|
string
|
$context = ''
|
#
|
private
static
|
array<class-string, mixed[]>
|
$annotationMetadata = [
Target::class => [
'is_annotation' => true,
'has_constructor' => true,
'has_named_argument_constructor' => false,
'properties' => [],
'targets_literal' => 'ANNOTATION_CLASS',
'targets' => Target::TARGET_CLASS,
'default_property' => 'value',
'attribute_types' => [
'value' => [
'required' => false,
'type' => 'array',
'array_type' => 'string',
'value' => 'array<string>',
],
],
],
Attribute::class => [
'is_annotation' => true,
'has_constructor' => false,
'has_named_argument_constructor' => false,
'targets_literal' => 'ANNOTATION_ANNOTATION',
'targets' => Target::TARGET_ANNOTATION,
'default_property' => 'name',
'properties' => ['name' => 'name', 'type' => 'type', 'required' => 'required'],
'attribute_types' => [
'value' => ['required' => true, 'type' => 'string', 'value' => 'string'],
'type' => ['required' => true, 'type' => 'string', 'value' => 'string'],
'required' => ['required' => false, 'type' => 'boolean', 'value' => 'boolean'],
],
],
Attributes::class => [
'is_annotation' => true,
'has_constructor' => false,
'has_named_argument_constructor' => false,
'targets_literal' => 'ANNOTATION_CLASS',
'targets' => Target::TARGET_CLASS,
'default_property' => 'value',
'properties' => ['value' => 'value'],
'attribute_types' => [
'value' => [
'type' => 'array',
'required' => true,
'array_type' => Attribute::class,
'value' => 'array<' . Attribute::class . '>',
],
],
],
Enum::class => [
'is_annotation' => true,
'has_constructor' => true,
'has_named_argument_constructor' => false,
'targets_literal' => 'ANNOTATION_PROPERTY',
'targets' => Target::TARGET_PROPERTY,
'default_property' => 'value',
'properties' => ['value' => 'value'],
'attribute_types' => [
'value' => ['type' => 'array', 'required' => true],
'literal' => ['type' => 'array', 'required' => false],
],
],
NamedArgumentConstructor::class => [
'is_annotation' => true,
'has_constructor' => false,
'has_named_argument_constructor' => false,
'targets_literal' => 'ANNOTATION_CLASS',
'targets' => Target::TARGET_CLASS,
'default_property' => null,
'properties' => [],
'attribute_types' => [],
],
]
|
#
|
private
static
|
array<string, string>
|
$typeMap = ['float' => 'double', 'bool' => 'boolean', 'Boolean' => 'boolean', 'int' => 'integer']
|
#
|