, (*1)
A PHP reflection library to directly access protected/private properties and call protected/private methods. Static
properties and methods can also be accessed/invoked from a class directly., (*2)
This library works with major versions of PHP from 5.3 to 8.2., (*3)
Installation
For PHP 8.0+, please use version 2.0:, (*4)
composer require crowdstar/reflection:~2.0.0
For old versions of PHP (PHP 5.3 to PHP 7.4), please use version 1.0 instead:, (*5)
composer require crowdstar/reflection:~1.0.0
How To Use It
Three static methods are provided to access protected/private properties and call protected/private methods of an object/class:, (*6)
-
CrowdStar\Reflection\Reflection::getProperty()
: Get current value of a property.
-
CrowdStar\Reflection\Reflection::setProperty()
: Set a new value to a property.
-
CrowdStar\Reflection\Reflection::callMethod()
: Call a method of a class/object.
Here is a sample code showing how to use them:, (*7)