\Trismegiste\Mondrian\TransformReflectionContext

ReflectionContext is a context for Reflection on types

Responsible for maintaining a list of methods, traits, classes and interfaces used for building inheritance links in a digraph

Summary

Methods
Properties
Constants
__construct()
resolveSymbol()
findMethodInInheritanceTree()
initSymbol()
pushParentClass()
pushUseTrait()
addMethodToClass()
hasDeclaringClass()
getDeclaringClass()
getClassesUsingTraitForDeclaringMethod()
isInterface()
isTrait()
No public properties found
SYMBOL_TRAIT
SYMBOL_INTERFACE
SYMBOL_CLASS
resolveMethodDeclaration()
resolveTraitUse()
$inheritanceMap
N/A
recursivDeclaration()
$symbolTypes
N/A

Constants

SYMBOL_TRAIT

SYMBOL_TRAIT

SYMBOL_INTERFACE

SYMBOL_INTERFACE

SYMBOL_CLASS

SYMBOL_CLASS

Properties

$inheritanceMap

$inheritanceMap : 

Type

— array the symbol map

$symbolTypes

$symbolTypes : array

Type

array — List of three types : trait, class, interface

Methods

__construct()

__construct() 

Build the context

resolveSymbol()

resolveSymbol() 

Resolve all methods inheritance, use by traits and declared

findMethodInInheritanceTree()

findMethodInInheritanceTree(string  $cls, string  $method) : string

Find if method is declared in superclass.

Note1: Algo is DFS Note2: Must be called AFTER resolveSymbol Note3: this one is kewl, I don't know why it works at the first try

Parameters

string $cls
string $method

Returns

string —

the class which first declares the method (or null)

initSymbol()

initSymbol(string  $name, string  $symbolType) 

Initialize a new symbol

Parameters

string $name

class or interface name

string $symbolType

one of SYMBOL_ const

pushParentClass()

pushParentClass(string  $cls, string  $parent) 

Stacks a parent type for a type

Parameters

string $cls

the type

string $parent

the parent type of $cls

pushUseTrait()

pushUseTrait(  $cls,   $useTrait) 

Parameters

$cls
$useTrait

addMethodToClass()

addMethodToClass(string  $cls, string  $method) 

Add a method to its type with the current type for its default declaring type (after resolveSymbol, it changes)

Parameters

string $cls
string $method

hasDeclaringClass()

hasDeclaringClass(string  $cls) : boolean

Search if a type (trait, class or interface) exists in the inheritanceMap

Parameters

string $cls

Returns

boolean

getDeclaringClass()

getDeclaringClass(string  $cls, string  $meth) : string

Finds the FQCN of the first declaring class/interface of a method

Parameters

string $cls

subclass name

string $meth

method name

Returns

string

getClassesUsingTraitForDeclaringMethod()

getClassesUsingTraitForDeclaringMethod(string  $fqcn, string  $methodName) : array

Returns a list of all classes using a trait for declaring a given method

Parameters

string $fqcn

FQCN of trait

string $methodName

the imported method

Returns

array

isInterface()

isInterface(string  $cls) : boolean

Is FQCN an interface ?

Parameters

string $cls

FQCN

Returns

boolean

isTrait()

isTrait(string  $cls) : boolean

Is FQCN an interface ?

Parameters

string $cls

FQCN

Returns

boolean

resolveMethodDeclaration()

resolveMethodDeclaration() 

Construct the inheritanceMap of method by resolving which class or interface first declares a method

(not vey efficient algo, I admit), it sux, it's redundent, I don't like it

resolveTraitUse()

resolveTraitUse() 

recursivDeclaration()

recursivDeclaration(  $current,   $m) 

Parameters

$current
$m