class ReflectionCallback implements Reflector

The callback global reflector

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( callable $value)

No description

callable
getCallback()

Returns the original callback content

int
getCallbackType()

Returns the callback type

int
getType()

Returns the callback type (alias of self::getCallbackType())

getReflector()

Returns the reflector of the callback

null|string
getFunctionName()

Returns the function or method name if defined

null|string
getClassName()

Returns the class or object class name if defined

mixed
invoke()

Invokes the callback with a list of parameters

mixed
invokeArgs( array $args)

Invokes the callback with a list of parameters as an array

bool
isFunction()

Tests if the callback is a function

bool
isClosure()

Tests if the callback is a closure

bool
isMethod()

Tests if the callback is a class' method

bool
isMethodStatic()

Tests if the callback is a static class' method

bool
isObject()

Tests if the callback is a static class' method

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 64
__construct( callable $value)

Parameters

callable $value

Exceptions

ReflectionException if the parameter is not a closure

at line 82
callable getCallback()

Returns the original callback content

Return Value

callable

at line 92
int getCallbackType()

Returns the callback type

Return Value

int

at line 103
int getType()

Returns the callback type (alias of self::getCallbackType())

Return Value

int

See also

self::getCallbackType()

at line 113
Reflector getReflector()

Returns the reflector of the callback

Return Value

Reflector

at line 132
null|string getFunctionName()

Returns the function or method name if defined

Return Value

null|string

at line 142
null|string getClassName()

Returns the class or object class name if defined

Return Value

null|string

at line 152
mixed invoke()

Invokes the callback with a list of parameters

Return Value

mixed

at line 163
mixed invokeArgs( array $args)

Invokes the callback with a list of parameters as an array

Parameters

array $args

Return Value

mixed

at line 173
bool isFunction()

Tests if the callback is a function

Return Value

bool

at line 183
bool isClosure()

Tests if the callback is a closure

Return Value

bool

at line 193
bool isMethod()

Tests if the callback is a class' method

Return Value

bool

at line 203
bool isMethodStatic()

Tests if the callback is a static class' method

Return Value

bool

at line 213
bool isObject()

Tests if the callback is a static class' method

Return Value

bool

at line 226
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