Class

TRex\Reflection\TypeReflection

class TypeReflection extends Object

TypeReflection reflect the types.

Constants

VOID_TYPE

MIXED_TYPE

NULL_TYPE

BOOLEAN_TYPE

STRING_TYPE

INTEGER_TYPE

FLOAT_TYPE

NUMBER_TYPE

SCALAR_TYPE

ARRAY_TYPE

OBJECT_TYPE

RESOURCE_TYPE

UNKNOWN_TYPE

Methods

__construct(string $type)

Constructor.

mixed __get(string $propertyName)

See PHP doc.

from Object
mixed __set(string $propertyName, mixed $value)

See PHP doc.

from Object
mixed __call(string $methodName, array $args)

See PHP doc.

from Object
boolean isDynamic()

Indicates whether the current object has dynamic properties access.

from Object
setDynamic(boolean $isDynamic)

Sets dynamic properties access.

from Object
addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

from Object
array toArray()

Converts an object to an array.

from Object
Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

from Object
string __toString()

See PHP doc.

from Object
string getType()

Gets the reflected type.

string getStandardizedType()

Depending on the type, returns a standardized type, a constant value of XXX_TYPE.

bool isVoid()

Indicates whether the reflected type is void.

bool isMixed()

Indicates whether the reflected type is mixed.

bool isNull()

Indicates whether the reflected type is null.

bool isBoolean()

Indicates whether the reflected type is boolean.

bool isString()

Indicates whether the reflected type is string.

bool isInteger()

Indicates whether the reflected type is integer.

bool isFloat()

Indicates whether the reflected type is float.

bool isNumber()

Indicates whether the reflected type is number.

bool isScalar()

Indicates whether the reflected type is scalar.

bool isArray()

Indicates whether the reflected type is array.

bool isObject()

Indicates whether the reflected type is object.

bool isResource()

Indicates whether the reflected type is resource.

Details

at line 98
public __construct(string $type)

Constructor.

$data is initial data to set in the object. Keys are property names, and values are initial property values. $data could be a JSON string, an array or an array castable object.

Parameters

string $type Reflected type or class name

in Object at line 58
public mixed __get(string $propertyName)

See PHP doc.

Parameters

string $propertyName

Return Value

mixed

Exceptions

RuntimeException

in Object at line 78
public mixed __set(string $propertyName, mixed $value)

See PHP doc.

Parameters

string $propertyName
mixed $value

Return Value

mixed

Exceptions

RuntimeException

in Object at line 101
public mixed __call(string $methodName, array $args)

See PHP doc.

Call dynamically a method added with self::addMethod(). After having added a method, it is possible to call it like a declared method $object->newMethod($arg)

Parameters

string $methodName
array $args

Return Value

mixed

Exceptions

RuntimeException

in Object at line 116
public boolean isDynamic()

Indicates whether the current object has dynamic properties access.

Return Value

boolean

in Object at line 126
public setDynamic(boolean $isDynamic)

Sets dynamic properties access.

Parameters

boolean $isDynamic

in Object at line 137
public addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

Parameters

string $name
Closure $method

in Object at line 147
public array toArray()

Converts an object to an array.

The exported array contains all property values of the class and its parents, which are not transient.

Return Value

array

in Object at line 157
public Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

The exported data contains all property values ofn the class and its parents, who are not transient.

Parameters

int $options

Return Value

Json

in Object at line 170
public string __toString()

See PHP doc.

Return Value

string

at line 108
public string getType()

Gets the reflected type.

Return Value

string

at line 118
public string getStandardizedType()

Depending on the type, returns a standardized type, a constant value of XXX_TYPE.

Return Value

string

at line 133
public bool isVoid()

Indicates whether the reflected type is void.

Return Value

bool

at line 143
public bool isMixed()

Indicates whether the reflected type is mixed.

Return Value

bool

at line 153
public bool isNull()

Indicates whether the reflected type is null.

Return Value

bool

at line 163
public bool isBoolean()

Indicates whether the reflected type is boolean.

Return Value

bool

at line 173
public bool isString()

Indicates whether the reflected type is string.

Return Value

bool

at line 183
public bool isInteger()

Indicates whether the reflected type is integer.

Return Value

bool

at line 193
public bool isFloat()

Indicates whether the reflected type is float.

Return Value

bool

at line 203
public bool isNumber()

Indicates whether the reflected type is number.

Return Value

bool

at line 213
public bool isScalar()

Indicates whether the reflected type is scalar.

Return Value

bool

at line 223
public bool isArray()

Indicates whether the reflected type is array.

Return Value

bool

at line 233
public bool isObject()

Indicates whether the reflected type is object.

Return Value

bool

at line 243
public bool isResource()

Indicates whether the reflected type is resource.

Return Value

bool