class DocParser (View source)

A parser for docblock annotations.

It is strongly discouraged to change the default annotation parsing process.

Methods

__construct()

Constructs a new DocParser.

void
setIgnoredAnnotationNames(array $names)

Sets the annotation names that are ignored during the parsing process.

void
setIgnoredAnnotationNamespaces(bool[] $ignoredAnnotationNamespaces)

Sets the annotation namespaces that are ignored during the parsing process.

void
setIgnoreNotImportedAnnotations(boolean $bool)

Sets ignore on not-imported annotations.

void
addNamespace(string $namespace)

Sets the default namespaces.

void
setImports(array $imports)

Sets the imports.

void
setTarget(integer $target)

Sets current target context as bitmask.

array
parse(string $input, string $context = '')

Parses the given docblock string for annotations.

Details

__construct()

Constructs a new DocParser.

void setIgnoredAnnotationNames(array $names)

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

array $names indexed by annotation name

Return Value

void

void setIgnoredAnnotationNamespaces(bool[] $ignoredAnnotationNamespaces)

Sets the annotation namespaces that are ignored during the parsing process.

Parameters

bool[] $ignoredAnnotationNamespaces indexed by annotation namespace name

Return Value

void

void setIgnoreNotImportedAnnotations(boolean $bool)

Sets ignore on not-imported annotations.

Parameters

boolean $bool

Return Value

void

void addNamespace(string $namespace)

Sets the default namespaces.

Parameters

string $namespace

Return Value

void

Exceptions

RuntimeException

void setImports(array $imports)

Sets the imports.

Parameters

array $imports

Return Value

void

Exceptions

RuntimeException

void setTarget(integer $target)

Sets current target context as bitmask.

Parameters

integer $target

Return Value

void

array parse(string $input, string $context = '')

Parses the given docblock string for annotations.

Parameters

string $input The docblock string to parse.
string $context The parsing context.

Return Value

array Array of annotations. If no annotations are found, an empty array is returned.