-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Multiplier::validate(): Filter out non-validatable components #103
Merged
Conversation
This file contains 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
jtojnar
force-pushed
the
validate-filter
branch
from
March 21, 2024 00:22
45fc736
to
870c70b
Compare
jtojnar
force-pushed
the
validate-filter
branch
from
April 17, 2024 17:17
870c70b
to
6932abf
Compare
The PHPStan issue is caused by phpstan/phpstan-nette#141 |
Any progress in here? |
Still blocked on the PHPStan issue IIRC. Might need to put it to ignore list. |
jtojnar
force-pushed
the
validate-filter
branch
from
January 11, 2025 10:41
94ed718
to
07d1426
Compare
45ed76a started filtering components to `Control`s, to appease PHPStan, since `Container::validate()` only accepted `Control[]`. But `Multiplier` does not actually have `Control`s as direct children (other than the ‘Add’ `Submitter`s), so it would stop validating and filtering multiplied controls. a5a7348 reverted that part but kept the incorrect phpdoc type cast. Now, it works without the filter because `Container::validate()` already ignores non-validatable components but we should still respect its contract. Let’s filter the components before passing them down. This will also allow us to drop the lying phpdoc type cast. nette/forms 3.2.2 updated its phpdoc param type to allow that: nette/forms@6437671
Filters are used for converting an input value (usually a string) into a domain specific PHP type and they are bound to the validation scope: https://doc.nette.org/en/forms/validation#toc-modifying-input-values 45ed76a started filtering components passed to `Container::validate()` to `Control`s, to appease PHPStan. But `Multiplier` does not actually have `Control`s as direct children (other than the ‘Add’ `Submitter`s), so it would stop validating and filtering multiplied controls. It has been since fixed in a5a7348, and more properly in the parent commit but let’s add a test so this does not happen again. It can be reproduced by removing `|| $component instanceof Container` from the parent commit.
jtojnar
force-pushed
the
validate-filter
branch
from
January 17, 2025 23:37
07d1426
to
71b44f4
Compare
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.
45ed76a started filtering components to
Control
s, to appease PHPStan, sinceContainer::validate()
only acceptsControl[]
. ButMultiplier
does not actually haveControl
s as direct children (other than the ‘Add’Submitter
s), so it would stop validating and filtering multiplied controls.a5a7348 reverted that part but kept the incorrect phpdoc type cast.
Now, it works without the filter because
Container::validate()
already ignores non-validatable components but we should still respect its contract.Let’s filter the components before passing them down. This will also allow us to drop the lying phpdoc type cast.
Depends on nette/forms#323 for PHPStan to pass.