Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

phpdocumentor/type-resolver 1.8.0

A PSR-5 based resolver of Class names, Types and Structural Element Names
Package summary
Share
0
issues
0
licenses
Package created
12 Jun 2015
Version published
11 Jan 2024
Maintainers
2
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does phpdocumentor/type-resolver do?

The phpDocumentor/Type-Resolver is a powerful tool based on the PSR-5 specification used to resolve class names, types and structural element names in PHP. It involves the creation of two resolvers that are capable of returning value objects for given expressions while resolving any partial class names and returning an FQSEN (Fully Qualified Structural Element Name) object after resolving any partial structural element names into fully qualified ones. This proves to be highly effective in resolving class names in doc blocks, dealing with arrays, compounds and object interfaces and more.

How do you use phpdocumentor/type-resolver?

To use phpDocumentor/Type-Resolver, you first need to install the package via Composer using the command composer require phpdocumentor/type-resolver. When you want to deal with types, you instantiate the TypeResolver class and call its resolve method. For instance:

$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('string|integer');

Here, the $type object represents a compound type consisting of the string and integer types.

Similarly, you can deal with FQSENs using the FqsenResolver class:

$fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
$fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()');

In this case, the $fqsen object represents a fully qualified structural element name.

One key strength of phpDocumentor/Type-Resolver is its ability to handle partial class names. This involves providing a bit of Context to the resolving actions. This is done by creating and using an instance of the Context class:

$context = new \phpDocumentor\Reflection\Types\Context('\My\Example',[ 'Types' => '\phpDocumentor\Reflection\Types']);
$typeResolver = new \phpDocumentor\Reflection\TypeResolver();
$type = $typeResolver->resolve('Types\Context', $context);

Here, a given type Types\Context is resolved into a fully qualified class name according to the provided namespace and aliases context.

Where are the phpdocumentor/type-resolver docs?

As for the documentation of phpDocumentor/Type-Resolver, the best source of reference is the GitHub page. The readme file of the repository provides a comprehensive guide on installation, usage, examples as well as understanding types and element names, resolving a type, resolving FQSEN areas and handling partial classes and structural element names.