Commit 4f3822e
committed
minor symfony#52861 [Form] Adding
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[Form] Adding ``@var`` PHPDoc to silence psalm
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes (kind of)
| New feature? | no
| Deprecations? | no
| Issues | Fix symfony#52829
| License | MIT
The goal is to add some PHPDoc to silence the psalm warnings mentioned in the linked issue, without changing the actual type hint (would be a BC break).
I found three ways to achieve this:
* Adding ``@var`` to the variable *in the next line*. That's what I'm doing in this PR. The idea is taken from https://stackoverflow.com/a/46842721/1668200 . It looks weird, but it's only a small change...
* Adding ``@param`` above the anonymous function. Would require to move it to a new line and subsequently indent the following ~50 lines:
```php
$builder->addEventListener(FormEvents::PRE_SUBMIT,
/** `@param` PreSubmitEvent $event */
static function (FormEvent $event) use ($choiceList, $options, &$unknownValues) {
// ...
}
);
```
* Refactoring by extracting the anonymous callback function to a dedicated method.
Waiting for feedback here, then I'll do the same in [`TimeType`](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php#L64) and [`FileType`](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Form/Extension/Core/Type/FileType.php#L50)
Commits
-------
d364472 [Form] Adding ``@var`` PHPDoc to silence psalm@var PHPDoc to silence psalm (ThomasLandauer)File tree
1 file changed
+2
-0
lines changed- src/Symfony/Component/Form/Extension/Core/Type
1 file changed
+2
-0
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
0 commit comments