PHPackages                             rybakit/arguments-resolver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rybakit/arguments-resolver

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rybakit/arguments-resolver
==========================

ArgumentsResolver allows you to determine the arguments to pass to a function or method.

v0.6.2(4y ago)26107.7k↓25.5%17MITPHPPHP ^7.1|^8CI failing

Since Aug 8Pushed 4y ago3 watchersCompare

[ Source](https://github.com/rybakit/arguments-resolver)[ Packagist](https://packagist.org/packages/rybakit/arguments-resolver)[ Docs](https://github.com/rybakit/arguments-resolver)[ GitHub Sponsors](https://github.com/rybakit)[ RSS](/packages/rybakit-arguments-resolver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (7)

ArgumentsResolver
=================

[](#argumentsresolver)

[![Quality Assurance](https://github.com/rybakit/arguments-resolver/workflows/QA/badge.svg)](https://github.com/rybakit/arguments-resolver/workflows/QA/badge.svg)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/40400297f6b0ad0c2aca259bd112583959e18ed2445abfa9d8e8f9c8dac2378c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f727962616b69742f617267756d656e74732d7265736f6c7665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rybakit/arguments-resolver/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2b50c4d81e89d2b97ac1a66b28cb660d97451cc334bd46bf4e689a29172719a6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f727962616b69742f617267756d656e74732d7265736f6c7665722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/rybakit/arguments-resolver/?branch=master)

ArgumentsResolver allows you to determine the arguments to pass to a function or method.

Installation
------------

[](#installation)

The recommended way to install ArgumentsResolver is through [Composer](http://getcomposer.org):

```
composer require rybakit/arguments-resolver
```

Usage example
-------------

[](#usage-example)

```
use ArgumentsResolver\InDepthArgumentsResolver;

$greet = function ($username, DateTime $date, $greeting = 'Hello %s!') {
    // ...
};

$parameters = [
    'Welcome %s!',
    ['foo'],
    new DateTime(),
    'username' => 'Stranger',
    'bar',
];

$arguments = (new InDepthArgumentsResolver($greet))->resolve($parameters);
print_r($arguments);
```

The above example will output:

```
Array
(
    [0] => Stranger
    [1] => DateTime Object (...)
    [2] => Welcome %s!
)
```

Resolvers
---------

[](#resolvers)

The library ships with two resolvers, the [InDepthArgumentsResolver](#indepthargumentsresolver) and [NamedArgumentsResolver](#namedargumentsresolver). They both expect a function to be supplied as a single constructor argument. The function can be any [callable](http://php.net/manual/en/language.types.callable.php), [a string representing a class method](http://php.net/manual/en/reflectionmethod.construct.php#refsect1-reflectionmethod.construct-parameters) or an instance of [ReflectionFunctionAbstract](http://php.net/manual/en/class.reflectionfunctionabstract.php):

```
new InDepthArgumentsResolver(['MyClass', 'myMethod']);
new InDepthArgumentsResolver([new MyClass(), 'myMethod']);
new InDepthArgumentsResolver(['MyClass', 'myStaticMethod']);
new InDepthArgumentsResolver('MyClass::myStaticMethod');
new InDepthArgumentsResolver('MyClass::__construct');
new InDepthArgumentsResolver(['MyClass', '__construct']);
new InDepthArgumentsResolver(new MyInvokableClass());
new InDepthArgumentsResolver(function ($foo) {});
new InDepthArgumentsResolver('MyNamespace\my_function');
new InDepthArgumentsResolver(new ReflectionMethod('MyClass', 'myMethod'));
new InDepthArgumentsResolver(new ReflectionFunction('MyNamespace\my_function'));
```

There is also an utility class which helps in creating a reflection instance:

```
use ArgumentsResolver\ReflectionFactory;

$reflection = ReflectionFactory::create('MyClass::__construct');
$resolver = new InDepthArgumentsResolver($reflection);
```

#### InDepthArgumentsResolver

[](#indepthargumentsresolver)

In the `InDepthArgumentsResolver`, the decision about whether an argument matched the parameter value or not is influenced by multiple factors, namely the argument's type, the class hierarchy (if it's an object), the argument name and the argument position.

To clarify, consider each circumstance in turn:

*Argument type*

```
function foo(array $array, stdClass $object, callable $callable) {}

(new InDepthArgumentsResolver('foo'))->resolve([
    ...
    function () {},    // $callable
    ...
    new stdClass(),    // $object
    ...
    [42],              // $array
    ...
]);
```

*Class hierarchy*

```
function foo(Exception $e, RuntimeException $re) {}

(new InDepthArgumentsResolver('foo'))->resolve([
    ...
    new RuntimeException(),    // $re
    ...
    new Exception(),           // $e
    ...
]);
```

*Argument name*

```
function foo($a, $b) {}

(new InDepthArgumentsResolver('foo'))->resolve([
    ...
    'c' => 3,
    'b' => 2,    // $b
    'a' => 1,    // $a
    ...
]);
```

*Argument position*

```
function foo($a, $b) {}

(new InDepthArgumentsResolver('foo'))->resolve([
    1,   // $a
    2,   // $b
    ...
]);
```

#### NamedArgumentsResolver

[](#namedargumentsresolver)

The `NamedArgumentsResolver` is a very simple resolver which does the matching only by the argument name. Therefore this requires parameters to be an associative array:

```
function foo($a, array $b, $c = null) {}

(new NamedArgumentsResolver('foo'))->resolve([
    ...
    'b' => [],       // $b
    'a' => 1,        // $a
    'c' => 'bar',    // $c
    ...
]);
```

Tests
-----

[](#tests)

ArgumentsResolver uses [PHPUnit](http://phpunit.de) for unit testing. In order to run the tests, you'll first need to setup the test suite using composer:

```
composer install
```

You can then run the tests:

```
vendor/bin/phpunit
```

License
-------

[](#license)

ArgumentsResolver is released under the MIT License. See the bundled [LICENSE](LICENSE) file for details.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~313 days

Recently: every ~500 days

Total

9

Last Release

1791d ago

PHP version history (5 changes)v0.1.0PHP &gt;=5.5.0

v0.2.0PHP &gt;=5.4.0

v0.5.0PHP ^5.4|^7.0

v0.6.0PHP ^7.1

v0.6.2PHP ^7.1|^8

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/533861?v=4)[Eugene Leonovich](/maintainers/rybakit)[@rybakit](https://github.com/rybakit)

---

Top Contributors

[![rybakit](https://avatars.githubusercontent.com/u/533861?v=4)](https://github.com/rybakit "rybakit (157 commits)")

---

Tags

argumentscallablephpresolverinvokeinjectioncallablereflectionfunctionparametersmethodresolverarguments

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rybakit-arguments-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/rybakit-arguments-resolver/health.svg)](https://phpackages.com/packages/rybakit-arguments-resolver)
```

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[phpdocumentor/reflection-common

Common reflection classes used by phpdocumentor to reflect the code structure

9.1k706.8M26](/packages/phpdocumentor-reflection-common)[php-di/invoker

Generic and extensible callable invoker

26857.8M56](/packages/php-di-invoker)[timacdonald/has-parameters

A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.

228271.7k2](/packages/timacdonald-has-parameters)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12521.4M109](/packages/phpdocumentor-reflection)[raphhh/trex-reflection

Reflection helpers for callables and types

14324.0k10](/packages/raphhh-trex-reflection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
