PHP Classes

File: vendor/phpdocumentor/type-resolver/examples/04-discovering-the-context-using-class-reflection.php

Recommend this page to a friend!
  Classes of Renato De Oliveira Lucena  >  PHP Pokemon Script  >  vendor/phpdocumentor/type-resolver/examples/04-discovering-the-context-using-class-reflection.php  >  Download  
File: vendor/phpdocumentor/type-resolver/examples/04-discovering-the-context-using-class-reflection.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Pokemon Script
Provides an API to manage a database of Pokemons
Author: By
Last change:
Date: 2 years ago
Size: 1,240 bytes


Class file image Download

use phpDocumentor\Reflection\FqsenResolver;


$typeResolver = new TypeResolver();
$fqsenResolver = new FqsenResolver();

$contextFactory = new ContextFactory();
$context = $contextFactory->createFromReflector(new ReflectionClass('My\\Example\\Classy'));

// Class named: \phpDocumentor\Reflection\Types\Resolver
var_dump((string)$typeResolver->resolve('Types\Resolver', $context));

// String
var_dump((string)$typeResolver->resolve('string', $context));

// Property named: \phpDocumentor\Reflection\Types\Resolver::$keyWords
var_dump((string)$fqsenResolver->resolve('Types\Resolver::$keyWords', $context));

// Class named: \My\Example\string
// - Shows the difference between the FqsenResolver and TypeResolver; the FqsenResolver will assume
// that the given value is not a type but most definitely a reference to another element. This is
// because conflicts between type keywords and class names can exist and if you know a reference
// is not a type but an element you can force that keywords are resolved.
var_dump((string)$fqsenResolver->resolve('string', $context));

For more information send a message to info at phpclasses dot org.