Make resolve() variadic-aware and add ParameterResolver interface#30
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the parameter resolution API to return an ordered, “ready-to-splat” argument list (instead of a name-keyed array), adds support for expanding trailing variadic parameters, and introduces a ParameterResolver interface so consumers can depend on the contract rather than the concrete Resolver.
Changes:
- Changed
Resolver::resolve()to accept mixed positional/named inputs and return an orderedlist<mixed>suitable for...$args/newInstanceArgs(). - Added
ParameterResolverinterface and madeResolverimplement it; deprecatedresolveNamed()as an alias ofresolve(). - Updated tests and README to reflect the new return shape, precedence rules, and variadic behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Resolver.php |
Reworks resolution algorithm to produce ordered arguments and expand variadics; keeps resolveNamed() as deprecated alias. |
src/ParameterResolver.php |
Introduces the ParameterResolver interface exposing resolve(). |
tests/unit/ResolverTest.php |
Updates expectations for ordered return shape; adds coverage for variadics and interface implementation. |
tests/fixtures/VariadicConsumer.php |
Adds a variadic constructor fixture to exercise variadic argument expansion. |
README.md |
Documents new resolution precedence, ordered return list, variadic behavior, and interface usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
resolve() now returns an ordered, ready-to-splat list (in parameter order) instead of a name-keyed array, and expands a trailing variadic parameter into all remaining positional arguments. It also accepts named arguments directly (keyed by parameter name, taking precedence over the container), so a single algorithm handles positional, named, and variadic resolution. Add a ParameterResolver interface exposing just resolve(), so consumers can depend on the contract rather than the concrete Resolver. Resolver implements it. Deprecate resolveNamed() as a thin alias of resolve(); update the README for the new return shape, precedence, variadics, and interface.
4555624 to
cc53d0a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolve() now returns an ordered, ready-to-splat list (in parameter order) instead of a name-keyed array, and expands a trailing variadic parameter into all remaining positional arguments. It also accepts named arguments directly (keyed by parameter name, taking precedence over the container), so a single algorithm handles positional, named, and variadic resolution.
Add a ParameterResolver interface exposing just resolve(), so consumers can depend on the contract rather than the concrete Resolver. Resolver implements it.
Deprecate resolveNamed() as a thin alias of resolve(); update the README for the new return shape, precedence, variadics, and interface.