Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -33,7 +33,7 @@ class DataPart extends TextPart
/**
* @param resource|string $body
*/
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)
{
unset($this->_parent);
@@ -51,7 +51,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
{
if (null === $contentType) {
$ext = strtolower(substr($path, strrpos($path, '.') + 1));
@@ -61,13 +61,20 @@ class DataPart extends TextPart
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
}
if (false === is_readable($path)) {
if ((is_file($path) && !is_readable($path)) || is_dir($path)) {
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
}
if (false === $handle = @fopen($path, 'r', false)) {
throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path));
}
if (!is_file($path)) {
$cache = fopen('php://temp', 'r+');
stream_copy_to_stream($handle, $cache);
$handle = $cache;
}
$p = new self($handle, $name ?: basename($path), $contentType);
$p->handle = $handle;

View File

@@ -59,4 +59,17 @@ class MessagePart extends DataPart
{
return $this->message->toIterable();
}
/**
* @return array
*/
public function __sleep()
{
return ['message'];
}
public function __wakeup()
{
$this->__construct($this->message);
}
}

View File

@@ -58,7 +58,7 @@ final class FormDataPart extends AbstractMultipartPart
$values = [];
$prepare = function ($item, $key, $root = null) use (&$values, &$prepare) {
if (\is_int($key) && \is_array($item)) {
if (null === $root && \is_int($key) && \is_array($item)) {
if (1 !== \count($item)) {
throw new InvalidArgumentException(sprintf('Form field values with integer keys can only have one array element, the key being the field name and the value being the field value, %d provided.', \count($item)));
}

View File

@@ -42,7 +42,7 @@ class TextPart extends AbstractPart
/**
* @param resource|string $body
*/
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)
{
unset($this->_headers);
@@ -197,6 +197,7 @@ class TextPart extends AbstractPart
// convert resources to strings for serialization
if (null !== $this->seekable) {
$this->body = $this->getBody();
$this->seekable = null;
}
$this->_headers = $this->getHeaders();