TypeResolver
in package
Table of Contents
- OPERATOR_ARRAY = '[]'
- OPERATOR_NAMESPACE = '\'
- PARSER_IN_ARRAY_EXPRESSION = 2
- PARSER_IN_COLLECTION_EXPRESSION = 3
- PARSER_IN_COMPOUND = 0
- PARSER_IN_NULLABLE = 1
- $fqsenResolver : FqsenResolver
- $keywords : array<string, string>
- __construct() : mixed
- Initializes this TypeResolver with the means to create and resolve Fqsen objects.
- addKeyword() : void
- Adds a keyword to the list of Keywords and associates it with a specific Value Object.
- resolve() : Type
- Analyzes the given type and returns the FQCN variant.
- isFqsen() : bool
- Tests whether the given type is a Fully Qualified Structural Element Name.
- isKeyword() : bool
- Detects whether the given type represents a PHPDoc keyword.
- isPartialStructuralElementName() : bool
- Detects whether the given type represents a relative structural element name.
- makeCollectionFromObject() : Collection
- parseTypes() : Type
- Analyse each tokens and creates types
- resolveClassString() : Type
- Resolves class string
- resolveCollection() : Array_|Iterable_|Collection
- Resolves the collection values and keys
- resolveKeyword() : Type
- Resolves the given keyword (such as `string`) into a Type object representing that keyword.
- resolveSingleType() : Type|Array_|Object_
- resolve the given type into a type object
- resolveTypedObject() : Object_
- Resolves the given FQSEN string into an FQSEN object.
Constants
OPERATOR_ARRAY
private
string
OPERATOR_ARRAY
= '[]'
OPERATOR_NAMESPACE
private
string
OPERATOR_NAMESPACE
= '\'
PARSER_IN_ARRAY_EXPRESSION
private
int
PARSER_IN_ARRAY_EXPRESSION
= 2
PARSER_IN_COLLECTION_EXPRESSION
private
int
PARSER_IN_COLLECTION_EXPRESSION
= 3
PARSER_IN_COMPOUND
private
int
PARSER_IN_COMPOUND
= ""
PARSER_IN_NULLABLE
private
int
PARSER_IN_NULLABLE
= 1
Properties
$fqsenResolver
private
FqsenResolver
$fqsenResolver
Tags
$keywords
private
array<string, string>
$keywords
= ['string' => phpDocumentorReflectionTypesString_::class, 'class-string' => phpDocumentorReflectionTypesClassString::class, 'int' => phpDocumentorReflectionTypesInteger::class, 'integer' => phpDocumentorReflectionTypesInteger::class, 'bool' => phpDocumentorReflectionTypesBoolean::class, 'boolean' => phpDocumentorReflectionTypesBoolean::class, 'real' => phpDocumentorReflectionTypesFloat_::class, 'float' => phpDocumentorReflectionTypesFloat_::class, 'double' => phpDocumentorReflectionTypesFloat_::class, 'object' => phpDocumentorReflectionTypesObject_::class, 'mixed' => phpDocumentorReflectionTypesMixed_::class, 'array' => phpDocumentorReflectionTypesArray_::class, 'resource' => phpDocumentorReflectionTypesResource_::class, 'void' => phpDocumentorReflectionTypesVoid_::class, 'null' => phpDocumentorReflectionTypesNull_::class, 'scalar' => phpDocumentorReflectionTypesScalar::class, 'callback' => phpDocumentorReflectionTypesCallable_::class, 'callable' => phpDocumentorReflectionTypesCallable_::class, 'false' => phpDocumentorReflectionPseudoTypesFalse_::class, 'true' => phpDocumentorReflectionPseudoTypesTrue_::class, 'self' => phpDocumentorReflectionTypesSelf_::class, '$this' => phpDocumentorReflectionTypesThis::class, 'static' => phpDocumentorReflectionTypesStatic_::class, 'parent' => phpDocumentorReflectionTypesParent_::class, 'iterable' => phpDocumentorReflectionTypesIterable_::class]
Tags
Methods
__construct()
Initializes this TypeResolver with the means to create and resolve Fqsen objects.
public
__construct([FqsenResolver|null $fqsenResolver = null ]) : mixed
Parameters
- $fqsenResolver : FqsenResolver|null = null
Return values
mixed —addKeyword()
Adds a keyword to the list of Keywords and associates it with a specific Value Object.
public
addKeyword(string $keyword, string $typeClassName) : void
Parameters
- $keyword : string
- $typeClassName : string
Tags
Return values
void —resolve()
Analyzes the given type and returns the FQCN variant.
public
resolve(string $type[, Context|null $context = null ]) : Type
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.
- $context : Context|null = null
Tags
Return values
Type —isFqsen()
Tests whether the given type is a Fully Qualified Structural Element Name.
private
isFqsen(string $type) : bool
Parameters
- $type : string
Tags
Return values
bool —isKeyword()
Detects whether the given type represents a PHPDoc keyword.
private
isKeyword(string $type) : bool
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.
Tags
Return values
bool —isPartialStructuralElementName()
Detects whether the given type represents a relative structural element name.
private
isPartialStructuralElementName(string $type) : bool
Parameters
- $type : string
-
A relative or absolute type as defined in the phpDocumentor documentation.
Tags
Return values
bool —makeCollectionFromObject()
private
makeCollectionFromObject(Object_ $object, Type $valueType[, Type|null $keyType = null ]) : Collection
Parameters
Tags
Return values
Collection —parseTypes()
Analyse each tokens and creates types
private
parseTypes(ArrayIterator<int, string|null> $tokens, Context $context, int $parserContext) : Type
Parameters
- $tokens : ArrayIterator<int, string|null>
-
the iterator on tokens
- $context : Context
- $parserContext : int
-
on of self::PARSER_* constants, indicating the context where we are in the parsing
Return values
Type —resolveClassString()
Resolves class string
private
resolveClassString(ArrayIterator<int, (string|null)> $tokens, Context $context) : Type
Parameters
- $tokens : ArrayIterator<int, (string|null)>
- $context : Context
Return values
Type —resolveCollection()
Resolves the collection values and keys
private
resolveCollection(ArrayIterator<int, (string|null)> $tokens, Type $classType, Context $context) : Array_|Iterable_|Collection
Parameters
Return values
Array_|Iterable_|Collection —resolveKeyword()
Resolves the given keyword (such as `string`) into a Type object representing that keyword.
private
resolveKeyword(string $type) : Type
Parameters
- $type : string
Tags
Return values
Type —resolveSingleType()
resolve the given type into a type object
private
resolveSingleType(string $type, Context $context) : Type|Array_|Object_
Parameters
- $type : string
-
the type string, representing a single type
- $context : Context
Tags
Return values
Type|Array_|Object_ —resolveTypedObject()
Resolves the given FQSEN string into an FQSEN object.
private
resolveTypedObject(string $type[, Context|null $context = null ]) : Object_
Parameters
- $type : string
- $context : Context|null = null