Add type mapping support for container ID override
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
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.
Description
The Resolver resolves parameters by looking up types directly in the container using ->get(). This doesn't work when:
- Multiple implementations of an interface exist in the container, and you need to specify which one
- 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.
- Dominant language
- PHP
- Stars
- 0
- Forks
- 1
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Respect/Parameter
-
Roadmap for 4.0 Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in Respect/Parameter
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·