Aggiornato Composer
This commit is contained in:
13
vendor/symfony/mime/Part/DataPart.php
vendored
13
vendor/symfony/mime/Part/DataPart.php
vendored
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user