Skip to content

Support typed autowiring of two parameters in form handlers #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mildabre
Copy link
Contributor

@mildabre mildabre commented Jul 22, 2025

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:

protected function formSucceeded(ArrayHash $values, Form $form) {}
protected function formSucceeded(array $values, Form $form) {}
protected function formSucceeded(stdClass $values, Form $form) {}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant