PHP Class Trismegiste\Mondrian\Transform\ReflectionContext

Responsible for maintaining a list of methods, traits, classes and interfaces used for building inheritance links in a digraph
显示文件 Open project: trismegiste/mondrian

Protected Properties

Property Type Description
$inheritanceMap array the symbol map

Public Methods

Method Description
__construct ( ) Build the context
addMethodToClass ( string $cls, string $method ) Add a method to its type with the current type for its default declaring type (after resolveSymbol, it changes)
findMethodInInheritanceTree ( string $cls, string $method ) : string Find if method is declared in superclass.
getClassesUsingTraitForDeclaringMethod ( string $fqcn, string $methodName ) : array Returns a list of all classes using a trait for declaring a given method
getDeclaringClass ( string $cls, string $meth ) : string Finds the FQCN of the first declaring class/interface of a method
hasDeclaringClass ( string $cls ) : boolean Search if a type (trait, class or interface) exists in the inheritanceMap
initClass ( $name )
initInterface ( $name )
initSymbol ( string $name, string $symbolType ) Initialize a new symbol
initTrait ( $name )
isInterface ( string $cls ) : boolean Is FQCN an interface ?
isTrait ( string $cls ) : boolean Is FQCN an interface ?
pushParentClass ( string $cls, string $parent ) Stacks a parent type for a type
pushUseTrait ( $cls, $useTrait )
resolveSymbol ( ) Resolve all methods inheritance, use by traits and declared

Protected Methods

Method Description
resolveMethodDeclaration ( ) Construct the inheritanceMap of method by resolving which class or interface first declares a method
resolveTraitUse ( )

Private Methods

Method Description
recursivDeclaration ( $current, $m )

Method Details

__construct() public method

Build the context
public __construct ( )

addMethodToClass() public method

Add a method to its type with the current type for its default declaring type (after resolveSymbol, it changes)
public addMethodToClass ( string $cls, string $method )
$cls string
$method string

findMethodInInheritanceTree() public method

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
public findMethodInInheritanceTree ( string $cls, string $method ) : string
$cls string
$method string
return string the class which first declares the method (or null)

getClassesUsingTraitForDeclaringMethod() public method

Returns a list of all classes using a trait for declaring a given method
public getClassesUsingTraitForDeclaringMethod ( string $fqcn, string $methodName ) : array
$fqcn string FQCN of trait
$methodName string the imported method
return array

getDeclaringClass() public method

Finds the FQCN of the first declaring class/interface of a method
public getDeclaringClass ( string $cls, string $meth ) : string
$cls string subclass name
$meth string method name
return string

hasDeclaringClass() public method

Search if a type (trait, class or interface) exists in the inheritanceMap
public hasDeclaringClass ( string $cls ) : boolean
$cls string
return boolean

initClass() public method

public initClass ( $name )

initInterface() public method

public initInterface ( $name )

initSymbol() public method

Initialize a new symbol
public initSymbol ( string $name, string $symbolType )
$name string class or interface name
$symbolType string one of SYMBOL_ const

initTrait() public method

public initTrait ( $name )

isInterface() public method

Is FQCN an interface ?
public isInterface ( string $cls ) : boolean
$cls string FQCN
return boolean

isTrait() public method

Is FQCN an interface ?
public isTrait ( string $cls ) : boolean
$cls string FQCN
return boolean

pushParentClass() public method

Stacks a parent type for a type
public pushParentClass ( string $cls, string $parent )
$cls string the type
$parent string the parent type of $cls

pushUseTrait() public method

public pushUseTrait ( $cls, $useTrait )

resolveMethodDeclaration() protected method

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

resolveSymbol() public method

Resolve all methods inheritance, use by traits and declared
public resolveSymbol ( )

resolveTraitUse() protected method

protected resolveTraitUse ( )

Property Details

$inheritanceMap protected_oe property

array the symbol map
protected $inheritanceMap