ReflectionEnum
class ReflectionEnum extends ReflectionClass (View source)
The ReflectionEnum class reports information about an Enum.
Constants
| IS_IMPLICIT_ABSTRACT |
Indicates class that is abstract because it has some abstract methods. |
| IS_EXPLICIT_ABSTRACT |
Indicates class that is abstract because of its definition. |
| IS_FINAL |
Indicates final class. |
|
IS_READONLY
Since: 8.2
|
|
|
SKIP_INITIALIZATION_ON_SERIALIZE
Since: 8.4
|
|
|
SKIP_DESTRUCTOR
Since: 8.4
|
|
Properties
| T> | $name | from ReflectionClass |
Methods
Instantiates a ReflectionEnum object
Exports a reflected class
Returns the string representation of the ReflectionClass object.
Checks if class is defined internally by an extension, or the core
Gets the filename of the file in which the class has been defined
Gets a ReflectionMethod for a class method.
Gets an array of methods for the class.
Gets a ReflectionProperty for a class's property
Gets a ReflectionClassConstant for a class's property
Creates a new class instance from given arguments.
Creates a new class instance without invoking the constructor.
Creates a new class instance from given arguments.
Gets static property value
Sets static property value
Checks whether it implements an interface.
Gets a ReflectionExtension object for the extension which defined the class
Gets the name of the extension which defined the class
Creates a new lazy ghost instance
Creates a new lazy proxy instance
Resets an object and marks it as lazy
Resets an object and marks it as lazy
Forces initialization of a lazy object
Checks if an object is lazy and uninitialized
Marks a lazy object as initialized without calling the initializer or factory
Checks for a case on an Enum
Returns a list of all cases on an Enum
Returns a specific case of an Enum
Determines if an Enum is a Backed Enum
Gets the backing type of an Enum, if any
Details
__construct(T>|T $objectOrClass)
Instantiates a ReflectionEnum object
static string|null
export(mixed $argument, bool $return = false)
Exports a reflected class
string
__toString()
Returns the string representation of the ReflectionClass object.
string
getName()
Gets class name
bool
isInternal()
Checks if class is defined internally by an extension, or the core
bool
isUserDefined()
Checks if user defined
bool
isInstantiable()
Checks if the class is instantiable
bool
isCloneable()
Returns whether this class is cloneable
string|false
getFileName()
Gets the filename of the file in which the class has been defined
int|false
getStartLine()
Gets starting line number
int|false
getEndLine()
Gets end line
string|false
getDocComment()
Gets doc comments
ReflectionMethod|null
getConstructor()
Gets the constructor of the class
bool
hasMethod(string $name)
Checks if method is defined
ReflectionMethod
getMethod(string $name)
Gets a ReflectionMethod for a class method.
array
getMethods(int|null $filter = null)
Gets an array of methods for the class.
bool
hasProperty(string $name)
Checks if property is defined
ReflectionProperty
getProperty(string $name)
Gets a ReflectionProperty for a class's property
array
getProperties(int|null $filter = null)
Gets properties
ReflectionClassConstant|false
getReflectionConstant(string $name)
Gets a ReflectionClassConstant for a class's property
array
getReflectionConstants(int|null $filter = null)
Gets class constants
bool
hasConstant(string $name)
Checks if constant is defined
array
getConstants(int|null $filter = null)
Gets constants
mixed
getConstant(string $name)
Gets defined constant
array
getInterfaces()
Gets the interfaces
array
getInterfaceNames()
Gets the interface names
bool
isAnonymous()
Checks if the class is anonymous
bool
isInterface()
Checks if the class is an interface
array
getTraits()
Returns an array of traits used by this class
array
getTraitNames()
Returns an array of names of traits used by this class
array
getTraitAliases()
Returns an array of trait aliases
bool
isTrait()
Returns whether this is a trait
bool
isAbstract()
Checks if class is abstract
bool
isFinal()
Checks if class is final
bool
isReadOnly()
Checks if class is readonly
Checks if a class is readonly.
int
getModifiers()
Gets modifiers
bool
isInstance(object $object)
Checks class for instance
object
newInstance(mixed ...$args)
Creates a new class instance from given arguments.
object
newInstanceWithoutConstructor()
Creates a new class instance without invoking the constructor.
object|null
newInstanceArgs(array $args = [])
Creates a new class instance from given arguments.
ReflectionClass|false
getParentClass()
Gets parent class
bool
isSubclassOf(string|ReflectionClass $class)
Checks if a subclass
array|null
getStaticProperties()
Gets static properties
mixed
getStaticPropertyValue(string $name, mixed $default)
Gets static property value
void
setStaticPropertyValue(string $name, mixed $value)
Sets static property value
array
getDefaultProperties()
Gets default properties
bool
isIterateable()
An alias of {ReflectionClass method.
bool
isIterable()
Check whether this class is iterable
bool
implementsInterface(string $interface)
Checks whether it implements an interface.
ReflectionExtension|null
getExtension()
Gets a ReflectionExtension object for the extension which defined the class
string|false
getExtensionName()
Gets the name of the extension which defined the class
bool
inNamespace()
Checks if in namespace
string
getNamespaceName()
Gets namespace name
string
getShortName()
Gets short name
array
getAttributes(string|null $name = null, int $flags = 0)
Gets Attributes
Returns all attributes declared on this class as an array of ReflectionAttribute.
bool
isEnum()
Returns whether this is an enum
Checks if a class is an enum.
object
newLazyGhost(callable $initializer, int $options = 0)
Creates a new lazy ghost instance
Creates a new lazy ghost instance of the class, attaching the initializer to it. The constructor is not called, and properties are not set to their default value. However, the object will be automatically initialized by invoking the initializer the first time its state is observed or modified. See Initialization Triggers and Initialization Sequence.
object
newLazyProxy(callable $factory, int $options = 0)
Creates a new lazy proxy instance
Creates a new lazy proxy instance of the class, attaching the factory function to it. The constructor is not called, and properties are not set to their default values. When an attempt is made to observe or modify the proxy's state for the first time, the factory function is called to provide a real instance, which is then attached to the proxy. After this, all subsequent interactions with the proxy are forwarded to the real instance. See Initialization Triggers and Initialization Sequence.
void
resetAsLazyGhost(object $object, callable $initializer, int $options = 0)
Resets an object and marks it as lazy
Resets an existing object and marks it as lazy.
void
resetAsLazyProxy(object $object, callable $factory, int $options = 0)
Resets an object and marks it as lazy
The behavior of this method is the same as ReflectionClass::resetAsLazyGhost except that it uses the proxy strategy.
object
initializeLazyObject(object $object)
Forces initialization of a lazy object
Forces initialization of the specified object. This method has no effect if the object is not lazy or has already been initialized. Otherwise, initialization proceeds as described in the Initialization Sequence.
bool
isUninitializedLazyObject(object $object)
Checks if an object is lazy and uninitialized
object
markLazyObjectAsInitialized(object $object)
Marks a lazy object as initialized without calling the initializer or factory
Marks a lazy object as initialized without calling the initializer or factory. This has no effect if object is not lazy or is already initialized.
callable|null
getLazyInitializer(object $object)
Gets lazy initializer
Gets the lazy initializer or factory attached to object.
bool
hasCase(string $name)
Checks for a case on an Enum
Determines if a given case is defined on an Enum.
array
getCases()
Returns a list of all cases on an Enum
An Enum may contain zero or more cases. This method retrieves all defined cases, in lexical order (that is, the order they appear in the source code).
ReflectionEnumUnitCase
getCase(string $name)
Returns a specific case of an Enum
Returns the reflection object for a specific Enum case by name. If the requested case is not defined, a ReflectionException is thrown.
bool
isBacked()
Determines if an Enum is a Backed Enum
A Backed Enum is one that has a native backing scalar equivalent, either a string or an int. Not all Enums are backed.
ReflectionType|null
getBackingType()
Gets the backing type of an Enum, if any
If the enumeration is a Backed Enum, this method will return an instance of ReflectionType for the backing type of the Enum. If it is not a Backed Enum, it will return null.