Support typed autowiring of two parameters in form handlers #345
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.
Purpose
The goal of this PR is to replace the existing hybrid autowiring logic for form handler parameters, which currently autowires by type (for a single parameter) or by position (for two parameters), with fully typed autowiring, where parameter order is irrelevant.
Implementation
The proposed changes introduce a parallel autowiring path that complements the existing logic without modifying it directly.
Unexpected behavior occurs with the following handler method signatures:
In these cases, the provided parameter types consistently result in an Error, and the handler method is never invoked, regardless of the code of the handler itself.
By handling these three parameter combinations within the newly introduced parallel logic path, this change remains 100% backward compatible.
Benefits
Nette developers are accustomed to type-based autowiring through DI, where parameter order doesn't matter. This proposal extends that principle to form handlers in a safe and modern way, aligning with the conventions of contemporary frameworks by enabling full type-based autowiring without relying on parameter sequence.
The proposed solution is currently being discussedon: nette forum