Download the PHP package raphhh/trex-reflection without Composer
On this page you can find all versions of the php package raphhh/trex-reflection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download raphhh/trex-reflection
More information about raphhh/trex-reflection
Files in raphhh/trex-reflection
Package trex-reflection
Short Description Reflection helpers for callables and types
License MIT
Homepage https://github.com/Raphhh/trex-reflection
Informations about the package trex-reflection
TRex Reflection
PHP tool to reflect callables an types.
Installation
Use composer command:
Documentation
- CallableReflection
- TypeReflection
CallableReflection
You can use CallableReflection to inspect and call a callable, like a callback or a Closure for example.
All kind of callable
You can know which kind of callable is given.
Closure
Function
Static method
Instance method
Invoked object
Retrieve contexts
You can retrieve the callable, like the object or the method name for example.
Closure
Function
Static method
Instance method
Invoked object
Invoke callable
You can invoke every kind of callable in a same way.
With a list of args
This method calls the method and give to it all its args.
With an array of args
This method allows to map each value of an array with every params of a function. Useful to use dynamic args with func_get_args().
With a map of args
This method allows to map the keys of an array with the name of the params of a function. So, the order of the args has no importance.
Retrieve the associated reflection class
Retrieve the ReflectionFunctionAbstract of the callable.
For a function or a closure
For a method
For a class
Note that for a class, we get a ReflectionMethod
for the __invoke
method of the current object, and not a ReflectionClass
.
TypeReflection
Reflection on the type of a variable or function.
What is a type?
A type is a string defined by a specific value related to one of the PHP types.
If you work with a variable, you can use TypeReflection::createFromVariable($variable)
Note the TypeReflection
is case insensitive.
Standardized types
TypeReflection
standardizes types with following values:
void
mixed
null
boolean
string
integer
float
number
scalar
array
object
resource
callable
unknown type
Valid any type
Recognition
boolean
string
integer
float
number
Any integer or float value.
scalar
Any boolean, string or number value.