PHP code example of makinacorpus / argument-resolver

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

    

makinacorpus / argument-resolver example snippets




return [
    // ... Your other bundles.
    MakinaCorpus\ArgumentResolver\Bridge\Symfony\ArgumentResolverBundle::class => ['all' => true],
];

namespace Some\Namespace;

function foo(int $bar, ?int $foo, string $fizz = 'foo', \DateTime ...$dates): void
{
    // Do something.
}

use MakinaCorpus\ArgumentResolver\Context\ArrayResolverContext;
use MakinaCorpus\ArgumentResolver\DefaultArgumentResolver;

$callback = '\\Some\\Namespace\\foo';

$argumentResolver = new DefaultArgumentResolver();

$arguments = $argumentResolver->getArguments(
    $callback,
    new ArrayResolverContext(
        [
            'bar' => 12,
        ]
    )
);

echo ($callback)(...$arguments);
// 12