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\Types\ClassString', 'interface-string' => 'phpDocumentor\Reflection\Types\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', '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_', 'array-key' => 'phpDocumentor\Reflection\Types\ArrayKey', 'resource' => 'phpDocumentor\Reflection\Types\Resource_', 'void' => 'phpDocumentor\Reflection\Types\Void_', 'null' => 'phpDocumentor\Reflection\Types\Null_', 'scalar' => 'phpDocumentor\Reflection\Types\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_', 'list' => 'phpDocumentor\Reflection\PseudoTypes\List_', 'non-empty-list' => 'phpDocumentor\Reflection\PseudoTypes\NonEmptyList']
 
  • 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 createArray(array $typeNodes, phpDocumentor\Reflection\Types\Context $context) : phpDocumentor\Reflection\Types\Array_
 
  • param \TypeNode[] $typeNodes
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 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
private tryParseRemainingCompoundTypes(PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator, phpDocumentor\Reflection\Types\Context $context, phpDocumentor\Reflection\Type $type) : phpDocumentor\Reflection\Type
 

Will try to parse unsupported type notations by phpstan

The phpstan parser doesn't support the illegal nullable combinations like this library does. This method will warn the user about those notations but for bc purposes we will still have it here.

private validArrayKeyType(?phpDocumentor\Reflection\Type $type) : bool
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration