class Collection extends ArrayObject

Class Collection - Collection

Constants

OPERATOR_OR

OPERATOR_ARRAY

OPERATOR_NAMESPACE

Properties

static protected string[] $keywords
protected Context $context Current invoking location.

Methods

__construct(array $types = array(), Context $context = null)

Registers the namespace and aliases; uses that to add and expand the given types.

getContext()

Returns the current invoking location.

void
add(string $type)

Adds a new type to the collection and expands it if it contains a relative namespace.

string
__toString()

Returns a string representation of the collection.

string
expand(string $type)

Analyzes the given type and returns the FQCN variant.

bool
isTypeAnArray(string $type)

Detects whether the given type represents an array.

bool
isTypeAKeyword(string $type)

Detects whether the given type represents a PHPDoc keyword.

bool
isRelativeType(string $type)

Detects whether the given type represents a relative or absolute path.

Details

at line 50
__construct(array $types = array(), Context $context = null)

Registers the namespace and aliases; uses that to add and expand the given types.

Parameters

array $types Array containing a list of types to add to this container.
Context $context The current invoking location.

at line 63
Context getContext()

Returns the current invoking location.

Return Value

Context

at line 83
void add(string $type)

Adds a new type to the collection and expands it if it contains a relative namespace.

If a class in the type contains a relative namespace than this collection will try to expand that into a FQCN.

Parameters

string $type A 'Type' as defined in the documentation.

Return Value

void

Exceptions

InvalidArgumentException if a non-string argument is passed.

See also

http://phpdoc.org/docs/latest/for-users/types.html for the definition of a type.

at line 106
string __toString()

Returns a string representation of the collection.

Return Value

string The resolved types across the collection, separated with {@link self::OPERATOR_OR}.

at line 129
protected string expand(string $type)

Analyzes the given type and returns the FQCN variant.

When a type is provided this method checks whether it is not a keyword or Fully Qualified Class Name. If so it will use the given namespace and aliases to expand the type to a FQCN representation.

This method only works as expected if the namespace and aliases are set; no dynamic reflection is being performed here.

Parameters

string $type The relative or absolute type.

Return Value

string

at line 171
protected bool isTypeAnArray(string $type)

Detects whether the given type represents an array.

Parameters

string $type A relative or absolute type as defined in the documentation.

Return Value

bool

at line 183
protected bool isTypeAKeyword(string $type)

Detects whether the given type represents a PHPDoc keyword.

Parameters

string $type A relative or absolute type as defined in the documentation.

Return Value

bool

at line 198
protected bool isRelativeType(string $type)

Detects whether the given type represents a relative or absolute path.

This method will detect keywords as being absolute; even though they are not preceeded by a namespace separator.

Parameters

string $type A relative or absolute type as defined in the documentation.

Return Value

bool