PHP code example of donquixote / callback-reflection
1. Go to this page and download the library: Download donquixote/callback-reflection 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/ */
donquixote / callback-reflection example snippets
class C {
private $x;
private $y;
public function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
}
// Callback from class constructor.
$callback = CallbackReflection_ClassConstruction::create(C::class);
// Get reflection parameters.
$parameters = $callback->getReflectionParameters();
// Invoke the callback to create a class instance.
$instance = $callback->invokeArgs(['x', 'y']);
// Generate a PHP statement.
$codegenHelper = new CodegenHelper();
$php = $callback->argsPhpGetPhp(["'x'", "'y'"], $codegenHelper);