1. Go to this page and download the library: Download rybakit/arguments-resolver 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/ */
rybakit / arguments-resolver example snippets
use ArgumentsResolver\InDepthArgumentsResolver;
$greet = function ($username, DateTime $date, $greeting = 'Hello %s!') {
// ...
};
$parameters = [
'Welcome %s!',
['foo'],
new DateTime(),
'username' => 'Stranger',
'bar',
];
$arguments = (new InDepthArgumentsResolver($greet))->resolve($parameters);
print_r($arguments);
new InDepthArgumentsResolver(['MyClass', 'myMethod']);
new InDepthArgumentsResolver([new MyClass(), 'myMethod']);
new InDepthArgumentsResolver(['MyClass', 'myStaticMethod']);
new InDepthArgumentsResolver('MyClass::myStaticMethod');
new InDepthArgumentsResolver('MyClass::__construct');
new InDepthArgumentsResolver(['MyClass', '__construct']);
new InDepthArgumentsResolver(new MyInvokableClass());
new InDepthArgumentsResolver(function ($foo) {});
new InDepthArgumentsResolver('MyNamespace\my_function');
new InDepthArgumentsResolver(new ReflectionMethod('MyClass', 'myMethod'));
new InDepthArgumentsResolver(new ReflectionFunction('MyNamespace\my_function'));
use ArgumentsResolver\ReflectionFactory;
$reflection = ReflectionFactory::create('MyClass::__construct');
$resolver = new InDepthArgumentsResolver($reflection);
function foo(array $array, stdClass $object, callable $callable) {}
(new InDepthArgumentsResolver('foo'))->resolve([
...
function () {}, // $callable
...
new stdClass(), // $object
...
[42], // $array
...
]);
function foo(Exception $e, RuntimeException $re) {}
(new InDepthArgumentsResolver('foo'))->resolve([
...
new RuntimeException(), // $re
...
new Exception(), // $e
...
]);