1. Go to this page and download the library: Download respect/parameter 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/ */
respect / parameter example snippets
use Respect\Parameter\ContainerResolver;
function notify(Mailer $mailer, Logger $logger, string $to, string $subject = 'Hi') {
// ...
}
$resolver = new ContainerResolver($container);
$args = $resolver->resolve(new ReflectionFunction('notify'), ['[email protected]']);
// [Mailer, Logger, '[email protected]', 'Hi'] — ordered, ready to splat
notify(...$args);
// or
$reflection->newInstanceArgs($args);
function notify(string $subject, Mailer $mailer) {
// ...
}
$args = $resolver->resolve(new ReflectionFunction('notify'), [$mailer, 'Hello']);
// ['Hello', Mailer] — $mailer matched by type, 'Hello' fell through to $subject