Update dependencies

This commit is contained in:
Kode
2022-06-29 13:20:08 +01:00
parent bbae811cd8
commit e2ba89c80e
349 changed files with 21017 additions and 4079 deletions

View File

@@ -28,7 +28,7 @@ final class DkimOptions
/**
* @return $this
*/
public function algorithm(int $algo): self
public function algorithm(string $algo): self
{
$this->options['algorithm'] = $algo;

View File

@@ -272,12 +272,16 @@ class Email extends Message
}
/**
* @param resource|string $body
* @param resource|string|null $body
*
* @return $this
*/
public function text($body, string $charset = 'utf-8')
{
if (null !== $body && !\is_string($body) && !\is_resource($body)) {
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
}
$this->text = $body;
$this->textCharset = $charset;
@@ -304,6 +308,10 @@ class Email extends Message
*/
public function html($body, string $charset = 'utf-8')
{
if (null !== $body && !\is_string($body) && !\is_resource($body)) {
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
}
$this->html = $body;
$this->htmlCharset = $charset;
@@ -330,6 +338,10 @@ class Email extends Message
*/
public function attach($body, string $name = null, string $contentType = null)
{
if (!\is_string($body) && !\is_resource($body)) {
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
}
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => false];
return $this;
@@ -352,6 +364,10 @@ class Email extends Message
*/
public function embed($body, string $name = null, string $contentType = null)
{
if (!\is_string($body) && !\is_resource($body)) {
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
}
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => true];
return $this;
@@ -463,7 +479,7 @@ class Email extends Message
$names = [];
$htmlPart = null;
$html = $this->html;
if (null !== $this->html) {
if (null !== $html) {
$htmlPart = new TextPart($html, $this->htmlCharset, 'html');
$html = $htmlPart->getBody();
preg_match_all('(<img\s+[^>]*src\s*=\s*(?:([\'"])cid:([^"]+)\\1|cid:([^>\s]+)))i', $html, $names);

View File

@@ -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

@@ -55,12 +55,14 @@ final class EmailHeaderSame extends Constraint
*/
protected function failureDescription($message): string
{
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message));
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message) ?? 'null');
}
private function getHeaderValue($message): string
private function getHeaderValue($message): ?string
{
$header = $message->getHeaders()->get($this->headerName);
if (null === $header = $message->getHeaders()->get($this->headerName)) {
return null;
}
return $header instanceof UnstructuredHeader ? $header->getValue() : $header->getBodyAsString();
}