Collection
extends ArrayObject
in package
Collection
Tags
Table of Contents
- OPERATOR_ARRAY = '[]'
- OPERATOR_NAMESPACE = '\'
- OPERATOR_OR = '|'
- $context : Context
- Current invoking location.
- $keywords : array<string|int, string>
- __construct() : mixed
- Registers the namespace and aliases; uses that to add and expand the given types.
- __toString() : string
- Returns a string representation of the collection.
- add() : void
- Adds a new type to the collection and expands it if it contains a relative namespace.
- getContext() : Context
- Returns the current invoking location.
- expand() : string
- Analyzes the given type and returns the FQCN variant.
- isRelativeType() : bool
- Detects whether the given type represents a relative or absolute path.
- isTypeAKeyword() : bool
- Detects whether the given type represents a PHPDoc keyword.
- isTypeAnArray() : bool
- Detects whether the given type represents an array.
- shouldBeAbsolute() : bool
- Detects if the type should actually be absolute, by checking if it exists.
Constants
OPERATOR_ARRAY
public
string
OPERATOR_ARRAY
= '[]'
Definition of the ARRAY operator for types
OPERATOR_NAMESPACE
public
string
OPERATOR_NAMESPACE
= '\'
Definition of the NAMESPACE operator in PHP
OPERATOR_OR
public
string
OPERATOR_OR
= '|'
Definition of the OR operator for types
Properties
$context
Current invoking location.
protected
Context
$context
= null
This is used to prepend to type with a relative location. May also be 'default' or 'global', in which case they are ignored.
$keywords
protected
static array<string|int, string>
$keywords
= array('string', 'int', 'integer', 'bool', 'boolean', 'float', 'double', 'object', 'mixed', 'array', 'resource', 'void', 'null', 'scalar', 'callback', 'callable', 'false', 'true', 'self', '$this', 'static')
List of recognized keywords
Methods
__construct()
Registers the namespace and aliases; uses that to add and expand the given types.
public
__construct([array<string|int, string> $types = array() ][, Context $context = null ]) : mixed
Parameters
- $types : array<string|int, string> = array()
-
Array containing a list of types to add to this container.
- $context : Context = null
Return values
mixed —__toString()
Returns a string representation of the collection.
public
__toString() : string
Return values
string —add()
Adds a new type to the collection and expands it if it contains a relative namespace.
public
add(string $type) : void
If a class in the type contains a relative namespace than this collection will try to expand that into a FQCN.
Parameters
- $type : string
-
A 'Type' as defined in the phpDocumentor documentation.
Tags
Return values
void —getContext()
Returns the current invoking location.
public
getContext() : Context
Return values
Context —expand()
Analyzes the given type and returns the FQCN variant.
protected
expand(string $type) : string
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
- $type : string
-
The relative or absolute type.
Tags
Return values
string —isRelativeType()
Detects whether the given type represents a relative or absolute path.
protected
isRelativeType(string $type) : bool
This method will detect keywords as being absolute; even though they are not preceeded by a namespace separator.
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.
Return values
bool —isTypeAKeyword()
Detects whether the given type represents a PHPDoc keyword.
protected
isTypeAKeyword(string $type) : bool
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.
Return values
bool —isTypeAnArray()
Detects whether the given type represents an array.
protected
isTypeAnArray(string $type) : bool
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.
Return values
bool —shouldBeAbsolute()
Detects if the type should actually be absolute, by checking if it exists.
protected
shouldBeAbsolute(string $type) : bool
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.