Download the PHP package skagarwal/reflection without Composer
On this page you can find all versions of the php package skagarwal/reflection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download skagarwal/reflection
More information about skagarwal/reflection
Files in skagarwal/reflection
Package reflection
Short Description Test any Private/Protected Methods/Properties of any class
License MIT
Informations about the package reflection
Php-Reflection-Deflector
Test your Private/Protected Methods/Properties with any testing package and with Zero configuration.
New: Can reflect multiple classes at same time.
Usage
Step 1: Install Through Composer
Step 2: Import the trait
Import the SKAgarwal\Reflection\ReflectableTrait
in your TestClass
of any package. Eg: PhpUnit
, PhpSpec
, Laracasts\Integrated
.
For PhpUnit
And That's it. You are all set to go. :)
Now you can do the following to test private/protected methods or properties:
Instantiate the Reflector
By using reflect()
method like this:
This Method is not chainable
Note: Its preferable to use this in constructor
or for PhpUnit in setUp()
method etc.
By using on()
method like this:
This method is chainable Note: This method relfects the class object only once. That is only for one call to method or property. It can be used for relfecting multiple classes at same time.
Available Methods
reflect($classObj);
Description: Reflect the Class Object
on($classObj);
Description: Reflect the Class Object. This is Chainable Method.
Possible Chaining:
call($method, $arguments = []);
Description: Call any valid public/Private/Protected Method of reflected Class Object. This is not Chainable Method.
call{Method}($arguments = []);
Description: Same as call()
but dynamically calls the method. This is not Chainable Method.
{method} Can be any valid public/private/protected method of reflected Class Object.
get($property);
Description: Get the value of any valid Public/Private/Protected property of the reflected Class Object. This is not Chainable Method.
get{Property};
Description: Same as get()
but dynamically gets the value of the property. This is not Chainable Method.
{property} Can be any valid Public/Private/Protected property of the reflected Class Object.
set($name, $value);
Description: Set the value of valid Public/Private/Protected property of the reflected Class Object. This is not Chainable Method.
set{Property} = $value;
Description: Same as set()
but dynamically sets the value of the property. This is not Chainable Method.
{property} Can be any valid Public/Private/Protected property of the reflected Class Object.
-
Reflect Multiple classes at same time
Example: