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.

setIgnoredAnnotationNames(array $names)

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

setIgnoreNotImportedAnnotations($bool)

Sets ignore on not-imported annotations

addNamespace(array $namespace)

Sets the default namespaces.

setImports(array $imports)

Sets the imports

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.

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

setIgnoreNotImportedAnnotations($bool)

Sets ignore on not-imported annotations

Parameters

$bool

addNamespace(array $namespace)

Sets the default namespaces.

Parameters

array $namespace

Exceptions

RuntimeException

setImports(array $imports)

Sets the imports

Parameters

array $imports

Exceptions

RuntimeException

setTarget(integer $target)

Sets current target context as bitmask.

Parameters

integer $target

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.