1. Go to this page and download the library: Download vitorsreis/extend-caller 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/ */
use VSR\Extend\Caller\Context;
new Caller(function ($context) { ... });
new Caller(function (mixed $context) { ... }); # Explicit mixed type only PHP 8+
new Caller(function (Context $context) { ... });
new Caller(function (Context $custom_name_context) { ... });
new Caller(new class {
public function __construct($context) { ... }
public function __invoke($context) { ... }
}); // Call __invoke
$callback = function ($a, $b, $c = 3) { ... };
$caller = new \VSR\Extend\Caller($callback);
$callback = static function ($a, $b, $c = 3) { ... };
$caller = new \VSR\Extend\Caller($callback);
class AAA {
public function method($a, $b, $c = 3) { ... }
}
$aaa = new AAA();
$caller = new \VSR\Extend\Caller("AAA::method"); // Call first constructor if exists and then method
$caller = new \VSR\Extend\Caller([ AAA::class, 'method' ]); // Call first constructor if exists and then method
$caller = new \VSR\Extend\Caller([ new AAA(), 'method' ]); // Call method
$caller = new \VSR\Extend\Caller([ $aaa, 'method' ]); // Call method
class BBB {
public static function method($a, $b, $c = 3) { ... }
}
$bbb = new BBB();
$caller = new \VSR\Extend\Caller("BBB::method"); // Call static method
$caller = new \VSR\Extend\Caller([ BBB::class, 'method' ]); // Call static method
$caller = new \VSR\Extend\Caller([ new BBB(), 'method' ]); // Call static method
$caller = new \VSR\Extend\Caller([ $bbb, 'method' ]); // Call static method
class CCC {
public function __construct($d, $e, $f = 6) { ... }
public function method($a, $b, $c = 3) { ... }
}
$caller = new \VSR\Extend\Caller("CCC::method"); // Call first constructor and then method
$caller = new \VSR\Extend\Caller([ CCC::class, "method" ]); // Call first constructor and then method
class DDD {
public function __invoke($a, $b, $c = 3) { ... }
}
$ddd = new DDD();
$caller = new \VSR\Extend\Caller("DDD"); // Call first constructor if exists and then __invoke
$caller = new \VSR\Extend\Caller(DDD::class); // Call first constructor if exists and then __invoke
$caller = new \VSR\Extend\Caller(new DDD()); // Call __invoke
$caller = new \VSR\Extend\Caller($ddd); // Call __invoke
$caller = new \VSR\Extend\Caller(new class {
public function __invoke($a, $b, $c = 3) { ... }
}); // Call __invoke
$context->time
$context->get($key, $default = null)
$context->set($key, $value)
$context->has($key)
$context->del($key)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.