Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krakphp/auto-args
Auto Argument Resolver
https://github.com/krakphp/auto-args
argument-resolver auto-wire composer
Last synced: 29 days ago
JSON representation
Auto Argument Resolver
- Host: GitHub
- URL: https://github.com/krakphp/auto-args
- Owner: krakphp
- License: mit
- Created: 2017-01-15T05:08:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-25T02:35:29.000Z (almost 8 years ago)
- Last Synced: 2024-11-16T14:14:06.527Z (about 1 month ago)
- Topics: argument-resolver, auto-wire, composer
- Language: PHP
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Auto Args
Auto Args provides a system for automatically resolving arguments for any callable. This can also be referred to as Auto wiring.
## Installation
Install with composer at `krak/auto-args`.
## Usage
```php
['a' => 1],
'objects' => [new SplStack()],
];$func = function($a, SplDoublyLinkedList $stack, $b = 1) {
assert($a == 1 && $b === 1);
};$args->invoke($func, $context);
```### Container Integration
```php
$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.
#### mixed invoke(callable $callable, array $context)
Invokes a callable and resolves the arguments from the argument resolver and given context.
#### mixed construct($class_name, array $context)
Constructs a an object from the class name and resolves the arguments for the constructor
#### 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.
#### Krak\\Mw\\MwStack ::createStack()
Returns a configured instance of an mw stack.