# Reflection

# Introduction

PHP comes with a complete reflection API that adds the ability to introspect classes, interfaces, functions, methods and extensions. Additionally, the reflection API offers ways to retrieve doc comments for functions, classes and methods.

Please note that certain parts of the internal API are missing the necessary code to work with the Reflection extension. E.g., an internal PHP class might be missing reflection data for properties. These few cases are considered bugs, however, so they should be discovered and fixed.

- Examples
- Extending
- Reflection — The Reflection class
  - Reflection::export — Exports
  - Reflection::getModifierNames — Gets modifier names
- ReflectionClass — The ReflectionClass class
  - ReflectionClass::__construct — Constructs a ReflectionClass
  - ReflectionClass::export — Exports a class
  - ReflectionClass::getAttributes — Gets Attributes
  - ReflectionClass::getConstant — Gets defined constant
  - ReflectionClass::getConstants — Gets constants
  - ReflectionClass::getConstructor — Gets the constructor of the class
  - ReflectionClass::getDefaultProperties — Gets default properties
  - ReflectionClass::getDocComment — Gets doc comments
  - ReflectionClass::getEndLine — Gets end line
  - ReflectionClass::getExtension — Gets a ReflectionExtension object for the extension which defined the class
  - ReflectionClass::getExtensionName — Gets the name of the extension which defined the class
  - ReflectionClass::getFileName — Gets the filename of the file in which the class has been defined
  - ReflectionClass::getInterfaceNames — Gets the interface names
  - ReflectionClass::getInterfaces — Gets the interfaces
  - ReflectionClass::getLazyInitializer — Gets lazy initializer
  - ReflectionClass::getMethod — Gets a ReflectionMethod for a class method
  - ReflectionClass::getMethods — Gets an array of methods
  - ReflectionClass::getModifiers — Gets the class modifiers
  - ReflectionClass::getName — Gets class name
  - ReflectionClass::getNamespaceName — Gets namespace name
  - ReflectionClass::getParentClass — Gets parent class
  - ReflectionClass::getProperties — Gets properties
  - ReflectionClass::getProperty — Gets a ReflectionProperty for a class's property
  - ReflectionClass::getReflectionConstant — Gets a ReflectionClassConstant for a class's constant
  - ReflectionClass::getReflectionConstants — Gets class constants
  - ReflectionClass::getShortName — Gets short name
  - ReflectionClass::getStartLine — Gets starting line number
  - ReflectionClass::getStaticProperties — Gets static properties
  - ReflectionClass::getStaticPropertyValue — Gets static property value
  - ReflectionClass::getTraitAliases — Returns an array of trait aliases
  - ReflectionClass::getTraitNames — Returns an array of names of traits used by this class
  - ReflectionClass::getTraits — Returns an array of traits used by this class
  - ReflectionClass::hasConstant — Checks if constant is defined
  - ReflectionClass::hasMethod — Checks if method is defined
  - ReflectionClass::hasProperty — Checks if property is defined
  - ReflectionClass::implementsInterface — Implements interface
  - ReflectionClass::initializeLazyObject — Forces initialization of a lazy object
  - ReflectionClass::inNamespace — Checks if in namespace
  - ReflectionClass::isAbstract — Checks if class is abstract
  - ReflectionClass::isAnonymous — Checks if class is anonymous
  - ReflectionClass::isCloneable — Returns whether this class is cloneable
  - ReflectionClass::isEnum — Returns whether this is an enum
  - ReflectionClass::isFinal — Checks if class is final
  - ReflectionClass::isInstance — Checks class for instance
  - ReflectionClass::isInstantiable — Checks if the class is instantiable
  - ReflectionClass::isInterface — Checks if the class is an interface
  - ReflectionClass::isInternal — Checks if class is defined internally by an extension, or the core
  - ReflectionClass::isIterable — Check whether this class is iterable
  - ReflectionClass::isIterateable — Alias of ReflectionClass::isIterable
  - ReflectionClass::isReadOnly — Checks if class is readonly
  - ReflectionClass::isSubclassOf — Checks if a subclass
  - ReflectionClass::isTrait — Returns whether this is a trait
  - ReflectionClass::isUninitializedLazyObject — Checks if an object is lazy and uninitialized
  - ReflectionClass::isUserDefined — Checks if user defined
  - ReflectionClass::markLazyObjectAsInitialized — Marks a lazy object as initialized without calling the initializer or factory
  - ReflectionClass::newInstance — Creates a new class instance from given arguments
  - ReflectionClass::newInstanceArgs — Creates a new class instance from given arguments
  - ReflectionClass::newInstanceWithoutConstructor — Creates a new class instance without invoking the constructor
  - ReflectionClass::newLazyGhost — Creates a new lazy ghost instance
  - ReflectionClass::newLazyProxy — Creates a new lazy proxy instance
  - ReflectionClass::resetAsLazyGhost — Resets an object and marks it as lazy
  - ReflectionClass::resetAsLazyProxy — Resets an object and marks it as lazy
  - ReflectionClass::setStaticPropertyValue — Sets public static property value
  - ReflectionClass::__toString — Returns the string representation of the ReflectionClass object
- ReflectionClassConstant — The ReflectionClassConstant class
  - ReflectionClassConstant::__construct — Constructs a ReflectionClassConstant
  - ReflectionClassConstant::export — Export
  - ReflectionClassConstant::getAttributes — Gets Attributes
  - ReflectionClassConstant::getDeclaringClass — Gets declaring class
  - ReflectionClassConstant::getDocComment — Gets doc comments
  - ReflectionClassConstant::getModifiers — Gets the class constant modifiers
  - ReflectionClassConstant::getName — Get name of the constant
  - ReflectionClassConstant::getType — Gets a class constant's type
  - ReflectionClassConstant::getValue — Gets value
  - ReflectionClassConstant::hasType — Checks if class constant has a type
  - ReflectionClassConstant::isDeprecated — Checks if deprecated
  - ReflectionClassConstant::isEnumCase — Checks if class constant is an Enum case
  - ReflectionClassConstant::isFinal — Checks if class constant is final
  - ReflectionClassConstant::isPrivate — Checks if class constant is private
  - ReflectionClassConstant::isProtected — Checks if class constant is protected
  - ReflectionClassConstant::isPublic — Checks if class constant is public
  - ReflectionClassConstant::__toString — Returns the string representation of the ReflectionClassConstant object
- ReflectionConstant — The ReflectionConstant class
  - ReflectionConstant::__construct — Constructs a ReflectionConstant
  - ReflectionConstant::getExtension — Gets ReflectionExtension of the defining extension
  - ReflectionConstant::getExtensionName — Gets name of the defining extension
  - ReflectionConstant::getFileName — Gets name of the defining file
  - ReflectionConstant::getName — Gets name
  - ReflectionConstant::getNamespaceName — Gets namespace name
  - ReflectionConstant::getShortName — Gets short name
  - ReflectionConstant::getValue — Gets value
  - ReflectionConstant::isDeprecated — Checks if deprecated
  - ReflectionConstant::__toString — Returns string representation
- ReflectionEnum — The ReflectionEnum class
  - ReflectionEnum::__construct — Instantiates a ReflectionEnum object
  - ReflectionEnum::getBackingType — Gets the backing type of an Enum, if any
  - ReflectionEnum::getCase — Returns a specific case of an Enum
  - ReflectionEnum::getCases — Returns a list of all cases on an Enum
  - ReflectionEnum::hasCase — Checks for a case on an Enum
  - ReflectionEnum::isBacked — Determines if an Enum is a Backed Enum
- ReflectionEnumUnitCase — The ReflectionEnumUnitCase class
  - ReflectionEnumUnitCase::__construct — Instantiates a ReflectionEnumUnitCase object
  - ReflectionEnumUnitCase::getEnum — Gets the reflection of the enum of this case
  - ReflectionEnumUnitCase::getValue — Gets the enum case object described by this reflection object
- ReflectionEnumBackedCase — The ReflectionEnumBackedCase class
  - ReflectionEnumBackedCase::__construct — Instantiates a ReflectionEnumBackedCase object
  - ReflectionEnumBackedCase::getBackingValue — Gets the scalar value backing this Enum case
- ReflectionZendExtension — The ReflectionZendExtension class
  - ReflectionZendExtension::__clone — Clone handler
  - ReflectionZendExtension::__construct — Constructs a ReflectionZendExtension object
  - ReflectionZendExtension::export — Export
  - ReflectionZendExtension::getAuthor — Gets author
  - ReflectionZendExtension::getCopyright — Gets copyright
  - ReflectionZendExtension::getName — Gets name
  - ReflectionZendExtension::getURL — Gets URL
  - ReflectionZendExtension::getVersion — Gets version
  - ReflectionZendExtension::__toString — To string handler
- ReflectionExtension — The ReflectionExtension class
  - ReflectionExtension::__clone — Clones
  - ReflectionExtension::__construct — Constructs a ReflectionExtension
  - ReflectionExtension::export — Export
  - ReflectionExtension::getClasses — Gets classes
  - ReflectionExtension::getClassNames — Gets class names
  - ReflectionExtension::getConstants — Gets constants
  - ReflectionExtension::getDependencies — Gets dependencies
  - ReflectionExtension::getFunctions — Gets extension functions
  - ReflectionExtension::getINIEntries — Gets extension ini entries
  - ReflectionExtension::getName — Gets extension name
  - ReflectionExtension::getVersion — Gets extension version
  - ReflectionExtension::info — Print extension info
  - ReflectionExtension::isPersistent — Returns whether this extension is persistent
  - ReflectionExtension::isTemporary — Returns whether this extension is temporary
  - ReflectionExtension::__toString — To string
- ReflectionFunction — The ReflectionFunction class
  - ReflectionFunction::__construct — Constructs a ReflectionFunction object
  - ReflectionFunction::export — Exports function
  - ReflectionFunction::getClosure — Returns a dynamically created closure for the function
  - ReflectionFunction::invoke — Invokes function
  - ReflectionFunction::invokeArgs — Invokes function args
  - ReflectionFunction::isAnonymous — Checks if a function is anonymous
  - ReflectionFunction::isDisabled — Checks if function is disabled
  - ReflectionFunction::__toString — Returns the string representation of the ReflectionFunction object
- ReflectionFunctionAbstract — The ReflectionFunctionAbstract class
  - ReflectionFunctionAbstract::__clone — Clones function
  - ReflectionFunctionAbstract::getAttributes — Gets Attributes
  - ReflectionFunctionAbstract::getClosureCalledClass — Returns the class corresponding to static:: inside a closure
  - ReflectionFunctionAbstract::getClosureScopeClass — Returns the class corresponding to the scope inside a closure
  - ReflectionFunctionAbstract::getClosureThis — Returns the object which corresponds to $this inside a closure
  - ReflectionFunctionAbstract::getClosureUsedVariables — Returns an array of the used variables in the Closure
  - ReflectionFunctionAbstract::getDocComment — Gets doc comment
  - ReflectionFunctionAbstract::getEndLine — Gets end line number
  - ReflectionFunctionAbstract::getExtension — Gets extension info
  - ReflectionFunctionAbstract::getExtensionName — Gets extension name
  - ReflectionFunctionAbstract::getFileName — Gets file name
  - ReflectionFunctionAbstract::getName — Gets function name
  - ReflectionFunctionAbstract::getNamespaceName — Gets namespace name
  - ReflectionFunctionAbstract::getNumberOfParameters — Gets number of parameters
  - ReflectionFunctionAbstract::getNumberOfRequiredParameters — Gets number of required parameters
  - ReflectionFunctionAbstract::getParameters — Gets parameters
  - ReflectionFunctionAbstract::getReturnType — Gets the specified return type of a function
  - ReflectionFunctionAbstract::getShortName — Gets function short name
  - ReflectionFunctionAbstract::getStartLine — Gets starting line number
  - ReflectionFunctionAbstract::getStaticVariables — Gets static variables
  - ReflectionFunctionAbstract::getTentativeReturnType — Returns the tentative return type associated with the function
  - ReflectionFunctionAbstract::hasReturnType — Checks if the function has a specified return type
  - ReflectionFunctionAbstract::hasTentativeReturnType — Returns whether the function has a tentative return type
  - ReflectionFunctionAbstract::inNamespace — Checks if function in namespace
  - ReflectionFunctionAbstract::isClosure — Checks if closure
  - ReflectionFunctionAbstract::isDeprecated — Checks if deprecated
  - ReflectionFunctionAbstract::isGenerator — Returns whether this function is a generator
  - ReflectionFunctionAbstract::isInternal — Checks if is internal
  - ReflectionFunctionAbstract::isStatic — Checks if the function is static
  - ReflectionFunctionAbstract::isUserDefined — Checks if user defined
  - ReflectionFunctionAbstract::isVariadic — Checks if the function is variadic
  - ReflectionFunctionAbstract::returnsReference — Checks if returns reference
  - ReflectionFunctionAbstract::__toString — Returns the string representation of the ReflectionFunctionAbstract object
- ReflectionMethod — The ReflectionMethod class
  - ReflectionMethod::__construct — Constructs a ReflectionMethod
  - ReflectionMethod::createFromMethodName — Creates a new ReflectionMethod
  - ReflectionMethod::export — Export a reflection method
  - ReflectionMethod::getClosure — Returns a dynamically created closure for the method
  - ReflectionMethod::getDeclaringClass — Gets declaring class for the reflected method
  - ReflectionMethod::getModifiers — Gets the method modifiers
  - ReflectionMethod::getPrototype — Gets the method prototype (if there is one)
  - ReflectionMethod::hasPrototype — Returns whether a method has a prototype
  - ReflectionMethod::invoke — Invoke
  - ReflectionMethod::invokeArgs — Invoke args
  - ReflectionMethod::isAbstract — Checks if method is abstract
  - ReflectionMethod::isConstructor — Checks if method is a constructor
  - ReflectionMethod::isDestructor — Checks if method is a destructor
  - ReflectionMethod::isFinal — Checks if method is final
  - ReflectionMethod::isPrivate — Checks if method is private
  - ReflectionMethod::isProtected — Checks if method is protected
  - ReflectionMethod::isPublic — Checks if method is public
  - ReflectionMethod::setAccessible — Set method accessibility
  - ReflectionMethod::__toString — Returns the string representation of the Reflection method object
- ReflectionNamedType — The ReflectionNamedType class
  - ReflectionNamedType::getName — Get the name of the type as a string
  - ReflectionNamedType::isBuiltin — Checks if it is a built-in type
- ReflectionObject — The ReflectionObject class
  - ReflectionObject::__construct — Constructs a ReflectionObject
  - ReflectionObject::export — Export
- ReflectionParameter — The ReflectionParameter class
  - ReflectionParameter::allowsNull — Checks if null is allowed
  - ReflectionParameter::canBePassedByValue — Returns whether this parameter can be passed by value
  - ReflectionParameter::__clone — Clone
  - ReflectionParameter::__construct — Construct
  - ReflectionParameter::export — Exports
  - ReflectionParameter::getAttributes — Gets Attributes
  - ReflectionParameter::getClass — Get a ReflectionClass object for the parameter being reflected or null
  - ReflectionParameter::getDeclaringClass — Gets declaring class
  - ReflectionParameter::getDeclaringFunction — Gets declaring function
  - ReflectionParameter::getDefaultValue — Gets default parameter value
  - ReflectionParameter::getDefaultValueConstantName — Returns the default value's constant name if default value is constant or null
  - ReflectionParameter::getName — Gets parameter name
  - ReflectionParameter::getPosition — Gets parameter position
  - ReflectionParameter::getType — Gets a parameter's type
  - ReflectionParameter::hasType — Checks if parameter has a type
  - ReflectionParameter::isArray — Checks if parameter expects an array
  - ReflectionParameter::isCallable — Returns whether parameter MUST be callable
  - ReflectionParameter::isDefaultValueAvailable — Checks if a default value is available
  - ReflectionParameter::isDefaultValueConstant — Returns whether the default value of this parameter is a constant
  - ReflectionParameter::isOptional — Checks if optional
  - ReflectionParameter::isPassedByReference — Checks if passed by reference
  - ReflectionParameter::isPromoted — Checks if a parameter is promoted to a property
  - ReflectionParameter::isVariadic — Checks if the parameter is variadic
  - ReflectionParameter::__toString — To string
- ReflectionProperty — The ReflectionProperty class
  - ReflectionProperty::__clone — Clone
  - ReflectionProperty::__construct — Construct a ReflectionProperty object
  - ReflectionProperty::export — Export
  - ReflectionProperty::getAttributes — Gets Attributes
  - ReflectionProperty::getDeclaringClass — Gets declaring class
  - ReflectionProperty::getDefaultValue — Returns the default value declared for a property
  - ReflectionProperty::getDocComment — Gets the property doc comment
  - ReflectionProperty::getHook — Returns a reflection object for a specified hook
  - ReflectionProperty::getHooks — Returns an array of all hooks on this property
  - ReflectionProperty::getModifiers — Gets the property modifiers
  - ReflectionProperty::getName — Gets property name
  - ReflectionProperty::getRawValue — Returns the value of a property, bypassing a get hook if defined
  - ReflectionProperty::getSettableType — Returns the parameter type of a setter hook
  - ReflectionProperty::getType — Gets a property's type
  - ReflectionProperty::getValue — Gets value
  - ReflectionProperty::hasDefaultValue — Checks if property has a default value declared
  - ReflectionProperty::hasHook — Returns whether the property has a given hook defined
  - ReflectionProperty::hasHooks — Returns whether the property has any hooks defined
  - ReflectionProperty::hasType — Checks if property has a type
  - ReflectionProperty::isAbstract — Determines if a property is abstract
  - ReflectionProperty::isDefault — Checks if property is a default property
  - ReflectionProperty::isDynamic — Checks if property is a dynamic property
  - ReflectionProperty::isFinal — Determines if this property is final or not
  - ReflectionProperty::isInitialized — Checks whether a property is initialized
  - ReflectionProperty::isLazy — Checks whether a property is lazy
  - ReflectionProperty::isPrivate — Checks if property is private
  - ReflectionProperty::isPrivateSet — Checks if property is private for writing
  - ReflectionProperty::isPromoted — Checks if property is promoted
  - ReflectionProperty::isProtected — Checks if property is protected
  - ReflectionProperty::isProtectedSet — Checks whether the property is protected for writing
  - ReflectionProperty::isPublic — Checks if property is public
  - ReflectionProperty::isReadOnly — Checks if property is readonly
  - ReflectionProperty::isStatic — Checks if property is static
  - ReflectionProperty::isVirtual — Determines if a property is virtual
  - ReflectionProperty::setAccessible — Set property accessibility
  - ReflectionProperty::setRawValue — Sets the value of a property, bypassing a set hook if defined
  - ReflectionProperty::setRawValueWithoutLazyInitialization — Set raw property value without triggering lazy initialization
  - ReflectionProperty::setValue — Set property value
  - ReflectionProperty::skipLazyInitialization — Marks property as non-lazy
  - ReflectionProperty::__toString — To string
- ReflectionType — The ReflectionType class
  - ReflectionType::allowsNull — Checks if null is allowed
  - ReflectionType::__toString — To string
- ReflectionUnionType — The ReflectionUnionType class
  - ReflectionUnionType::getTypes — Returns the types included in the union type
- ReflectionGenerator — The ReflectionGenerator class
  - ReflectionGenerator::__construct — Constructs a ReflectionGenerator object
  - ReflectionGenerator::getExecutingFile — Gets the file name of the currently executing generator
  - ReflectionGenerator::getExecutingGenerator — Gets the executing Generator object
  - ReflectionGenerator::getExecutingLine — Gets the currently executing line of the generator
  - ReflectionGenerator::getFunction — Gets the function name of the generator
  - ReflectionGenerator::getThis — Gets the $this value of the generator
  - ReflectionGenerator::getTrace — Gets the trace of the executing generator
  - ReflectionGenerator::isClosed — Checks if execution finished
- ReflectionFiber — The ReflectionFiber class
  - ReflectionFiber::__construct — Constructs a ReflectionFiber object
  - ReflectionFiber::getCallable — Gets the callable used to create the Fiber
  - ReflectionFiber::getExecutingFile — Get the file name of the current execution point
  - ReflectionFiber::getExecutingLine — Get the line number of the current execution point
  - ReflectionFiber::getFiber — Get the reflected Fiber instance
  - ReflectionFiber::getTrace — Get the backtrace of the current execution point
- ReflectionIntersectionType — The ReflectionIntersectionType class
  - ReflectionIntersectionType::getTypes — Returns the types included in the intersection type
- ReflectionReference — The ReflectionReference class
  - ReflectionReference::__construct — Private constructor to disallow direct instantiation
  - ReflectionReference::fromArrayElement — Create a ReflectionReference from an array element
  - ReflectionReference::getId — Get unique ID of a reference
- ReflectionAttribute — The ReflectionAttribute class
  - ReflectionAttribute::__construct — Private constructor to disallow direct instantiation
  - ReflectionAttribute::getArguments — Gets arguments passed to attribute
  - ReflectionAttribute::getName — Gets attribute name
  - ReflectionAttribute::getTarget — Returns the target of the attribute as bitmask
  - ReflectionAttribute::isRepeated — Returns whether the attribute of this name has been repeated on a code element
  - ReflectionAttribute::newInstance — Instantiates the attribute class represented by this ReflectionAttribute class and arguments
- Reflector — The Reflector interface
  - Reflector::export — Exports
- ReflectionException — The ReflectionException class
- PropertyHookType — The PropertyHookType Enum

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open