Repository navigation
Add createBuilder() and createNamedBuilder() to the FormFactoryInterface stub - #516
Merged
Merged
Conversation
Contributor
|
I am not a symfony expert. do these newly added method types hold across all supported symfony versions of phpstan-symfony? //cc @SanderMuller |
VincentLanglet
approved these changes
Oct 25, 2026
|
Yes. I checked The new tests pass with lowest (symfony/form 5.4.0) and highest (6.4.48) dependencies, and fail without the stub change. I also checked the default |
Contributor
|
Thank you! |
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.
Closes #445
The stub only declared
create()andcreateNamed(), so the builder methods fell back to Symfony's own signature and returned a plainFormBuilderInterface, withmixeddata. They now carry the same templates as theircreate*()counterparts and returnFormBuilderInterface<TData>(or<null|TData>without data), so$builder->getData()and$builder->getForm()keep the data type of the form type.One limit worth knowing: like
create(), this only helps with a generic form type (AbstractType<Foo>). With the coreFormType::classfrom the issue,TDatastaysmixed, exactly ascreate(FormType::class, new Foo())does today.createForProperty()andcreateBuilderForProperty()are left alone, since there is no form type to take the data type from.