Documentation

Collection extends ArrayObject
in package

Collection

Tags
author

Mike van Riel mike.vanriel@naenius.com

copyright

2010-2011 Mike van Riel / Naenius (http://www.naenius.com)

license

http://www.opensource.org/licenses/mit-license.php MIT

link
http://phpdoc.org

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

The resolved types across the collection, separated with .

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
throws
InvalidArgumentException

if a non-string argument is passed.

see
http://phpdoc.org/docs/latest/for-users/types.html

for the definition of a type.

Return values
void

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
uses
getNamespace

to determine with what to prefix the type name.

uses
getNamespaceAliases

to check whether the first part of the relative type name should not be replaced with another namespace.

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.

Return values
bool

Search results