PHP Класс BetterReflection\Reflection\ReflectionClass

Наследование: implements BetterReflection\Reflection\Reflection
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__clone ( )
__toString ( ) : string Get a string representation of this reflection
addMethod ( string $methodName ) Add a new method to the class.
addProperty ( string $propertyName, integer $visibility = ReflectionProperty::IS_PUBLIC, boolean $static = false ) Add a new property to the class.
createFromInstance ( object $instance ) : ReflectionClass Create a ReflectionClass from an instance, using default reflectors etc.
createFromName ( string $className ) : ReflectionClass Create a ReflectionClass by name, using default reflectors etc.
createFromNode ( BetterReflection\Reflector\Reflector $reflector, ClassLike $node, BetterReflection\SourceLocator\Located\LocatedSource $locatedSource, Namespace_ $namespace = null ) : ReflectionClass Create from a Class Node.
export ( string $className = null ) : string Create a reflection and return the string representation of a named class
getAst ( ) : ClassLike Retrieve the AST node for this class
getConstant ( string $name ) : mixed | null Get the value of the specified class constant.
getConstants ( ) : mixed[] Get an array of the defined constants in this class.
getConstructor ( ) : BetterReflection\Reflection\ReflectionMethod Get the constructor method for this class.
getDefaultProperties ( )
getDocComment ( ) : string
getEndLine ( ) : integer Get the line number that this class ends on.
getFileName ( ) : string | null
getImmediateInterfaces ( ) : ReflectionClass[] Get only the interfaces that this class implements (i.e. do not search up parent classes etc.)
getImmediateMethods ( ) : BetterReflection\Reflection\ReflectionMethod[] Get only the methods that this class implements (i.e. do not search up parent classes etc.)
getInterfaceNames ( ) : string[] Gets the interface names.
getInterfaces ( ) : ReflectionClass[] Gets the interfaces.
getLocatedSource ( ) : BetterReflection\SourceLocator\Located\LocatedSource
getMethod ( string $methodName ) : BetterReflection\Reflection\ReflectionMethod Get a single method with the name $methodName.
getMethods ( ) : BetterReflection\Reflection\ReflectionMethod[] Fetch an array of all methods for this class.
getModifiers ( ) : integer Get the core-reflection-compatible modifier values.
getName ( ) : string Get the "full" name of the class (e.g. for A\B\Foo, this will return "A\B\Foo").
getNamespaceName ( ) : string Get the "namespace" name of the class (e.g. for A\B\Foo, this will return "A\B").
getParentClass ( ) : ReflectionClass Get the parent class, if it is defined. If this class does not have a specified parent class, this will throw an exception.
getProperties ( ) : ReflectionProperty[] Get the properties for this class.
getProperty ( string $name ) : ReflectionProperty | null Get the property called $name.
getShortName ( ) : string Get the "short" name of the class (e.g. for A\B\Foo, this will return "Foo").
getStartLine ( ) : integer Get the line number that this class starts on.
getStaticPropertyValue ( string $propertyName ) : mixed Get the value of a static property, if it exists. Throws a PropertyDoesNotExist exception if it does not exist or is not static.
getTraitAliases ( ) : string[] Return a list of the aliases used when importing traits for this class.
getTraitNames ( ) : string[] Get the names of the traits used as an array of strings, if any are defined. If this class does not have any defined traits, this will return an empty array.
getTraits ( ) : ReflectionClass[] Get the traits used, if any are defined. If this class does not have any defined traits, this will return an empty array.
hasConstant ( string $name ) : boolean Does this class have the specified constant?
hasMethod ( string $methodName ) : boolean Does the class have the specified method method?
hasProperty ( string $name ) : boolean Does this class have the specified property?
implementsInterface ( string $interfaceName ) : boolean Checks whether this class implements the given interface.
inNamespace ( ) : boolean Decide if this class is part of a namespace. Returns false if the class is in the global namespace or does not have a specified namespace.
isAbstract ( ) : boolean Is this class an abstract class.
isCloneable ( ) : boolean Checks whether this is a reflection of a class that supports the clone operator
isFinal ( ) : boolean Is this class a final class.
isInstance ( object $object ) : boolean Checks whether the given object is an instance.
isInstantiable ( ) : boolean Checks whether this reflection is an instantiable class
isInterface ( ) : boolean Is this reflection an interface?
isInternal ( ) : boolean Is this an internal class?
isIterateable ( ) : boolean Checks if iterateable
isSubclassOf ( string $className ) : boolean Checks whether the given class string is a subclass of this class.
isTrait ( ) : boolean Is this reflection a trait?
isUserDefined ( ) : boolean Is this a user-defined function (will always return the opposite of whatever isInternal returns).
removeMethod ( string $methodName ) : boolean Remove the named method from the class.
removeProperty ( string $propertyName ) : boolean Remove a property from the class.
setFinal ( boolean $isFinal ) Set whether this class is final or not
setStaticPropertyValue ( string $propertyName, mixed $value ) : void Set the value of a static property

Приватные методы

Метод Описание
__construct ( )
getCurrentClassImplementedInterfacesIndexedByName ( ) : ReflectionClass[]
getFqsenFromNamedNode ( Name $node ) : string Given an AST Node\Name, try to resolve the type into a fully qualified structural element name (FQSEN).
getInheritanceClassHierarchy ( ) : ReflectionClass[]
getInterfacesHierarchy ( ) : ReflectionClass[] This method allows us to retrieve all interfaces parent of the this interface. Do not use on class nodes!
getMethodsIndexedByName ( ) : BetterReflection\Reflection\ReflectionMethod[]
reflectClassForNamedNode ( Name $node ) : ReflectionClass Given an AST Node\Name, create a new ReflectionClass for the element.
scanMethods ( ) : BetterReflection\Reflection\ReflectionMethod[] Construct a flat list of methods that are available. This will search up all parent classes/traits/interfaces/current scope for methods.

Описание методов

__clone() публичный метод

public __clone ( )

__toString() публичный метод

Get a string representation of this reflection
См. также: https://github.com/Roave/BetterReflection/issues/94
public __toString ( ) : string
Результат string

addMethod() публичный метод

Add a new method to the class.
public addMethod ( string $methodName )
$methodName string

addProperty() публичный метод

Visibility defaults to \ReflectionProperty::IS_PUBLIC, or can be ::IS_PROTECTED or ::IS_PRIVATE.
public addProperty ( string $propertyName, integer $visibility = ReflectionProperty::IS_PUBLIC, boolean $static = false )
$propertyName string
$visibility integer
$static boolean

createFromInstance() публичный статический метод

This is simply a helper method that calls ReflectionObject::createFromInstance().
См. также: ReflectionObject::createFromInstance
public static createFromInstance ( object $instance ) : ReflectionClass
$instance object
Результат ReflectionClass

createFromName() публичный статический метод

Create a ReflectionClass by name, using default reflectors etc.
public static createFromName ( string $className ) : ReflectionClass
$className string
Результат ReflectionClass

createFromNode() публичный статический метод

Create from a Class Node.
public static createFromNode ( BetterReflection\Reflector\Reflector $reflector, ClassLike $node, BetterReflection\SourceLocator\Located\LocatedSource $locatedSource, Namespace_ $namespace = null ) : ReflectionClass
$reflector BetterReflection\Reflector\Reflector
$node PhpParser\Node\Stmt\ClassLike
$locatedSource BetterReflection\SourceLocator\Located\LocatedSource
$namespace PhpParser\Node\Stmt\Namespace_ optional - if omitted, we assume it is global namespaced class
Результат ReflectionClass

export() публичный статический метод

Create a reflection and return the string representation of a named class
public static export ( string $className = null ) : string
$className string
Результат string

getAst() публичный метод

Retrieve the AST node for this class
public getAst ( ) : ClassLike
Результат PhpParser\Node\Stmt\ClassLike

getConstant() публичный метод

Returns null if not specified.
public getConstant ( string $name ) : mixed | null
$name string
Результат mixed | null

getConstants() публичный метод

Get an array of the defined constants in this class.
public getConstants ( ) : mixed[]
Результат mixed[]

getConstructor() публичный метод

Get the constructor method for this class.
public getConstructor ( ) : BetterReflection\Reflection\ReflectionMethod
Результат BetterReflection\Reflection\ReflectionMethod

getDefaultProperties() публичный метод

getDocComment() публичный метод

public getDocComment ( ) : string
Результат string

getEndLine() публичный метод

Get the line number that this class ends on.
public getEndLine ( ) : integer
Результат integer

getFileName() публичный метод

public getFileName ( ) : string | null
Результат string | null

getImmediateInterfaces() публичный метод

Get only the interfaces that this class implements (i.e. do not search up parent classes etc.)
public getImmediateInterfaces ( ) : ReflectionClass[]
Результат ReflectionClass[]

getImmediateMethods() публичный метод

Get only the methods that this class implements (i.e. do not search up parent classes etc.)
public getImmediateMethods ( ) : BetterReflection\Reflection\ReflectionMethod[]
Результат BetterReflection\Reflection\ReflectionMethod[]

getInterfaceNames() публичный метод

Gets the interface names.
public getInterfaceNames ( ) : string[]
Результат string[] A numerical array with interface names as the values.

getInterfaces() публичный метод

Gets the interfaces.
public getInterfaces ( ) : ReflectionClass[]
Результат ReflectionClass[] An associative array of interfaces, with keys as interface names and the array values as {@see \ReflectionClass} objects.

getLocatedSource() публичный метод

public getLocatedSource ( ) : BetterReflection\SourceLocator\Located\LocatedSource
Результат BetterReflection\SourceLocator\Located\LocatedSource

getMethod() публичный метод

Get a single method with the name $methodName.
public getMethod ( string $methodName ) : BetterReflection\Reflection\ReflectionMethod
$methodName string
Результат BetterReflection\Reflection\ReflectionMethod

getMethods() публичный метод

Fetch an array of all methods for this class.
public getMethods ( ) : BetterReflection\Reflection\ReflectionMethod[]
Результат BetterReflection\Reflection\ReflectionMethod[]

getModifiers() публичный метод

Get the core-reflection-compatible modifier values.
public getModifiers ( ) : integer
Результат integer

getName() публичный метод

Get the "full" name of the class (e.g. for A\B\Foo, this will return "A\B\Foo").
public getName ( ) : string
Результат string

getNamespaceName() публичный метод

Get the "namespace" name of the class (e.g. for A\B\Foo, this will return "A\B").
public getNamespaceName ( ) : string
Результат string

getParentClass() публичный метод

You may optionally specify a source locator that will be used to locate the parent class. If no source locator is given, a default will be used.
public getParentClass ( ) : ReflectionClass
Результат ReflectionClass

getProperties() публичный метод

Get the properties for this class.
public getProperties ( ) : ReflectionProperty[]
Результат ReflectionProperty[]

getProperty() публичный метод

Returns null if property does not exist.
public getProperty ( string $name ) : ReflectionProperty | null
$name string
Результат ReflectionProperty | null

getShortName() публичный метод

Get the "short" name of the class (e.g. for A\B\Foo, this will return "Foo").
public getShortName ( ) : string
Результат string

getStartLine() публичный метод

Get the line number that this class starts on.
public getStartLine ( ) : integer
Результат integer

getStaticPropertyValue() публичный метод

(note, differs very slightly from internal reflection behaviour)
public getStaticPropertyValue ( string $propertyName ) : mixed
$propertyName string
Результат mixed

getTraitAliases() публичный метод

The returned array is in key/value pair in this format:. 'aliasedMethodName' => 'ActualClass::actualMethod'
public getTraitAliases ( ) : string[]
Результат string[]

getTraitNames() публичный метод

You may optionally specify a source locator that will be used to locate the traits. If no source locator is given, a default will be used.
public getTraitNames ( ) : string[]
Результат string[]

getTraits() публичный метод

You may optionally specify a source locator that will be used to locate the traits. If no source locator is given, a default will be used.
public getTraits ( ) : ReflectionClass[]
Результат ReflectionClass[]

hasConstant() публичный метод

Does this class have the specified constant?
public hasConstant ( string $name ) : boolean
$name string
Результат boolean

hasMethod() публичный метод

Does the class have the specified method method?
public hasMethod ( string $methodName ) : boolean
$methodName string
Результат boolean

hasProperty() публичный метод

Does this class have the specified property?
public hasProperty ( string $name ) : boolean
$name string
Результат boolean

implementsInterface() публичный метод

Checks whether this class implements the given interface.
public implementsInterface ( string $interfaceName ) : boolean
$interfaceName string
Результат boolean

inNamespace() публичный метод

Decide if this class is part of a namespace. Returns false if the class is in the global namespace or does not have a specified namespace.
public inNamespace ( ) : boolean
Результат boolean

isAbstract() публичный метод

Is this class an abstract class.
public isAbstract ( ) : boolean
Результат boolean

isCloneable() публичный метод

Checks whether this is a reflection of a class that supports the clone operator
public isCloneable ( ) : boolean
Результат boolean

isFinal() публичный метод

Is this class a final class.
public isFinal ( ) : boolean
Результат boolean

isInstance() публичный метод

Checks whether the given object is an instance.
public isInstance ( object $object ) : boolean
$object object
Результат boolean

isInstantiable() публичный метод

Checks whether this reflection is an instantiable class
public isInstantiable ( ) : boolean
Результат boolean

isInterface() публичный метод

Is this reflection an interface?
public isInterface ( ) : boolean
Результат boolean

isInternal() публичный метод

Is this an internal class?
public isInternal ( ) : boolean
Результат boolean

isIterateable() публичный метод

Checks if iterateable
public isIterateable ( ) : boolean
Результат boolean

isSubclassOf() публичный метод

Checks whether the given class string is a subclass of this class.
public isSubclassOf ( string $className ) : boolean
$className string
Результат boolean

isTrait() публичный метод

Is this reflection a trait?
public isTrait ( ) : boolean
Результат boolean

isUserDefined() публичный метод

Is this a user-defined function (will always return the opposite of whatever isInternal returns).
public isUserDefined ( ) : boolean
Результат boolean

removeMethod() публичный метод

Returns true if method was successfully removed. Returns false if method was not found, or could not be removed.
public removeMethod ( string $methodName ) : boolean
$methodName string
Результат boolean

removeProperty() публичный метод

Remove a property from the class.
public removeProperty ( string $propertyName ) : boolean
$propertyName string
Результат boolean

setFinal() публичный метод

Set whether this class is final or not
public setFinal ( boolean $isFinal )
$isFinal boolean

setStaticPropertyValue() публичный метод

Set the value of a static property
public setStaticPropertyValue ( string $propertyName, mixed $value ) : void
$propertyName string
$value mixed
Результат void