Convenience class to create a Context for DocBlocks when not using the Reflection Component of phpDocumentor.

For a DocBlock to be able to resolve types that use partial namespace names or rely on namespace imports we need to
provide a bit of context so that the DocBlock can read that and based on it decide how to resolve the types to
Fully Qualified names.

  • see \Contextfor more information.
public createForNamespace(string $namespace, string $fileContents) : phpDocumentor\Reflection\Types\Context

Build a Context for a namespace in the provided file contents.

  • see \Contextfor more information on Contexts.
public createFromReflector(Reflector $reflector) : phpDocumentor\Reflection\Types\Context

Build a Context given a Class Reflection.

  • see \Contextfor more information on Contexts.
private phpDocumentor\Reflection\Types\ContextFactory::T_LITERAL_END_OF_USE = ';'

The literal used at the end of a use statement.

private phpDocumentor\Reflection\Types\ContextFactory::T_LITERAL_USE_SEPARATOR = ','

The literal used between sets of use statements

private createFromReflectionClass(ReflectionClass $class) : phpDocumentor\Reflection\Types\Context
    private createFromReflectionClassConstant(ReflectionClassConstant $constant) : phpDocumentor\Reflection\Types\Context
    private createFromReflectionMethod(ReflectionMethod $method) : phpDocumentor\Reflection\Types\Context
    private createFromReflectionParameter(ReflectionParameter $parameter) : phpDocumentor\Reflection\Types\Context
    private createFromReflectionProperty(ReflectionProperty $property) : phpDocumentor\Reflection\Types\Context
    private extractUseStatements(ArrayIterator $tokens) : array

    Deduce the namespace name and alias of an import when we are at the T_USE token or have not reached the end of
    a USE statement yet. This will return a key/value array of the alias => namespace.

    • return string[]
    • psalm-suppress TypeDoesNotContainType
    • psalm-return array
    private parseNamespace(ArrayIterator $tokens) : string

    Deduce the name from tokens when we are at the T_NAMESPACE token.

      private parseUseStatement(ArrayIterator $tokens) : array

      Deduce the names of all imports when we are at the T_USE token.

      • return string[]
      • psalm-return array
      private skipToNextStringOrNamespaceSeparator(ArrayIterator $tokens) : void

      Fast-forwards the iterator as longs as we don't encounter a T_STRING or T_NS_SEPARATOR token.

        © 2020 Bruce Wells
        Search Namespaces \ Classes
        ConfigurationNumbers (0-9.) only