class ReflectionValue implements ReflectionValueInterface

This is the global variable value reflector object. It acts like a reflection proxy.

Traits

Basic implementation of the \Reflector::export() method
This trait defines magic getters and setters for read-only object's properties

Methods

static  string|null
export( mixed $argument, bool $return = false)

Creation of a new instance of the mother class on-the-fly

void
setReadOnlyProperties( array $data)

Defines the read-only properties names and accessors.

mixed
__get( string $name)

Magic getter for read-only properties.

void
__set( string $name, mixed $value)

Magic setter to avoid setting read-only properties.

void
__unset( string $name)

Magic un-setter to avoid un-setting read-only properties.

__construct( mixed $value, int $flag = ValueType::MODE_STRICT, array $order = null)

No description

mixed
getReflector()

Returns the variable reflector

mixed
getValue()

Returns the variable's value from the reflector

string
getValueType()

Returns the variable's type from the reflector

bool
isNull()

Tests if the variable is NULL

bool
isBoolean()

Tests if the variable is a boolean

bool
isInteger()

Tests if the variable is an integer

bool
isFloat()

Tests if the variable is a float

bool
isString()

Tests if the variable is a string

bool
isArray()

Tests if the variable is an array

bool
isObject()

Tests if the variable is an object

bool
isResource()

Tests if the variable is a resource

bool
isCallback()

Tests if the variable is a callback

string
__toString()

Representation of the object

Details

in ReflectorTrait at line 54
static string|null export( mixed $argument, bool $return = false)

Creation of a new instance of the mother class on-the-fly

Keep in mind that this method only consider the FIRST argument passed to transmit to the constructor. If your mother class requires more than one argument, you will have to over-write this method (or to not use the trait).

Parameters

mixed $argument
bool $return

Return Value

string|null

Exceptions

ErrorException if the mother class does not implement the \Reflector interface
ErrorException if the mother class constructor is not callable

void setReadOnlyProperties( array $data)

Defines the read-only properties names and accessors.

Each key => value pair of the $data array must be constructed like:

  • key is the name of the property (MUST be defined with protected access in the child class)
  • value is an accessor for that property: the name of the access method if it exists or true for the default $obj->$key accessor.

Parameters

array $data This is the table of read-only properties

Return Value

void

Exceptions

InvalidArgumentException if the $data array is malformed

mixed __get( string $name)

Magic getter for read-only properties.

This will trigger a notice if the property can not be accessed.

Parameters

string $name

Return Value

mixed

void __set( string $name, mixed $value)

Magic setter to avoid setting read-only properties.

Parameters

string $name
mixed $value

Return Value

void

Exceptions

ReflectionException if trying to set a read-only property

void __unset( string $name)

Magic un-setter to avoid un-setting read-only properties.

Parameters

string $name

Return Value

void

Exceptions

ReflectionException if trying to unset a read-only property

at line 53
__construct( mixed $value, int $flag = ValueType::MODE_STRICT, array $order = null)

Parameters

mixed $value
int $flag
array $order

at line 66
mixed getReflector()

Returns the variable reflector

Return Value

mixed

at line 76
mixed getValue()

Returns the variable's value from the reflector

Return Value

mixed

at line 86
string getValueType()

Returns the variable's type from the reflector

Return Value

string

at line 96
bool isNull()

Tests if the variable is NULL

Return Value

bool

at line 106
bool isBoolean()

Tests if the variable is a boolean

Return Value

bool

at line 116
bool isInteger()

Tests if the variable is an integer

Return Value

bool

at line 126
bool isFloat()

Tests if the variable is a float

Return Value

bool

at line 136
bool isString()

Tests if the variable is a string

Return Value

bool

at line 146
bool isArray()

Tests if the variable is an array

Return Value

bool

at line 156
bool isObject()

Tests if the variable is an object

Return Value

bool

at line 166
bool isResource()

Tests if the variable is a resource

Return Value

bool

at line 176
bool isCallback()

Tests if the variable is a callback

Return Value

bool

at line 189
string __toString()

Representation of the object

If an exception is caught, its message is returned instead of the original result (but it is not thrown ahead).

Return Value

string