Form APIs should not be enforcing generic types that have been rejected in Symfony because of being wrong
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by locating the FormTypeInterface and createForm stubs that define the disputed generic types, then read the linked Symfony discussion and existing extension tests. Done means the rejected generic assumptions are no longer enforced, or their loading is made conditional, with tests covering the chosen behavior.
Written by the indexing model from the issue text.
Description
Generic types for FormTypeInterface and the various createForm methods have been rejected in Symfony because they are lying about the actual behavior of the form component. Those generic types allow to have a nice inferred type for the basic usage of the component, but they will analyze advanced usages of the component in a broken way (reporting errors on valid code, inferring wrong types due to making wrong assumptions about how the component actually works).
See https://github.com/symfony/symfony/pull/40783#issuecomment-942470623 for the discussion when those generic types were submitted upstream.
In version 1.x of the extension, those generic types were configured in skipCheckGenericClasses, which allowed projects to mostly ignore the fact that the extension stubs were adding it. In 2.0x, this is not the case anymore so phpstan will enforce that any form type defines such generic type to satisfy the extension, even when being aware that those generic types are a lie.
My opinion is that those stubs should be removed to match the decision done in Symfony. However, I would also accept a case where the loading of those simplistic generic types is conditional, allowing projects to decide whether they want them (if they rely only on the basic usage pattern where the inference would produce a good result) or not (if they want the analysis to stick to the true behavior of the component).
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-symfony
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
phpstan/phpstan-symfony#510 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
phpstan/phpstan-symfony#494 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
phpstan/phpstan-symfony#268 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
phpstan/phpstan-symfony#509 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
phpstan/phpstan-symfony#466 · 4 comments ·
All issues in phpstan/phpstan-symfony
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·