PHPackages                             respect/parameter - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. respect/parameter

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

respect/parameter
=================

Resolves function/constructor parameters via type and name lookup

3.0.0(1mo ago)0496—3.9%1[2 issues](https://github.com/Respect/Parameter/issues)[4 PRs](https://github.com/Respect/Parameter/pulls)1ISCPHPPHP ^8.5CI passing

Since Mar 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Respect/Parameter)[ Packagist](https://packagist.org/packages/respect/parameter)[ RSS](/packages/respect-parameter/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (3)Dependencies (14)Versions (19)Used By (1)

Respect\\Parameter
==================

[](#respectparameter)

Resolves function and constructor parameters from a PSR-11 container by type.

Install
-------

[](#install)

```
composer require respect/parameter
```

Usage
-----

[](#usage)

### Resolve arguments

[](#resolve-arguments)

For each parameter the resolver tries, in order:

1. An explicit **named** argument (keyed by parameter name)
2. A **positional** argument already matching the parameter **type**
3. The **container**, matched by **type** (non-builtin)
4. The next **positional** argument
5. The parameter's **default value**
6. `null`

A trailing **variadic** parameter receives a matching named argument (if any) followed by every remaining positional argument.

```
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'), ['bob@example.com']);
// [Mailer, Logger, 'bob@example.com', 'Hi']  — ordered, ready to splat
```

The result is an ordered list, so spread it straight into the call or constructor:

```
notify(...$args);
// or
$reflection->newInstanceArgs($args);
```

### Named arguments

[](#named-arguments)

`resolve()` accepts named arguments too — keyed by parameter name, taking precedence over the container; the remaining parameters are filled by type and defaults:

```
$args = $resolver->resolve($constructor, ['username' => 'admin']);
```

### Bind to the interface

[](#bind-to-the-interface)

Type-hint `Resolver` (the `resolve()` contract) rather than the concrete `ContainerResolver` to stay decoupled from the implementation:

```
use Respect\Parameter\Resolver;

final class Factory
{
    public function __construct(private Resolver $resolver)
    {
    }
}
```

### Reflect any callable

[](#reflect-any-callable)

Convert any callable form into a `ReflectionFunctionAbstract`:

```
use Respect\Parameter\ContainerResolver;

ContainerResolver::reflectCallable(fn() => ...);                  // Closure
ContainerResolver::reflectCallable([$obj, 'method']);             // Array callable
ContainerResolver::reflectCallable(new Invocable());              // __invoke object
ContainerResolver::reflectCallable('strlen');                     // Function name
ContainerResolver::reflectCallable('DateTime::createFromFormat'); // Static method
```

### Check accepted types

[](#check-accepted-types)

```
ContainerResolver::acceptsType($reflection, LoggerInterface::class); // true/false
```

API
---

[](#api)

MethodTypeDescription`resolve($reflection, $arguments)`instanceResolve named/positional arguments + container into an ordered `list`, expanding variadics`reflectCallable($callable)`staticAny callable to `ReflectionFunctionAbstract``acceptsType($reflection, $type)`staticCheck if any parameter accepts a type`ContainerResolver` implements `Resolver`.

License
-------

[](#license)

ISC. See [LICENSE](LICENSE).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance93

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 67.9% 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 ~47 days

Total

3

Last Release

42d ago

Major Versions

1.0.0 → 2.0.02026-06-25

2.0.0 → 3.0.02026-06-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/202642?v=4)[Alexandre Gomes Gaigalas](/maintainers/alganet)[@alganet](https://github.com/alganet)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")[![alganet](https://avatars.githubusercontent.com/u/202642?v=4)](https://github.com/alganet "alganet (9 commits)")

---

Tags

PSR-11Autowiringdependency-injectionrespectparameterresolver

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/respect-parameter/health.svg)

```
[![Health](https://phpackages.com/badges/respect-parameter/health.svg)](https://phpackages.com/packages/respect-parameter)
```

###  Alternatives

[laminas/laminas-servicemanager

Factory-Driven Dependency Injection Container

15960.1M830](/packages/laminas-laminas-servicemanager)[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

138.8k4](/packages/infocyph-intermix)

PHPackages © 2026

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