8000 minor #59061 [Mime] Fix wrong PHPDoc in `FormDataPart` constructor (M… · symfony/symfony@8804980 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8804980

Browse files
minor #59061 [Mime] Fix wrong PHPDoc in FormDataPart constructor (MaximePinot)
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 #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` constructor
2 parents ffc4dc6 + 886d4ed commit 8804980

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class FormDataPart extends AbstractMultipartPart
2626
private array $fields = [];
2727

2828
/**
29-
* @param array<string|array|DataPart> $fields
29+
* @param array<string|array|TextPart> $fields
3030
*/
3131
public function __construct(array $fields = [])
3232
{

0 commit comments

Comments
 (0)
0