1. Go to this page and download the library: Download nsp-team/reflection-tool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nsp-team / reflection-tool example snippets
use NspTeam\Reflection\ReflectionObject;
class Test
{
private $key;
private static $keyStatic;
/**
*
* @return string
*/
private function one(): string
{
return '私有方法';
}
/**
* @param int $i
* @param int $j
* @return string
*/
private static function oneStatic(int $i, int $j): string
{
return "私有静态方法 带参 $i 和 $j";
}
}
$test = new Test();
ReflectionObject::setProperty(Test::class, 'keyStatic', 'another value');
ReflectionObject::setProperty($test, 'key', 'value ');
var_dump(ReflectionObject::callMethod($test, 'one'));
var_dump(ReflectionObject::getProperty($test, 'key'));
var_dump(ReflectionObject::callMethod($test, 'oneStatic', array(1, 2)));
var_dump(ReflectionObject::getProperty($test, 'keyStatic'));
var_dump(ReflectionObject::findProperty($test, 'key'));
var_dump(ReflectionObject::getMethod(Test::class, 'one')->getDocComment());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.