Reflection

Table of Contents

The Reflection class

Introduction

The reflection class.

Class synopsis

Reflection
class Reflection {
/* Methods */
public static string export ( Reflector $reflector [, bool $return = false ] )
public static array getModifierNames ( int $modifiers )
}

The ReflectionClass class

Introduction

The ReflectionClass class reports information about a class.

Class synopsis

ReflectionClass
class ReflectionClass implements Reflector {
/* Constants */
const integer ReflectionClass::IS_IMPLICIT_ABSTRACT = 16 ;
const integer ReflectionClass::IS_EXPLICIT_ABSTRACT = 32 ;
const integer ReflectionClass::IS_FINAL = 64 ;
/* Properties */
public $name ;
/* Methods */
public __construct ( mixed $argument )
public static string export ( mixed $argument [, bool $return = false ] )
public mixed getConstant ( string $name )
public array getConstants ( void )
public ReflectionMethod getConstructor ( void )
public array getDefaultProperties ( void )
public string getDocComment ( void )
public int getEndLine ( void )
public ReflectionExtension getExtension ( void )
public string getExtensionName ( void )
public string getFileName ( void )
public array getInterfaceNames ( void )
public array getInterfaces ( void )
public ReflectionMethod getMethod ( string $name )
public array getMethods ([ int $filter ] )
public int getModifiers ( void )
public string getName ( void )
public string getNamespaceName ( void )
public ReflectionClass getParentClass ( void )
public array getProperties ([ int $filter ] )
public ReflectionProperty getProperty ( string $name )
public string getShortName ( void )
public int getStartLine ( void )
public array getStaticProperties ( void )
public mixed getStaticPropertyValue ( string $name [, mixed &$def_value ] )
public array getTraitAliases ( void )
public array getTraitNames ( void )
public array getTraits ( void )
public bool hasConstant ( string $name )
public bool hasMethod ( string $name )
public bool hasProperty ( string $name )
public bool implementsInterface ( string $interface )
public bool inNamespace ( void )
public bool isAbstract ( void )
public bool isAnonymous ( void )
public bool isCloneable ( void )
public bool isFinal ( void )
public bool isInstance ( object $object )
public bool isInstantiable ( void )
public bool isInterface ( void )
public bool isInternal ( void )
public bool isIterateable ( void )
public bool isSubclassOf ( string $class )
public bool isTrait ( void )
public bool isUserDefined ( void )
public object newInstance ( mixed $args [, mixed $... ] )
public object newInstanceArgs ([ array $args ] )
public object newInstanceWithoutConstructor ( void )
public void setStaticPropertyValue ( string $name , string $value )
public string __toString ( void )
}

Properties

name

Name of the class. Read-only, throws ReflectionException in attempt to write.

Predefined Constants

ReflectionClass Modifiers

ReflectionClass::IS_IMPLICIT_ABSTRACT

Indicates class that is abstract because it has some abstract methods.

ReflectionClass::IS_EXPLICIT_ABSTRACT

Indicates class that is abstract because of its definition.

ReflectionClass::IS_FINAL

Indicates final class.

The ReflectionZendExtension class

Introduction

Class synopsis

ReflectionZendExtension
class ReflectionZendExtension implements Reflector {
/* Properties */
public $name ;
/* Methods */
final private void __clone ( void )
public __construct ( string $name )
public static string export ( string $name [, string $return ] )
public string getAuthor ( void )
public string getCopyright ( void )
public string getName ( void )
public string getURL ( void )
public string getVersion ( void )
public string __toString ( void )
}

Properties

name

Name of the extension. Read-only, throws ReflectionException in attempt to write.

The ReflectionExtension class

Introduction

The ReflectionExtension class reports information about an extension.

Class synopsis

ReflectionExtension
class ReflectionExtension implements Reflector {
/* Properties */
public $name ;
/* Methods */
final private void __clone ( void )
public __construct ( string $name )
public static string export ( string $name [, string $return = false ] )
public array getClasses ( void )
public array getClassNames ( void )
public array getConstants ( void )
public array getDependencies ( void )
public array getFunctions ( void )
public array getINIEntries ( void )
public string getName ( void )
public string getVersion ( void )
public void info ( void )
public void isPersistent ( void )
public void isTemporary ( void )
public string __toString ( void )
}

Properties

name

Name of the extension, same as calling the ReflectionExtension::getName method.

The ReflectionFunction class

Introduction

The ReflectionFunction class reports information about a function.

Class synopsis

ReflectionFunction
class ReflectionFunction extends ReflectionFunctionAbstract implements Reflector {
/* Constants */
const integer ReflectionFunction::IS_DEPRECATED = 262144 ;
/* Properties */
public $name ;
/* Methods */
public __construct ( mixed $name )
public static string export ( string $name [, string $return ] )
public Closure getClosure ( void )
public mixed invoke ([ mixed $parameter [, mixed $... ]] )
public mixed invokeArgs ( array $args )
public bool isDisabled ( void )
public string __toString ( void )
/* Inherited methods */
final private void ReflectionFunctionAbstract::__clone ( void )
public ReflectionClass ReflectionFunctionAbstract::getClosureScopeClass ( void )
public object ReflectionFunctionAbstract::getClosureThis ( void )
public string ReflectionFunctionAbstract::getDocComment ( void )
public int ReflectionFunctionAbstract::getEndLine ( void )
public ReflectionExtension ReflectionFunctionAbstract::getExtension ( void )
public string ReflectionFunctionAbstract::getExtensionName ( void )
public string ReflectionFunctionAbstract::getFileName ( void )
public string ReflectionFunctionAbstract::getName ( void )
public string ReflectionFunctionAbstract::getNamespaceName ( void )
public int ReflectionFunctionAbstract::getNumberOfParameters ( void )
public int ReflectionFunctionAbstract::getNumberOfRequiredParameters ( void )
public array ReflectionFunctionAbstract::getParameters ( void )
public ReflectionType ReflectionFunctionAbstract::getReturnType ( void )
public string ReflectionFunctionAbstract::getShortName ( void )
public int ReflectionFunctionAbstract::getStartLine ( void )
public array ReflectionFunctionAbstract::getStaticVariables ( void )
public bool ReflectionFunctionAbstract::hasReturnType ( void )
public bool ReflectionFunctionAbstract::inNamespace ( void )
public bool ReflectionFunctionAbstract::isClosure ( void )
public bool ReflectionFunctionAbstract::isDeprecated ( void )
public bool ReflectionFunctionAbstract::isGenerator ( void )
public bool ReflectionFunctionAbstract::isInternal ( void )
public bool ReflectionFunctionAbstract::isUserDefined ( void )
public bool ReflectionFunctionAbstract::isVariadic ( void )
public bool ReflectionFunctionAbstract::returnsReference ( void )
abstract public void ReflectionFunctionAbstract::__toString ( void )
}

Properties

name

Name of the function. Read-only, throws ReflectionException in attempt to write.

Predefined Constants

ReflectionFunction Modifiers

ReflectionFunction::IS_DEPRECATED

Indicates deprecated functions.

The ReflectionFunctionAbstract class

Introduction

A parent class to ReflectionFunction, read its description for details.

Class synopsis

ReflectionFunctionAbstract
class ReflectionFunctionAbstract implements Reflector {
/* Properties */
public $name ;
/* Methods */
final private void __clone ( void )
public ReflectionClass getClosureScopeClass ( void )
public object getClosureThis ( void )
public string getDocComment ( void )
public int getEndLine ( void )
public ReflectionExtension getExtension ( void )
public string getExtensionName ( void )
public string getFileName ( void )
public string getName ( void )
public string getNamespaceName ( void )
public int getNumberOfParameters ( void )
public int getNumberOfRequiredParameters ( void )
public array getParameters ( void )
public ReflectionType getReturnType ( void )
public string getShortName ( void )
public int getStartLine ( void )
public array getStaticVariables ( void )
public bool hasReturnType ( void )
public bool inNamespace ( void )
public bool isClosure ( void )
public bool isDeprecated ( void )
public bool isGenerator ( void )
public bool isInternal ( void )
public bool isUserDefined ( void )
public bool isVariadic ( void )
public bool returnsReference ( void )
abstract public void __toString ( void )
}

Properties

name

Name of the function. Read-only, throws ReflectionException in attempt to write.

The ReflectionMethod class

Introduction

The ReflectionMethod class reports information about a method.

Class synopsis

ReflectionMethod
class ReflectionMethod extends ReflectionFunctionAbstract implements Reflector {
/* Constants */
const integer ReflectionMethod::IS_STATIC = 1 ;
const integer ReflectionMethod::IS_PUBLIC = 256 ;
const integer ReflectionMethod::IS_PROTECTED = 512 ;
const integer ReflectionMethod::IS_PRIVATE = 1024 ;
const integer ReflectionMethod::IS_ABSTRACT = 2 ;
const integer ReflectionMethod::IS_FINAL = 4 ;
/* Properties */
public $name ;
public $class ;
/* Methods */
public __construct ( mixed $class , string $name )
public static string export ( string $class , string $name [, bool $return = false ] )
public Closure getClosure ( object $object )
public ReflectionClass getDeclaringClass ( void )
public int getModifiers ( void )
public ReflectionMethod getPrototype ( void )
public mixed invoke ( object $object [, mixed $parameter [, mixed $... ]] )
public mixed invokeArgs ( object $object , array $args )
public bool isAbstract ( void )
public bool isConstructor ( void )
public bool isDestructor ( void )
public bool isFinal ( void )
public bool isPrivate ( void )
public bool isProtected ( void )
public bool isPublic ( void )
public bool isStatic ( void )
public void setAccessible ( bool $accessible )
public string __toString ( void )
/* Inherited methods */
final private void ReflectionFunctionAbstract::__clone ( void )
public ReflectionClass ReflectionFunctionAbstract::getClosureScopeClass ( void )
public object ReflectionFunctionAbstract::getClosureThis ( void )
public string ReflectionFunctionAbstract::getDocComment ( void )
public int ReflectionFunctionAbstract::getEndLine ( void )
public ReflectionExtension ReflectionFunctionAbstract::getExtension ( void )
public string ReflectionFunctionAbstract::getExtensionName ( void )
public string ReflectionFunctionAbstract::getFileName ( void )
public string ReflectionFunctionAbstract::getName ( void )
public string ReflectionFunctionAbstract::getNamespaceName ( void )
public int ReflectionFunctionAbstract::getNumberOfParameters ( void )
public int ReflectionFunctionAbstract::getNumberOfRequiredParameters ( void )
public array ReflectionFunctionAbstract::getParameters ( void )
public ReflectionType ReflectionFunctionAbstract::getReturnType ( void )
public string ReflectionFunctionAbstract::getShortName ( void )
public int ReflectionFunctionAbstract::getStartLine ( void )
public array ReflectionFunctionAbstract::getStaticVariables ( void )
public bool ReflectionFunctionAbstract::hasReturnType ( void )
public bool ReflectionFunctionAbstract::inNamespace ( void )
public bool ReflectionFunctionAbstract::isClosure ( void )
public bool ReflectionFunctionAbstract::isDeprecated ( void )
public bool ReflectionFunctionAbstract::isGenerator ( void )
public bool ReflectionFunctionAbstract::isInternal ( void )
public bool ReflectionFunctionAbstract::isUserDefined ( void )
public bool ReflectionFunctionAbstract::isVariadic ( void )
public bool ReflectionFunctionAbstract::returnsReference ( void )
abstract public void ReflectionFunctionAbstract::__toString ( void )
}

Properties

name

Method name

class

Class name

Predefined Constants

ReflectionMethod Modifiers

ReflectionMethod::IS_STATIC

Indicates that the method is static.

ReflectionMethod::IS_PUBLIC

Indicates that the method is public.

ReflectionMethod::IS_PROTECTED

Indicates that the method is protected.

ReflectionMethod::IS_PRIVATE

Indicates that the method is private.

ReflectionMethod::IS_ABSTRACT

Indicates that the method is abstract.

ReflectionMethod::IS_FINAL

Indicates that the method is final.

The ReflectionObject class

Introduction

The ReflectionObject class reports information about an object.

Class synopsis

ReflectionObject
class ReflectionObject extends ReflectionClass implements Reflector {
/* Constants */
const integer ReflectionObject::IS_IMPLICIT_ABSTRACT = 16 ;
const integer ReflectionObject::IS_EXPLICIT_ABSTRACT = 32 ;
const integer ReflectionObject::IS_FINAL = 64 ;
/* Properties */
public $name ;
/* Methods */
public __construct ( object $argument )
public static string export ( string $argument [, bool $return ] )
/* Inherited methods */
public ReflectionClass::__construct ( mixed $argument )
public static string ReflectionClass::export ( mixed $argument [, bool $return = false ] )
public mixed ReflectionClass::getConstant ( string $name )
public array ReflectionClass::getConstants ( void )
public ReflectionMethod ReflectionClass::getConstructor ( void )
public array ReflectionClass::getDefaultProperties ( void )
public string ReflectionClass::getDocComment ( void )
public int ReflectionClass::getEndLine ( void )
public ReflectionExtension ReflectionClass::getExtension ( void )
public string ReflectionClass::getExtensionName ( void )
public string ReflectionClass::getFileName ( void )
public array ReflectionClass::getInterfaceNames ( void )
public array ReflectionClass::getInterfaces ( void )
public ReflectionMethod ReflectionClass::getMethod ( string $name )
public array ReflectionClass::getMethods ([ int $filter ] )
public int ReflectionClass::getModifiers ( void )
public string ReflectionClass::getName ( void )
public string ReflectionClass::getNamespaceName ( void )
public ReflectionClass ReflectionClass::getParentClass ( void )
public array ReflectionClass::getProperties ([ int $filter ] )
public ReflectionProperty ReflectionClass::getProperty ( string $name )
public string ReflectionClass::getShortName ( void )
public int ReflectionClass::getStartLine ( void )
public array ReflectionClass::getStaticProperties ( void )
public mixed ReflectionClass::getStaticPropertyValue ( string $name [, mixed &$def_value ] )
public array ReflectionClass::getTraitAliases ( void )
public array ReflectionClass::getTraitNames ( void )
public array ReflectionClass::getTraits ( void )
public bool ReflectionClass::hasConstant ( string $name )
public bool ReflectionClass::hasMethod ( string $name )
public bool ReflectionClass::hasProperty ( string $name )
public bool ReflectionClass::implementsInterface ( string $interface )
public bool ReflectionClass::inNamespace ( void )
public bool ReflectionClass::isAbstract ( void )
public bool ReflectionClass::isAnonymous ( void )
public bool ReflectionClass::isCloneable ( void )
public bool ReflectionClass::isFinal ( void )
public bool ReflectionClass::isInstance ( object $object )
public bool ReflectionClass::isInstantiable ( void )
public bool ReflectionClass::isInterface ( void )
public bool ReflectionClass::isInternal ( void )
public bool ReflectionClass::isIterateable ( void )
public bool ReflectionClass::isSubclassOf ( string $class )
public bool ReflectionClass::isTrait ( void )
public bool ReflectionClass::isUserDefined ( void )
public object ReflectionClass::newInstance ( mixed $args [, mixed $... ] )
public object ReflectionClass::newInstanceArgs ([ array $args ] )
public object ReflectionClass::newInstanceWithoutConstructor ( void )
public void ReflectionClass::setStaticPropertyValue ( string $name , string $value )
public string ReflectionClass::__toString ( void )
}

Properties

name

Name of the object's class. Read-only, throws ReflectionException in attempt to write.

The ReflectionParameter class

Introduction

The ReflectionParameter class retrieves information about function's or method's parameters.

To introspect function parameters, first create an instance of the ReflectionFunction or ReflectionMethod classes and then use their ReflectionFunctionAbstract::getParameters method to retrieve an array of parameters.

Class synopsis

ReflectionParameter
class ReflectionParameter implements Reflector {
/* Properties */
public $name ;
/* Methods */
public bool allowsNull ( void )
public bool canBePassedByValue ( void )
final private void __clone ( void )
public __construct ( string $function , string $parameter )
public static string export ( string $function , string $parameter [, bool $return ] )
public ReflectionClass getClass ( void )
public ReflectionClass getDeclaringClass ( void )
public ReflectionFunctionAbstract getDeclaringFunction ( void )
public mixed getDefaultValue ( void )
public string getDefaultValueConstantName ( void )
public string getName ( void )
public int getPosition ( void )
public ReflectionType getType ( void )
public bool hasType ( void )
public bool isArray ( void )
public bool isCallable ( void )
public bool isDefaultValueAvailable ( void )
public bool isDefaultValueConstant ( void )
public bool isOptional ( void )
public bool isPassedByReference ( void )
public bool isVariadic ( void )
public string __toString ( void )
}

Properties

name

Name of the parameter. Read-only, throws ReflectionException in attempt to write.

The ReflectionProperty class

Introduction

The ReflectionProperty class reports information about classes properties.

Class synopsis

ReflectionProperty
class ReflectionProperty implements Reflector {
/* Constants */
const integer ReflectionProperty::IS_STATIC = 1 ;
const integer ReflectionProperty::IS_PUBLIC = 256 ;
const integer ReflectionProperty::IS_PROTECTED = 512 ;
const integer ReflectionProperty::IS_PRIVATE = 1024 ;
/* Properties */
public $name ;
public $class ;
/* Methods */
final private void __clone ( void )
public __construct ( mixed $class , string $name )
public static string export ( mixed $class , string $name [, bool $return ] )
public ReflectionClass getDeclaringClass ( void )
public string getDocComment ( void )
public int getModifiers ( void )
public string getName ( void )
public mixed getValue ([ object $object ] )
public bool isDefault ( void )
public bool isPrivate ( void )
public bool isProtected ( void )
public bool isPublic ( void )
public bool isStatic ( void )
public void setAccessible ( bool $accessible )
public void setValue ( object $object , mixed $value )
public string __toString ( void )
}

Properties

name

Name of the property. Read-only, throws ReflectionException in attempt to write.

class

Name of the class where the property is defined. Read-only, throws ReflectionException in attempt to write.

Predefined Constants

ReflectionProperty Modifiers

ReflectionProperty::IS_STATIC

Indicates static properties.

ReflectionProperty::IS_PUBLIC

Indicates public properties.

ReflectionProperty::IS_PROTECTED

Indicates protected properties.

ReflectionProperty::IS_PRIVATE

Indicates private properties.

The ReflectionType class

Introduction

The ReflectionType class reports information about a function's return type.

Class synopsis

ReflectionType
class ReflectionType {
/* Methods */
public bool allowsNull ( void )
public bool isBuiltin ( void )
public string __toString ( void )
}

The ReflectionGenerator class

Introduction

The ReflectionGenerator class reports information about a generator.

Class synopsis

ReflectionGenerator
class ReflectionGenerator {
/* Methods */
public __construct ( Generator $generator )
public string getExecutingFile ( void )
public Generator getExecutingGenerator ( void )
public int getExecutingLine ( void )
public ReflectionFunctionAbstract getFunction ( void )
public object getThis ( void )
public array getTrace ([ int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT ] )
}

The Reflector interface

Introduction

Reflector is an interface implemented by all exportable Reflection classes.

Class synopsis

Reflector
class Reflector {
/* Methods */
public static string export ( void )
public string __toString ( void )
}

The ReflectionException class

Introduction

The ReflectionException class.

Class synopsis

ReflectionException
class ReflectionException extends Exception {
/* Properties */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Inherited methods */
final public string Exception::getMessage ( void )
final public Throwable Exception::getPrevious ( void )
final public mixed Exception::getCode ( void )
final public string Exception::getFile ( void )
final public int Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private void Exception::__clone ( void )
}