PHP Class Phan\Language\Element\Clazz

Inheritance: extends AddressableElement, use trait Phan\Memoize
Show file Open project: etsy/phan Class Usage Examples

Public Methods

Method Description
__construct ( Context $context, string $name, UnionType $type, integer $flags, FullyQualifiedClassName $fqsen, Type $parent_type = null, array $interface_fqsen_list = [], array $trait_fqsen_list = [] )
__toString ( ) : string
addConstant ( CodeBase $code_base, ClassConstant $constant ) : null; Add a class constant
addInterfaceClassFQSEN ( Phan\Language\FQSEN $fqsen ) : null
addMethod ( CodeBase $code_base, Method $method, Option | Phan\Library\None $type_option ) : null Add a method to this class
addProperty ( CodeBase $code_base, Property $property, Option | Phan\Library\None $type_option ) : void Add a property to this class
addTraitFQSEN ( Phan\Language\FQSEN $fqsen ) : null
analyze ( CodeBase $code_base ) : void This method should be called after hydration
fromClassName ( CodeBase $code_base, string $class_name ) : Clazz
fromReflectionClass ( CodeBase $code_base, ReflectionClass $class ) : Clazz
getAncestorClassList ( CodeBase $code_base ) : Clazz[]
getAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
getCallMethod ( CodeBase $code_base ) : Method
getCallStaticMethod ( CodeBase $code_base ) : Method
getConstantMap ( CodeBase $code_base ) : array
getConstantWithName ( CodeBase $code_base, string $name ) : ClassConstant
getFQSEN ( ) : FullyQualifiedClassName
getHasDynamicProperties ( CodeBase $code_base ) : boolean
getHierarchyDepth ( CodeBase $code_base ) : integer
getHierarchyRootFQSEN ( CodeBase $code_base ) : FullyQualifiedClassName
getInterfaceFQSENList ( ) : array
getIsParentConstructorCalled ( ) : boolean
getMethodByName ( CodeBase $code_base, string $name ) : Method
getMethodByNameInContext ( CodeBase $code_base, string $name, Context $context ) : Method
getMethodMap ( CodeBase $code_base ) : array
getNonParentAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
getOverridableAncestorClassList ( CodeBase $code_base ) : Clazz[]
getOverridableAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
getParentClass ( CodeBase $code_base ) : Clazz
getParentClassFQSEN ( ) : FullyQualifiedClassName
getParentTypeOption ( ) : Option
getPropertyByNameInContext ( CodeBase $code_base, string $name, Context $context ) : Property
getPropertyList ( CodeBase $code_base ) : Property[]
getPropertyMap ( CodeBase $code_base ) : array
getReferenceCount ( CodeBase $code_base ) : integer
getTemplateTypeMap ( ) : array
getTraitFQSENList ( ) : array
hasCallMethod ( CodeBase $code_base ) : boolean
hasCallOrCallStaticMethod ( CodeBase $code_base ) : boolean
hasCallStaticMethod ( CodeBase $code_base ) : boolean
hasConstantWithName ( CodeBase $code_base, string $name ) : boolean
hasGetMethod ( CodeBase $code_base ) : boolean
hasGetOrSetMethod ( CodeBase $code_base ) : boolean
hasMethodWithName ( CodeBase $code_base, string $name ) : boolean
hasParentType ( ) : boolean
hasPropertyWithName ( CodeBase $code_base, string $name ) : boolean
hasSetMethod ( CodeBase $code_base ) : boolean
importAncestorClass ( CodeBase $code_base, Clazz $class, Option | Phan\Library\None $type_option ) : void Add properties, constants and methods from the given class to this.
importAncestorClasses ( CodeBase $code_base ) : null Add properties, constants and methods from all ancestors (parents, traits, .
importParentClass ( CodeBase $code_base ) * Add properties, constants and methods from the parent of this class
isAbstract ( ) : boolean
isFinal ( ) : boolean
isGeneric ( ) : boolean
isInterface ( ) : boolean
isSubclassOf ( CodeBase $code_base, Clazz $other ) : boolean
isTrait ( ) : boolean
setHasDynamicProperties ( boolean $has_dynamic_properties ) : void
setIsParentConstructorCalled ( boolean $is_parent_constructor_called ) : void
setParentType ( Type $parent_type = null ) : void

Protected Methods

Method Description
hydrateOnce ( CodeBase $code_base ) : void This method must be called before analysis begins.

Private Methods

Method Description
getClassListFromFQSENList ( CodeBase $code_base, array $fqsen_list ) : array

Method Details

__construct() public method

public __construct ( Context $context, string $name, UnionType $type, integer $flags, FullyQualifiedClassName $fqsen, Type $parent_type = null, array $interface_fqsen_list = [], array $trait_fqsen_list = [] )
$context Phan\Language\Context The context in which the structural element lives
$name string
$type Phan\Language\UnionType
$flags integer
$fqsen Phan\Language\FQSEN\FullyQualifiedClassName A fully qualified name for this class
$parent_type Phan\Language\Type
$interface_fqsen_list array
$trait_fqsen_list array

__toString() public method

public __toString ( ) : string
return string A string describing this class

addConstant() public method

Add a class constant
public addConstant ( CodeBase $code_base, ClassConstant $constant ) : null;
$code_base Phan\CodeBase
$constant ClassConstant
return null;

addInterfaceClassFQSEN() public method

public addInterfaceClassFQSEN ( Phan\Language\FQSEN $fqsen ) : null
$fqsen Phan\Language\FQSEN Add the given FQSEN to the list of implemented interfaces for this class
return null

addMethod() public method

Add a method to this class
public addMethod ( CodeBase $code_base, Method $method, Option | Phan\Library\None $type_option ) : null
$code_base Phan\CodeBase A reference to the code base in which the ancestor exists
$method Method The method to copy onto this class
$type_option Option | Phan\Library\None
return null

addProperty() public method

Add a property to this class
public addProperty ( CodeBase $code_base, Property $property, Option | Phan\Library\None $type_option ) : void
$code_base Phan\CodeBase A reference to the code base in which the ancestor exists
$property Property The property to copy onto this class
$type_option Option | Phan\Library\None
return void

addTraitFQSEN() public method

public addTraitFQSEN ( Phan\Language\FQSEN $fqsen ) : null
$fqsen Phan\Language\FQSEN
return null

analyze() final public method

This method should be called after hydration
final public analyze ( CodeBase $code_base ) : void
$code_base Phan\CodeBase
return void

fromClassName() public static method

public static fromClassName ( CodeBase $code_base, string $class_name ) : Clazz
$code_base Phan\CodeBase A reference to the entire code base in which this context exists
$class_name string The name of a builtin class to build a new Class structural element from.
return Clazz A Class structural element representing the given named builtin.

fromReflectionClass() public static method

public static fromReflectionClass ( CodeBase $code_base, ReflectionClass $class ) : Clazz
$code_base Phan\CodeBase A reference to the entire code base in which this context exists
$class ReflectionClass A reflection class representing a builtin class.
return Clazz A Class structural element representing the given named builtin.

getAncestorClassList() public method

public getAncestorClassList ( CodeBase $code_base ) : Clazz[]
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Clazz[]

getAncestorFQSENList() public method

public getAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
$code_base Phan\CodeBase
return Phan\Language\FQSEN\FullyQualifiedClassName[]

getCallMethod() public method

public getCallMethod ( CodeBase $code_base ) : Method
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Method The magic `__call` method

getCallStaticMethod() public method

public getCallStaticMethod ( CodeBase $code_base ) : Method
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Method The magic `__callStatic` method

getConstantMap() public method

public getConstantMap ( CodeBase $code_base ) : array
$code_base Phan\CodeBase
return array The constants associated with this class

getConstantWithName() public method

public getConstantWithName ( CodeBase $code_base, string $name ) : ClassConstant
$code_base Phan\CodeBase
$name string
return ClassConstant The class constant with the given name.

getFQSEN() public method

public getFQSEN ( ) : FullyQualifiedClassName
return Phan\Language\FQSEN\FullyQualifiedClassName

getHasDynamicProperties() public method

public getHasDynamicProperties ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase
return boolean True if this class calls its parent constructor

getHierarchyDepth() public method

public getHierarchyDepth ( CodeBase $code_base ) : integer
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return integer This class's depth in the class hierarchy

getHierarchyRootFQSEN() public method

public getHierarchyRootFQSEN ( CodeBase $code_base ) : FullyQualifiedClassName
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Phan\Language\FQSEN\FullyQualifiedClassName The FQSEN of the root class on this class's hiearchy

getInterfaceFQSENList() public method

public getInterfaceFQSENList ( ) : array
return array Get the list of interfaces implemented by this class

getIsParentConstructorCalled() public method

public getIsParentConstructorCalled ( ) : boolean
return boolean True if this class calls its parent constructor

getMethodByName() public method

public getMethodByName ( CodeBase $code_base, string $name ) : Method
$code_base Phan\CodeBase
$name string
return Method The method with the given name

getMethodByNameInContext() public method

public getMethodByNameInContext ( CodeBase $code_base, string $name, Context $context ) : Method
$code_base Phan\CodeBase
$name string
$context Phan\Language\Context
return Method The method with the given name

getMethodMap() public method

public getMethodMap ( CodeBase $code_base ) : array
$code_base Phan\CodeBase
return array A list of methods on this class

getNonParentAncestorFQSENList() public method

public getNonParentAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Phan\Language\FQSEN\FullyQualifiedClassName[]

getOverridableAncestorClassList() public method

public getOverridableAncestorClassList ( CodeBase $code_base ) : Clazz[]
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return Clazz[]

getOverridableAncestorFQSENList() public method

public getOverridableAncestorFQSENList ( CodeBase $code_base ) : FullyQualifiedClassName[]
$code_base Phan\CodeBase
return Phan\Language\FQSEN\FullyQualifiedClassName[] The set of FQSENs representing extended classes and traits for which this class could have overriding methods and properties.

getParentClass() public method

public getParentClass ( CodeBase $code_base ) : Clazz
$code_base Phan\CodeBase
return Clazz The parent class of this class if defined

getParentClassFQSEN() public method

public getParentClassFQSEN ( ) : FullyQualifiedClassName
return Phan\Language\FQSEN\FullyQualifiedClassName The parent class of this class if one exists

getParentTypeOption() public method

public getParentTypeOption ( ) : Option
return Option

getPropertyByNameInContext() public method

public getPropertyByNameInContext ( CodeBase $code_base, string $name, Context $context ) : Property
$code_base Phan\CodeBase
$name string The name of the property
$context Phan\Language\Context The context of the caller requesting the property
return Property A property with the given name

getPropertyList() public method

public getPropertyList ( CodeBase $code_base ) : Property[]
$code_base Phan\CodeBase
return Property[] The list of properties defined on this class

getPropertyMap() public method

public getPropertyMap ( CodeBase $code_base ) : array
$code_base Phan\CodeBase
return array The list of properties on this class

getReferenceCount() public method

public getReferenceCount ( CodeBase $code_base ) : integer
$code_base Phan\CodeBase
return integer The number of references to this typed structural element

getTemplateTypeMap() public method

public getTemplateTypeMap ( ) : array
return array The set of all template types parameterizing this generic class

getTraitFQSENList() public method

public getTraitFQSENList ( ) : array
return array A list of FQSEN's for included traits

hasCallMethod() public method

public hasCallMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__call' method

hasCallOrCallStaticMethod() public method

public hasCallOrCallStaticMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__call' or '__callStatic' method

hasCallStaticMethod() public method

public hasCallStaticMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__callStatic' method

hasConstantWithName() public method

public hasConstantWithName ( CodeBase $code_base, string $name ) : boolean
$code_base Phan\CodeBase
$name string
return boolean True if a constant with the given name is defined on this class.

hasGetMethod() public method

public hasGetMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__get' method

hasGetOrSetMethod() public method

public hasGetOrSetMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__get' or '__set' method

hasMethodWithName() public method

public hasMethodWithName ( CodeBase $code_base, string $name ) : boolean
$code_base Phan\CodeBase
$name string
return boolean True if this class has a method with the given name

hasParentType() public method

public hasParentType ( ) : boolean
return boolean True if this class has a parent class

hasPropertyWithName() public method

public hasPropertyWithName ( CodeBase $code_base, string $name ) : boolean
$code_base Phan\CodeBase
$name string
return boolean

hasSetMethod() public method

public hasSetMethod ( CodeBase $code_base ) : boolean
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return boolean True if this class has a magic '__set' method

hydrateOnce() protected method

This method must be called before analysis begins.
protected hydrateOnce ( CodeBase $code_base ) : void
$code_base Phan\CodeBase
return void

importAncestorClass() public method

Add properties, constants and methods from the given class to this.
public importAncestorClass ( CodeBase $code_base, Clazz $class, Option | Phan\Library\None $type_option ) : void
$code_base Phan\CodeBase A reference to the code base in which the ancestor exists
$class Clazz A class to import from
$type_option Option | Phan\Library\None
return void

importAncestorClasses() public method

..) to this class
public importAncestorClasses ( CodeBase $code_base ) : null
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return null

importParentClass() public method

* Add properties, constants and methods from the parent of this class
public importParentClass ( CodeBase $code_base )
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details

isAbstract() public method

public isAbstract ( ) : boolean
return boolean True if this is an abstract class

isFinal() public method

public isFinal ( ) : boolean
return boolean True if this is a final class

isGeneric() public method

public isGeneric ( ) : boolean
return boolean True if this class contains generic types

isInterface() public method

public isInterface ( ) : boolean
return boolean True if this is an interface

isSubclassOf() public method

public isSubclassOf ( CodeBase $code_base, Clazz $other ) : boolean
$code_base Phan\CodeBase
$other Clazz
return boolean

isTrait() public method

public isTrait ( ) : boolean
return boolean True if this class is a trait

setHasDynamicProperties() public method

public setHasDynamicProperties ( boolean $has_dynamic_properties ) : void
$has_dynamic_properties boolean
return void

setIsParentConstructorCalled() public method

public setIsParentConstructorCalled ( boolean $is_parent_constructor_called ) : void
$is_parent_constructor_called boolean
return void

setParentType() public method

public setParentType ( Type $parent_type = null ) : void
$parent_type Phan\Language\Type The type of the parent (extended) class of this class.
return void