PHP code example of coroq / callable-reflector
1. Go to this page and download the library: Download coroq/callable-reflector 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/ */
coroq / callable-reflector example snippets
use Coroq\CallableReflector\CallableReflector;
$reflection = CallableReflector::createFromCallable($callable);
// Function
$reflection = CallableReflector:createFromCallable('strlen');
// Closure
$closure = function($x) { return $x * 2; };
$reflection = CallableReflector::createFromCallable($closure);
// Static method
$reflection = CallableReflector::createFromCallable('ExampleClass::staticMethod');
$reflection = CallableReflector::createFromCallable([ExampleClass::class, 'staticMethod']);
// Instance method
$object = new ExampleClass();
$reflection = CallableReflector::createFromCallable([$object, 'instanceMethod']);
// Invokable object
$object = new InvokableClass(); // InvokableClass has __invoke()
$reflection = CallableReflector::createFromCallable($object);