This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -29,7 +29,7 @@ class DataPart extends TextPart
/**
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
*/
public function __construct($body, string $filename = null, string $contentType = null, string $encoding = null)
public function __construct($body, ?string $filename = null, ?string $contentType = null, ?string $encoding = null)
{
if ($body instanceof File && !$filename) {
$filename = $body->getFilename();
@@ -47,7 +47,7 @@ class DataPart extends TextPart
$this->setDisposition('attachment');
}
public static function fromPath(string $path, string $name = null, string $contentType = null): self
public static function fromPath(string $path, ?string $name = null, ?string $contentType = null): self
{
return new self(new File($path), $name, $contentType);
}

View File

@@ -13,7 +13,6 @@ namespace Symfony\Component\Mime\Part\Multipart;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Part\AbstractMultipartPart;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\TextPart;
/**
@@ -26,7 +25,7 @@ final class FormDataPart extends AbstractMultipartPart
private array $fields = [];
/**
* @param array<string|array|DataPart> $fields
* @param array<string|array|TextPart> $fields
*/
public function __construct(array $fields = [])
{

View File

@@ -40,7 +40,7 @@ class TextPart extends AbstractPart
/**
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
*/
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', string $encoding = null)
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', ?string $encoding = null)
{
parent::__construct();
@@ -123,7 +123,11 @@ class TextPart extends AbstractPart
public function getBody(): string
{
if ($this->body instanceof File) {
return file_get_contents($this->body->getPath());
if (false === $ret = @file_get_contents($this->body->getPath())) {
throw new InvalidArgumentException(error_get_last()['message']);
}
return $ret;
}
if (null === $this->seekable) {