interface ReflectionServiceInterface (View source)

Reflection utility service

Constants

EXPOSE_HIDDEN_PROPERTY

Expose non-public prpeerties when retrieving property values.

WRITABLE

Require write permission to value.

READABLE

Require public value access

RW

Require full access to value.

EXPOSE_INHERITED_PROPERTY

Expose private properties of parent classes

ALLOW_WRITE_METHOD

Use class instance method to alter property value.

ALLOW_READ_METHOD

Use a class instance method to read access property value.

When retrieving non-public property value. Invoke method matching getter naming convention if any.

ALLOW_RW_METHODS

Use class instance methods to set and get values.

FORCE_WRITE_METHOD

When assigning property value.

Always use mettong matching getter naming convention if possible.

FORCE_READ_METHOD

When retrieving property value.

Always use mettong matching getter naming convention if possible.

FORCE_RW_METHODS

Force use of setter and getter methods even if property has public access.

Methods

getReflectionClass(string|object $classNameOrObject)

Get reflection class for the given class name or object.

getReflectionProperty(ReflectionClass|object|string $class, string $property, number $flags = 0)

No description

mixed
getPropertyValue(object $object, ReflectionProperty|string $property, number $flags = 0)

No description

mixed[]
getPropertyValues(object $object, number $flags = 0)

No description

setPropertyValues(object $object, array $values, number $flags = 0)

No description

findReadMethodForProperty(ReflectionClass $class, string $propertyName)

Find the method matching getter naming convention for the given property name.

findWriteMethodForProperty(ReflectionClass $class, string $propertyName)

Find the method matching setter naming convention for the given property name.

Details

ReflectionClass getReflectionClass(string|object $classNameOrObject)

Get reflection class for the given class name or object.

Parameters

string|object $classNameOrObject Class name or Class instance

Return Value

ReflectionClass

ReflectionProperty|NULL getReflectionProperty(ReflectionClass|object|string $class, string $property, number $flags = 0)

Parameters

ReflectionClass|object|string $class Class, class name or object
string $property Property name
number $flags Property requirements and options.

Return Value

ReflectionProperty|NULL A ReflectionProperty that honor $flags requirements.$this If $flags does not expect any requirement, NULL may be returned . If no ReflectionProperty can be provided the requirements expected by $flags, an error is thrown.

mixed getPropertyValue(object $object, ReflectionProperty|string $property, number $flags = 0)

Parameters

object $object Class instance
ReflectionProperty|string $property Property of $object
number $flags Option flags

Return Value

mixed Property value if it can be retrieved or NULL otherwise

mixed[] getPropertyValues(object $object, number $flags = 0)

Parameters

object $object Class instance
number $flags Option flags

Return Value

mixed[] Dictionary of prperty values.

setPropertyValues(object $object, array $values, number $flags = 0)

Parameters

object $object Output object
array $values Property values
number $flags ReflectionProperty flags

ReflectionMethod|NULL findReadMethodForProperty(ReflectionClass $class, string $propertyName)

Find the method matching getter naming convention for the given property name.

Parameters

ReflectionClass $class Class
string $propertyName Property name

Return Value

ReflectionMethod|NULL

ReflectionMethod|NULL findWriteMethodForProperty(ReflectionClass $class, string $propertyName)

Find the method matching setter naming convention for the given property name.

Parameters

ReflectionClass $class Class
string $propertyName Property name

Return Value

ReflectionMethod|NULL