Copied!
CloneableFinalInstantiable
Methods
public __construct(?phpDocumentor\Reflection\FqsenResolver $fqsenResolver = NULL)
 

Initializes this TypeResolver with the means to create and resolve Fqsen objects.

public addKeyword(string $keyword, string $typeClassName) : void
 

Adds a keyword to the list of Keywords and associates it with a specific Value Object.

  • psalm-param class-string<Type> $typeClassName
public createType(?PHPStan\PhpDocParser\Ast\Type\TypeNode $type, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\Type
public resolve(string $type, ?phpDocumentor\Reflection\Types\Context $context = NULL) : phpDocumentor\Reflection\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.

  • uses \Context::getNamespace()to determine with what to prefix the type name.
  • uses \Context::getNamespaceAliases()to check whether the first part of the relative type name should not be replaced with another namespace.
  • param string $type The relative or absolute type.
Constants
private phpDocumentor\Reflection\TypeResolver::OPERATOR_NAMESPACE = '\'
 
  • var string Definition of the NAMESPACE operator in PHP
Properties
private $fqsenResolver = NULL
 
  • psalm-readonly
  • var \FqsenResolver
private $keywords = ['string' => 'phpDocumentor\Reflection\Types\String_', 'class-string' => 'phpDocumentor\Reflection\PseudoTypes\ClassString', 'interface-string' => 'phpDocumentor\Reflection\PseudoTypes\InterfaceString', 'html-escaped-string' => 'phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString', 'lowercase-string' => 'phpDocumentor\Reflection\PseudoTypes\LowercaseString', 'non-empty-lowercase-string' => 'phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString', 'non-empty-string' => 'phpDocumentor\Reflection\PseudoTypes\NonEmptyString', 'numeric-string' => 'phpDocumentor\Reflection\PseudoTypes\NumericString', 'numeric' => 'phpDocumentor\Reflection\PseudoTypes\Numeric_', 'trait-string' => 'phpDocumentor\Reflection\PseudoTypes\TraitString', 'enum-string' => 'phpDocumentor\Reflection\PseudoTypes\EnumString', 'int' => 'phpDocumentor\Reflection\Types\Integer', 'integer' => 'phpDocumentor\Reflection\Types\Integer', 'positive-int' => 'phpDocumentor\Reflection\PseudoTypes\PositiveInteger', 'negative-int' => 'phpDocumentor\Reflection\PseudoTypes\NegativeInteger', 'bool' => 'phpDocumentor\Reflection\Types\Boolean', 'boolean' => 'phpDocumentor\Reflection\Types\Boolean', 'real' => 'phpDocumentor\Reflection\Types\Float_', 'float' => 'phpDocumentor\Reflection\Types\Float_', 'double' => 'phpDocumentor\Reflection\Types\Float_', 'object' => 'phpDocumentor\Reflection\Types\Object_', 'mixed' => 'phpDocumentor\Reflection\Types\Mixed_', 'array' => 'phpDocumentor\Reflection\Types\Array_', 'callable-array' => 'phpDocumentor\Reflection\PseudoTypes\CallableArray', 'array-key' => 'phpDocumentor\Reflection\PseudoTypes\ArrayKey', 'non-empty-array' => 'phpDocumentor\Reflection\PseudoTypes\NonEmptyArray', 'resource' => 'phpDocumentor\Reflection\Types\Resource_', 'open-resource' => 'phpDocumentor\Reflection\PseudoTypes\OpenResource', 'closed-resource' => 'phpDocumentor\Reflection\PseudoTypes\ClosedResource', 'void' => 'phpDocumentor\Reflection\Types\Void_', 'null' => 'phpDocumentor\Reflection\Types\Null_', 'scalar' => 'phpDocumentor\Reflection\PseudoTypes\Scalar', 'callback' => 'phpDocumentor\Reflection\Types\Callable_', 'callable' => 'phpDocumentor\Reflection\Types\Callable_', 'callable-string' => 'phpDocumentor\Reflection\PseudoTypes\CallableString', 'false' => 'phpDocumentor\Reflection\PseudoTypes\False_', 'true' => 'phpDocumentor\Reflection\PseudoTypes\True_', 'literal-string' => 'phpDocumentor\Reflection\PseudoTypes\LiteralString', 'self' => 'phpDocumentor\Reflection\Types\Self_', '$this' => 'phpDocumentor\Reflection\Types\This', 'static' => 'phpDocumentor\Reflection\Types\Static_', 'parent' => 'phpDocumentor\Reflection\Types\Parent_', 'iterable' => 'phpDocumentor\Reflection\Types\Iterable_', 'never' => 'phpDocumentor\Reflection\Types\Never_', 'never-return' => 'phpDocumentor\Reflection\PseudoTypes\NeverReturn', 'never-returns' => 'phpDocumentor\Reflection\PseudoTypes\NeverReturns', 'no-return' => 'phpDocumentor\Reflection\PseudoTypes\NoReturn', 'list' => 'phpDocumentor\Reflection\PseudoTypes\List_', 'non-empty-list' => 'phpDocumentor\Reflection\PseudoTypes\NonEmptyList', 'non-falsy-string' => 'phpDocumentor\Reflection\PseudoTypes\NonFalsyString', 'truthy-string' => 'phpDocumentor\Reflection\PseudoTypes\TruthyString', 'non-positive-int' => 'phpDocumentor\Reflection\PseudoTypes\NonPositiveInteger', 'non-negative-int' => 'phpDocumentor\Reflection\PseudoTypes\NonNegativeInteger', 'non-zero-int' => 'phpDocumentor\Reflection\PseudoTypes\NonZeroInteger']
 
  • var array<string, string> List of recognized keywords and unto which Value Object they map
  • psalm-var array<string, class-string<Type>>
private $lexer = NULL
 
  • psalm-readonly
  • var \Lexer
private $typeParser = NULL
 
  • psalm-readonly
  • var \TypeParser
Methods
private createFromCallable(PHPStan\PhpDocParser\Ast\Type\CallableTypeNode $type, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\Types\Callable_
private createFromConst(PHPStan\PhpDocParser\Ast\Type\ConstTypeNode $type, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\Type
private createFromGeneric(PHPStan\PhpDocParser\Ast\Type\GenericTypeNode $type, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\Type
private createTypesByTypeNodes(array $nodes, phpDocumentor\Reflection\Types\Context $context) : array
 
  • param \TypeNode[] $nodes
  • return \Type[]
private isFqsen(string $type) : bool
 

Tests whether the given type is a Fully Qualified Structural Element Name.

  • psalm-mutation-free
private isKeyword(string $type) : bool
 

Detects whether the given type represents a PHPDoc keyword.

  • param string $type A relative or absolute type as defined in the phpDocumentor documentation.
  • psalm-mutation-free
private isPartialStructuralElementName(string $type) : bool
 

Detects whether the given type represents a relative structural element name.

  • param string $type A relative or absolute type as defined in the phpDocumentor documentation.
  • psalm-mutation-free
private parse(PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : PHPStan\PhpDocParser\Ast\Type\TypeNode
private resolveKeyword(string $type) : phpDocumentor\Reflection\Type
 

Resolves the given keyword (such as string) into a Type object representing that keyword.

  • psalm-mutation-free
private resolveSingleType(string $type, phpDocumentor\Reflection\Types\Context $context) : object
 

resolve the given type into a type object

  • param string $type the type string, representing a single type
  • return \Type|\Array_|\Object_
  • psalm-mutation-free
private resolveTypedObject(string $type, ?phpDocumentor\Reflection\Types\Context $context = NULL) : phpDocumentor\Reflection\Types\Object_
 

Resolves the given FQSEN string into an FQSEN object.

  • psalm-mutation-free
© 2026 Bruce Wells
Search Namespaces \ Classes
Configuration