PHPackages                             resolver-interop/interface - 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. resolver-interop/interface

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

resolver-interop/interface
==========================

Interoperable autowiring resolver interfaces for PHP.

1.x-dev(1mo ago)18MITPHPPHP &gt;=8.4CI passing

Since May 23Pushed 1mo agoCompare

[ Source](https://github.com/resolver-interop/interface)[ Packagist](https://packagist.org/packages/resolver-interop/interface)[ Docs](https://github.com/resolver-interop/interface)[ RSS](/packages/resolver-interop-interface/feed)WikiDiscussions 1.x Synced today

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Resolver-Interop Standard Interface Package
===========================================

[](#resolver-interop-standard-interface-package)

Resolver-Interop provides an interoperable package of standard interfaces for autowiring resolver functionality. It reflects, refines, and reconciles the common practices identified within [several pre-existing projects](./README-RESEARCH.md).

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://www.rfc-editor.org/info/bcp14) ([RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119), [RFC 8174](https://datatracker.ietf.org/doc/html/rfc8174)).

Interfaces
----------

[](#interfaces)

This package defines the following interfaces:

- [*ClassResolver*](#classresolver) affords resolving a class to a new instance, and indicating whether a class may be resolved at all.
- [*ReflectionParametersResolver*](#reflectionparametersresolver) affords resolving an array of [*ReflectionParameter*](https://php.net/ReflectionParameter) instances into an array of arguments.
- [*ReflectionParameterResolver*](#reflectionparameterresolver) affords resolving a [*ReflectionParameter*](https://php.net/ReflectionParameter) to an argument value.
- [*ReflectionTypeResolver*](#reflectiontyperesolver) affords resolving a [*ReflectionType*](https://php.net/ReflectionType) to a `string` name, or `null` if it cannot be resolved.
- [*ReflectionMethodsResolver*](#reflectionmethodsresolver) affords instantiating and invoking [*ReflectionMethodResolver*](#reflectionmethodresolver) attributes on object methods.
- [*ReflectionMethodResolver*](#reflectionmethodresolver) affords method injection when implemented on a method-targeted [*Attribute*](https://php.net/Attribute).
- [*ReflectionPropertiesResolver*](#reflectionpropertiesresolver) affords instantiating and invoking [*ReflectionPropertyResolver*](#reflectionpropertyresolver) attributes on object properties.
- [*ReflectionPropertyResolver*](#reflectionpropertyresolver) affords property injection when implemented on a property-targeted [*Attribute*](https://php.net/Attribute).
- [*CallResolver*](#callresolver) affords resolving a callable's parameters and invoking it, returning the call's result.
- [*Resolvable*](#resolvable) affords an implementing object the ability to resolve itself to a value.
- [*ResolverThrowable*](#resolverthrowable) extends [*Throwable*](https://php.net/Throwable) to mark an [*Exception*](https://php.net/Exception) as resolver-related.

### *ClassResolver*

[](#classresolver)

[*ClassResolver*](#classresolver) affords resolving a class to a new instance, and indicating whether a class may be resolved at all.

#### *ClassResolver* Methods

[](#classresolver-methods)

- ```
    public function resolveClass(
        IocInterop\Interface\IocContainer $ioc,
        class-string $class,
        mixed[] $arguments = [],
    ) : T;
    ```

    - Resolves the `$class` to return a new instance.
    - Directives:

        - Implementations MUST resolve the `$class` constructor parameters using logic identical to that specified by [*ReflectionParametersResolver*](#reflectionparametersresolver).
        - Implementations MAY support property injection using logic identical to that specified by [*ReflectionPropertiesResolver*](#reflectionpropertiesresolver).
        - Implementations MAY support method injection using logic identical to that specified by [*ReflectionMethodsResolver*](#reflectionmethodsresolver).
        - Implementations MAY support other forms of injection not specified herein.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if the `$class`cannot be resolved.
- ```
    public function mayResolveClass(string $class) : bool;
    ```

    - May the resolver attempt to resolve `$class`?
    - Notes:

        - **The logic for this method is expressly unspecified.**Implementations may check `class_exists` and `ReflectionClass::isInstantiable()`, or apply stricter rules; e.g., requiring a registered service-name alias, rejecting abstract bases that lack a concrete binding, or excluding PHP-internal classes. Consumers should treat a `true` result as "the implementation is willing to try `resolveClass()`", not as a guarantee that resolution will succeed.

### *ReflectionParametersResolver*

[](#reflectionparametersresolver)

[*ReflectionParametersResolver*](#reflectionparametersresolver) affords resolving an array of [*ReflectionParameter*](https://php.net/ReflectionParameter) instances into an array of arguments.

#### *ReflectionParametersResolver* Methods

[](#reflectionparametersresolver-methods)

- ```
    public function resolveParameters(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionParameter[] $parameters,
        mixed[] $arguments = [],
    ) : mixed[];
    ```

    - Resolves the `$parameters` into the `$arguments`.
    - Directives:

        - Implementations MUST NOT attempt to resolve a [*ReflectionParameter*](https://php.net/ReflectionParameter) whose name or position already exists in the `$arguments` keys.
        - When resolving a [*ReflectionParameter*](https://php.net/ReflectionParameter) to an argument, implementations MUST do so using logic identical to that specified by [*ReflectionParameterResolver*](#reflectionparameterresolver).
        - Implementations MUST retain each resolved [*ReflectionParameter*](https://php.net/ReflectionParameter)by name in the `$arguments`.
        - Implementations MUST `resolve()` every [*Resolvable*](#resolvable) at the top level of the `$arguments` array.
    - Notes:

        - **Mixed name and position keys for the same parameter in the `$arguments` pass through unchanged.** Named and positional keys referring to the same parameters are preseved in the returned array as-is.
        - **Extra and out-of-range keys in `$arguments` pass through unchanged.** Keys that do not correspond to any parameter name or position, and positional keys whose integer index exceeds the parameter count, are preserved in the returned array as-is.
        - **Resolved parameters are retained by name.** Pre-filled positional arguments retain their integer keys; newly-resolved parameters are keyed on their parameter name, not their position.
        - **Resolve all `$arguments`.** Callers might pass one or more [*Resolvable*](#resolvable) as an argument; the implementation has to resolve them before returning.

### *ReflectionParameterResolver*

[](#reflectionparameterresolver)

[*ReflectionParameterResolver*](#reflectionparameterresolver) affords resolving a [*ReflectionParameter*](https://php.net/ReflectionParameter) to an argument value.

This interface is also suitable for implementation on an [*Attribute*](https://php.net/Attribute) to resolve a custom argument on a parameter.

- Directives:

    - An [*Attribute*](https://php.net/Attribute) implementing this interface MUST NOT be declared with `Attribute::IS_REPEATABLE`.

#### *ReflectionParameterResolver* Methods

[](#reflectionparameterresolver-methods)

- ```
    public function resolveParameter(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionParameter $parameter,
    ) : mixed;
    ```

    - Resolves the [*ReflectionParameter*](https://php.net/ReflectionParameter) to an argument value.
    - Directives:

        - Implementations MUST resolve the `$parameter` in this order:

            - If the `$parameter` has one or more [*Attribute*](https://php.net/Attribute) that implements [*ReflectionParameterResolver*](#reflectionparameterresolver), implementations MUST resolve the `$parameter` using only the first such [*Attribute*](https://php.net/Attribute).
            - Otherwise, if the `$parameter` type is resolvable using logic identical to [*ReflectionTypeResolver*](#reflectiontyperesolver) **and**`$ioc->hasService()` returns `true` for that resolved type, implementations MUST resolve the `$parameter` to that service via `$ioc->getService()`.
            - Otherwise, implementations MAY attempt to resolve the `$parameter` using implementation-specific logic; such logic is not defined herein.
            - Otherwise, if the `$parameter` has a default value, implementations MUST resolve the `$parameter` to that value.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if the `$parameter` cannot be resolved.
    - Notes:

        - **Variadic parameters resolve to a single value.** Implementations resolve a variadic `$parameter` once (via attribute, type, or default) and return that value as the variadic argument. Spreading across multiple variadic slots is not specified by this interface.

### *ReflectionTypeResolver*

[](#reflectiontyperesolver)

[*ReflectionTypeResolver*](#reflectiontyperesolver) affords resolving a [*ReflectionType*](https://php.net/ReflectionType) to a `string` name, or `null` if it cannot be resolved.

#### *ReflectionTypeResolver* Methods

[](#reflectiontyperesolver-methods)

- ```
    public function resolveType(
        IocInterop\Interface\IocContainer $ioc,
        ?ReflectionType $type,
    ) : ?string;
    ```

    - Resolves a [*ReflectionType*](https://php.net/ReflectionType) to a `string` name, or `null` if it cannot be resolved.
    - Directives:

        - If `$type` is `null`, implementations MUST return `null`.
        - Otherwise, if `$type` is a [*ReflectionNamedType*](https://php.net/ReflectionNamedType), implementations MUST return the type name as produced by its `getName()` method.
        - Otherwise, the logic for determining the return type name is implementation-defined.
    - Notes:

        - **Compound and other type handling is left to the implementation.**For example, [*ReflectionUnionType*](https://php.net/ReflectionUnionType) and [*ReflectionIntersectionType*](https://php.net/ReflectionIntersectionType) handling may vary between implementations: one might iterate the branches and return the first whose name corresponds to an `$ioc` service name; another might return the compound stringification (e.g. `"Foo|Bar"`) and let the container lookup handle it; yet another might return `null`out of hand.

### *ReflectionMethodsResolver*

[](#reflectionmethodsresolver)

[*ReflectionMethodsResolver*](#reflectionmethodsresolver) affords instantiating and invoking [*ReflectionMethodResolver*](#reflectionmethodresolver) attributes on object methods.

#### *ReflectionMethodsResolver* Methods

[](#reflectionmethodsresolver-methods)

- ```
    public function resolveMethods(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionMethod[] $methods,
        object $object,
    ) : void;
    ```

    - Invokes the attributed `$methods` on the `$object`.
    - Directives:

        - For each [*ReflectionMethod*](https://php.net/ReflectionMethod) in `$methods` that carries one or more [*Attribute*](https://php.net/Attribute) implementing [*ReflectionMethodResolver*](#reflectionmethodresolver), implementations MUST invoke only the first such [*Attribute*](https://php.net/Attribute).
        - Implementations MUST NOT invoke un-attributed methods.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if resolution fails.

### *ReflectionMethodResolver*

[](#reflectionmethodresolver)

[*ReflectionMethodResolver*](#reflectionmethodresolver) affords method injection when implemented on a method-targeted [*Attribute*](https://php.net/Attribute).

- Directives:

    - An [*Attribute*](https://php.net/Attribute) implementing this interface MUST NOT be declared with `Attribute::IS_REPEATABLE`.

#### *ReflectionMethodResolver* Methods

[](#reflectionmethodresolver-methods)

- ```
    public function resolveMethod(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionMethod $method,
        object $object,
    ) : void;
    ```

    - Invokes the [*ReflectionMethod*](https://php.net/ReflectionMethod) on the `$object`.
    - Directives:

        - Implementations MUST support parameter injection using logic identical to that specified by [*ReflectionParametersResolver*](#reflectionparametersresolver).
        - Implementations MUST invoke `$method` on `$object` with the resolved arguments.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if resolution fails.

### *ReflectionPropertiesResolver*

[](#reflectionpropertiesresolver)

[*ReflectionPropertiesResolver*](#reflectionpropertiesresolver) affords instantiating and invoking [*ReflectionPropertyResolver*](#reflectionpropertyresolver) attributes on object properties.

#### *ReflectionPropertiesResolver* Methods

[](#reflectionpropertiesresolver-methods)

- ```
    public function resolveProperties(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionProperty[] $properties,
        object $object,
    ) : void;
    ```

    - Resolves the attributed `$properties` on the `$object`.
    - Directives:

        - For each [*ReflectionProperty*](https://php.net/ReflectionProperty) in `$properties` that carries one or more [*Attribute*](https://php.net/Attribute) implementing [*ReflectionPropertyResolver*](#reflectionpropertyresolver), implementations MUST resolve the property using only the first such [*Attribute*](https://php.net/Attribute).
        - Implementations MUST leave un-attributed properties unchanged.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if any attempted resolution fails.

### *ReflectionPropertyResolver*

[](#reflectionpropertyresolver)

[*ReflectionPropertyResolver*](#reflectionpropertyresolver) affords property injection when implemented on a property-targeted [*Attribute*](https://php.net/Attribute).

- Directives:

    - An [*Attribute*](https://php.net/Attribute) implementing this interface MUST NOT be declared with `Attribute::IS_REPEATABLE`.

#### *ReflectionPropertyResolver* Methods

[](#reflectionpropertyresolver-methods)

- ```
    public function resolveProperty(
        IocInterop\Interface\IocContainer $ioc,
        ReflectionProperty $property,
        object $object,
    ) : void;
    ```

    - Sets the [*ReflectionProperty*](https://php.net/ReflectionProperty) on an object.
    - Directives:

        - Implementations MUST resolve the `$property` in this order:

            - Implementations MAY attempt to resolve the `$property` using implementation-specific logic; such logic is not defined herein.
            - Otherwise, implementations MUST resolve the `$property` to the [*IocContainer*](https://github.com/ioc-interop/interface/#ioccontainer) service whose name matches the property type as produced by [*ReflectionTypeResolver*](#reflectiontyperesolver), via `$ioc->getService()`.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if resolution of `$property` is attempted and fails.

### *CallResolver*

[](#callresolver)

[*CallResolver*](#callresolver) affords resolving a callable's parameters and invoking it, returning the call's result.

#### *CallResolver* Methods

[](#callresolver-methods)

- ```
    public function resolveCall(
        IocInterop\Interface\IocContainer $ioc,
        callable $callable,
        mixed[] $arguments = [],
    ) : mixed;
    ```

    - Resolves the `$callable` to return its result.
    - Directives:

        - Implementations MUST resolve the `$callable`'s parameters using logic identical to that specified by [*ReflectionParametersResolver*](#reflectionparametersresolver)'s `resolveParameters()`, including the `$arguments` pre-fill and [*Resolvable*](#resolvable)-unwrap semantics specified there.
        - Implementations MUST invoke the `$callable` with the resolved `$arguments` and MUST return the result of that invocation.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if the `$callable` cannot be resolved.

### *Resolvable*

[](#resolvable)

[*Resolvable*](#resolvable) affords an implementing object the ability to resolve itself to a value.

- Notes:

    - **`Resolvable` defers container calls until the moment of resolution.**Wrapping a container call in a `Resolvable` lets the implmenting object be pass around without forcing the container interation at construction time.

#### *Resolvable* Methods

[](#resolvable-methods)

- ```
    public function resolve(IocInterop\Interface\IocContainer $ioc) : mixed;
    ```

    - Resolves the implementing object to a value.
    - Directives:

        - Implementations MUST return a value that is neither itself a [*Resolvable*](#resolvable) nor contains any [*Resolvable*](#resolvable) instances.
        - Implementations MUST throw [*ResolverThrowable*](#resolverthrowable) if the object cannot be resolved.
    - Notes:

        - **Resolve recursively as needed.** Some implementations may return arrays or objects; the implementation might need to check their contents for other [*Resolvable*](#resolvable) instances so that the return value is fully and deeply resolved.

### *ResolverThrowable*

[](#resolverthrowable)

[*ResolverThrowable*](#resolverthrowable) extends [*Throwable*](https://php.net/Throwable) to mark an [*Exception*](https://php.net/Exception) as resolver-related.

It adds no class members.

Implementations
---------------

[](#implementations)

- Directives:

    - Implementations MAY define additional class members not defined in these interfaces.
- Notes:

    - **Reference implementations** may be found at .

Q &amp; A
---------

[](#q--a)

### Why are there so many interfaces?

[](#why-are-there-so-many-interfaces)

The researched projects typically afford autowiring through a single container class with several methods (`get()`, `make()`, `call()`, and so on), each performing a distinct resolution task.

Resolver-Interop opts to split those operations into separate interfaces. Doing so allows consumers to depend only on the specific methods they need, and implementors to combine them as they see fit.

### Why are setter-injection and property-injection supported?

[](#why-are-setter-injection-and-property-injection-supported)

Constructor injection is the documented default across all the researched projects. Setter-injection is generally supported, whereas property-injection is far less common.

Resolver-Interop summarizes this guidance evident from the projects:

- constructor injection is preferred above all;
- but sometimes setter-injection is unavoidable, especially in legacy or refactoring scenarios;
- and while property-injection is to be shunned prejudicially, having it available as an absolute last resort can be useful.

Thus, while Resolver-Interop does not forbid post-construction injection, it attempts to make explicit the appropriate scope for these alternative forms of injection.

---

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance91

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

42d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25754?v=4)[Paul M. Jones](/maintainers/pmjones)[@pmjones](https://github.com/pmjones)

---

Top Contributors

[![pmjones](https://avatars.githubusercontent.com/u/25754?v=4)](https://github.com/pmjones "pmjones (6 commits)")

---

Tags

Autowiringresolverautowire

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/resolver-interop-interface/health.svg)

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

###  Alternatives

[dflydev/placeholder-resolver

Given a data source representing key =&gt; value pairs, resolve placeholders like ${foo.bar} to the value associated with the 'foo.bar' key in the data source.

14414.6M3](/packages/dflydev-placeholder-resolver)[rybakit/arguments-resolver

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

26112.9k7](/packages/rybakit-arguments-resolver)[jeroen-g/autowire

Autowire and configure using PHP 8 Attributes in Laravel.

2320.3k](/packages/jeroen-g-autowire)[sroze/argument-resolver

A lightweight utility to resolve method arguments based on types and names

1042.9k1](/packages/sroze-argument-resolver)[acelot/resolver

Dependency auto resolver for PHP 7 and 8

122.7k](/packages/acelot-resolver)

PHPackages © 2026

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