Commit 8804980
committed
minor symfony#59061 [Mime] Fix wrong PHPDoc in
This PR was merged into the 6.4 branch.
Discussion
----------
[Mime] Fix wrong PHPDoc in `FormDataPart` constructor
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License | MIT
I believe the PHPDoc is wrong.
As far as I understand, the `FormDataPart` expects instances of `TextPart`:
```php
if (!\is_string($item) && !$item instanceof TextPart) {
throw new InvalidArgumentException(sprintf('The value of the form field "%s" can only be a string, an array, or an instance of TextPart, "%s" given.', $fieldName, get_debug_type($item)));
}
```
https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php#L74
The following code is rejected by PHPStan while it works:
```php
final readonly class Foo
{
public function bar(): void
{
new FormDataPart([
new TextPart('baz'),
]);
}
}
```
```shell
------ -------------------------------------------------------------------------------------------------------------------
Line src/Foo.php
------ -------------------------------------------------------------------------------------------------------------------
14 Parameter symfony#1 $fields of class Symfony\Component\Mime\Part\Multipart\FormDataPart constructor expects
array<array|string|Symfony\Component\Mime\Part\DataPart>, array<int, Symfony\Component\Mime\Part\TextPart> given.
------ -------------------------------------------------------------------------------------------------------------------
```
(cc `@B`-Galati)
Commits
-------
886d4ed [Mime] Fix wrong PHPDoc in `FormDataPart` constructorFormDataPart constructor (MaximePinot)1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments