2017 © Pedro Peláez
 

library auto-args

Auto Argument Resolver

image

krak/auto-args

Auto Argument Resolver

  • Saturday, March 25, 2017
  • by ragboyjr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 327 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Auto Args

Auto Args provides a system for automatically resolving arguments for any callable. This can also be referred to as Auto wiring., (*1)

Installation

Install with composer at krak/auto-args., (*2)

Usage

<?php

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);

Container Integration

<?php

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);

API

Class AutoArgs

__construct($resolve_arg = null)

Accepts an argument resolver which will accept Argument metadata and context and return the proper argument for it. If none is supplied, the default stack is created and composed instead., (*3)

mixed invoke(callable $callable, array $context)

Invokes a callable and resolves the arguments from the argument resolver and given context., (*4)

mixed construct($class_name, array $context)

Constructs a an object from the class name and resolves the arguments for the constructor, (*5)

array resolveArguments(callable $callable, array $context)

Returns the array of resolved arguments for the given callable. An exception will be thrown if no argument was able to be resolved., (*6)

Krak\Mw\MwStack ::createStack()

Returns a configured instance of an mw stack., (*7)

The Versions

25/03 2017

dev-master

9999999-dev

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver

25/03 2017

v0.3.1

0.3.1.0

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver

12/03 2017

v0.3.0

0.3.0.0

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver

27/02 2017

v0.2.1

0.2.1.0

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver

17/02 2017

v0.2.0

0.2.0.0

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver

15/01 2017

v0.1.0

0.1.0.0

Auto Argument Resolver

  Sources   Download

MIT

The Requires

 

The Development Requires

auto wiring auto args argument resolver