ReflectionProperty
class ReflectionProperty implements Reflector (View source)
The ReflectionProperty class reports information about a classes properties.
Constants
|
IS_ABSTRACT
Since: 8.4
|
|
|
IS_VIRTUAL
Since: 8.4
|
|
| IS_STATIC |
Indicates that the property is static. |
| IS_PUBLIC |
Indicates that the property is public. |
| IS_PROTECTED |
Indicates that the property is protected. |
| IS_PRIVATE |
Indicates that the property is private. |
|
IS_READONLY
Since: 8.1
|
|
|
IS_PROTECTED_SET
Since: 8.4
|
|
|
IS_PRIVATE_SET
Since: 8.4
|
|
|
IS_FINAL
Since: 8.4
|
|
Properties
| string | $name | ||
| class-string | $class |
Methods
Construct a ReflectionProperty object
Export
To string
Gets property name
Gets value
Set property value
Checks if property is public
Checks if property is private
Checks if property is protected
Checks if property is static
Checks if default value
Gets modifiers
Gets declaring class
Gets doc comment
Set property accessibility This method is no-op starting from PHP 8.1
Gets property type
Checks if property has type
Checks if property is initialized
Returns information about whether the property was promoted.
Checks if property has a default value declared
Returns the default value declared for a property
Gets Attributes
Checks if property is readonly
Returns the value of a property, bypassing a get hook if defined
Sets the value of a property, bypassing a set hook if defined
Determines if a property is abstract
Determines if a property is virtual
Returns the parameter type of a setter hook
Returns whether the property has any hooks defined
Returns an array of all hooks on this property
Returns whether the property has a given hook defined
Returns a reflection object for a specified hook
Checks if property is private for writing
Checks whether the property is protected for writing
Set raw property value without triggering lazy initialization
Marks property as non-lazy
Checks if property is a dynamic property
Determines if this property is final or not
Checks whether a property is lazy
Gets the mangled name of the property
No description
No description
Details
__construct(class-string|object $class, string $property)
Construct a ReflectionProperty object
static string|null
export(mixed $class, string $name, bool $return = false)
Export
string
__toString()
To string
string
getName()
Gets property name
mixed
getValue(object|null $object = null)
Gets value
void
setValue(mixed $objectOrValue, mixed $value)
Set property value
bool
isPublic()
Checks if property is public
bool
isPrivate()
Checks if property is private
bool
isProtected()
Checks if property is protected
bool
isStatic()
Checks if property is static
bool
isDefault()
Checks if default value
int
getModifiers()
Gets modifiers
ReflectionClass
getDeclaringClass()
Gets declaring class
string|false
getDocComment()
Gets doc comment
void
setAccessible(bool $accessible)
Set property accessibility This method is no-op starting from PHP 8.1
ReflectionType|null
getType()
Gets property type
bool
hasType()
Checks if property has type
bool
isInitialized(object|null $object = null)
Checks if property is initialized
bool
isPromoted()
Returns information about whether the property was promoted.
bool
hasDefaultValue()
Checks if property has a default value declared
Checks whether the property was declared with a default value, including an implicit null default value. Only returns false for typed properties without default value (or dynamic properties).
mixed
getDefaultValue()
Returns the default value declared for a property
Gets the implicit or explicitly declared default value for a property.
array
getAttributes(string|null $name = null, int $flags = 0)
Gets Attributes
Returns all attributes declared on this class property as an array of ReflectionAttribute.
bool
isReadOnly()
Checks if property is readonly
Checks whether the property is readonly.
mixed
getRawValue(object $object)
Returns the value of a property, bypassing a get hook if defined
void
setRawValue(object $object, mixed $value)
Sets the value of a property, bypassing a set hook if defined
bool
isAbstract()
Determines if a property is abstract
bool
isVirtual()
Determines if a property is virtual
ReflectionType|null
getSettableType()
Returns the parameter type of a setter hook
Returns the parameter type of a set hook. If no set hook is defined, it behaves identically to ReflectionProperty::getType.
bool
hasHooks()
Returns whether the property has any hooks defined
array
getHooks()
Returns an array of all hooks on this property
Returns a list of all hooks on this property.
bool
hasHook(PropertyHookType $type)
Returns whether the property has a given hook defined
ReflectionMethod|null
getHook(PropertyHookType $type)
Returns a reflection object for a specified hook
Gets the reflection of the property's hook, if any.
bool
isPrivateSet()
Checks if property is private for writing
Checks whether the property is private for writing.
bool
isProtectedSet()
Checks whether the property is protected for writing
void
setRawValueWithoutLazyInitialization(object $object, mixed $value)
Set raw property value without triggering lazy initialization
Sets (changes) the property's value without triggering lazy initialization and without calling hook functions. The property is marked as non-lazy and can be accessed afterwards without triggering lazy initialization. The property must not be dynamic, static, or virtual, and the object must be an instance of a user defined class or stdClass.
void
skipLazyInitialization(object $object)
Marks property as non-lazy
Marks a property as non-lazy such that it can be accessed directly without triggering lazy initialization. The property is initialized to its default value, if any. The property must not be dynamic, static, or virtual, and the object must be an instance of a user defined class or stdClass.
bool
isDynamic()
Checks if property is a dynamic property
Checks whether the property was declared at run-time, or whether the property was declared at compile-time.
bool
isFinal()
Determines if this property is final or not
Returns whether the property is final. If the property is marked private(set), then it will also be implicitly final.
bool
isLazy(object $object)
Checks whether a property is lazy
string
getMangledName()
Gets the mangled name of the property
Returns the mangled (internal) name of the property, which encodes the visibility scope for private and protected properties.
bool
isReadable(string|null $scope, object|null $object = null)
No description
bool
isWritable(string|null $scope, object|null $object = null)
No description