PHP code example of krak / auto-args

1. Go to this page and download the library: Download krak/auto-args 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/ */

    

krak / auto-args example snippets




use Krak\AutoArgs;

$args = new AutoArgs();

$context = [
    'vars' => ['a' => 1],
    'objects' => [new SplStack()],
];

$func = function($a, SplDoublyLinkedList $stack, $b = 1) {
    assert($a == 1 && $b === 1);
};

$args->invoke($func, $context);



use Krak\AutoArgs,
    Krak\Cargo,
    Interop\Container\ContainerInterface;

$args = new AutoArgs();
$c = Cargo\container();
$c[SplStack::class] = function() {
    return new SplStack();
};

$context = [
    'container' => $c->toInterop()
];

$func = function(ContainerInterface $container, SplStack $stack) {

};

$args->invoke($func, $context);