`FormBuilderInterface::getForm()` should not return `FormInterface<TData|null>`, but `FormInterface<TData>`?

Open
#466 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
php
Domain
tooling

Research direction

Start with stubs/Symfony/Component/Form/FormBuilderInterface.stub, especially lines 14–17, and compare its generic return type with Symfony's FormBuilderInterface contract and the stated FormInterface usage. The work is done when the stub accurately models getForm() for a FormBuilderInterface without incorrectly propagating null, with the relevant project checks passing.

Written by the indexing model from the issue text.

Description

I think https://github.com/phpstan/phpstan-symfony/blob/2.0.x/stubs/Symfony/Component/Form/FormBuilderInterface.stub#L14-L17 is wrong: when I'm carrying around a FormBuilderInterface<SomeModel>, I would expect to build a form for a function that receives FormInterface<SomeModel>.

Indeed, then FormInterface::getData() would return SomeModel|null, but that would not be a requirement for FormBuilderInterface::getForm() to return FormInterface<SomeModel|null>. But maybe I'm missing something obvious here!

Dominant language
PHP
Stars
800
Forks
104
Avg merge
4m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-symfony

All issues in phpstan/phpstan-symfony

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.