Respect / Respect/Parameter

Add type mapping support for container ID override

Open
#35 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
0
Forks
1
Avg merge
3d 3h
Merged PRs (30d)
6

Description

The Resolver resolves parameters by looking up types directly in the container using ->get(). This doesn't work when:

  1. Multiple implementations of an interface exist in the container, and you need to specify which one
  2. Services are registered with string aliases (e.g., 'my.favorite.animal') instead of class names

Currently there's no way to tell the Resolver "when this callable needs an Animal, look up 'my.favorite.goat' from the container."

Introduce a new interface ParameterResolverWithTypeMap extending ParameterResolver with an additional method:

interface ParameterResolverWithTypeMap extends ParameterResolver
{
    public function resolveWithTypeMap(
        ReflectionFunctionAbstract ,
        array ,
        array<string, string> 
    ): array;
}

Usage:

$args = $resolver->resolveWithTypeMap(
    $reflection,
    $arguments,
    [Animal::class => 'my.favorite.goat']
);

The Resolver class would implement both interfaces, maintaining backward compatibility.

Additional context

This approach preserves backward compatibility - existing code using ParameterResolver continues to work unchanged. Clients can build the type map externally based on their needs and pass it at call time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing ParameterResolver interface and Resolver implementation to understand how parameters are currently resolved through the container. Add the new ParameterResolverWithTypeMap contract and verify that Resolver supports both interfaces while accepting type-to-container-ID mappings. Review the existing test suite for resolver behavior and cover aliases, multiple implementations, and backward compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.