From f9526adda1f5b26a2390f60b34b321c76e461f1c Mon Sep 17 00:00:00 2001 From: thePanz Date: Thu, 15 Aug 2024 17:37:41 +0200 Subject: [PATCH 1/4] Increase PHP requirements to v7.4 or v8.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 944a35bb6..ba667df7e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": ">=5.3.3" + "php": "^7.4 || ^8.0" }, "require-dev": { "mockery/mockery": "~0.9.1", From fc839dd14efa99a456967ff1fa62095a21488ce1 Mon Sep 17 00:00:00 2001 From: thePanz Date: Thu, 15 Aug 2024 17:48:14 +0200 Subject: [PATCH 2/4] Fix deprecations on returned parameters from annotations --- lib/classes/Swift/Encoder/QpEncoder.php | 6 +++--- .../ContentEncoder/QpContentEncoderProxy.php | 21 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/classes/Swift/Encoder/QpEncoder.php b/lib/classes/Swift/Encoder/QpEncoder.php index edec10c51..164f979fa 100644 --- a/lib/classes/Swift/Encoder/QpEncoder.php +++ b/lib/classes/Swift/Encoder/QpEncoder.php @@ -153,9 +153,9 @@ protected function initSafeMap() * If the first line needs to be shorter, indicate the difference with * $firstLineOffset. * - * @param string $string to encode - * @param int $firstLineOffset, optional - * @param int $maxLineLength, optional 0 indicates the default of 76 chars + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars * * @return string */ diff --git a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index 3214e1cf3..72aa9fc46 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -56,7 +56,9 @@ public function __clone() } /** - * {@inheritdoc} + * Notify this observer that the entity's charset has changed. + * + * @param string $charset */ public function charsetChanged($charset) { @@ -65,7 +67,12 @@ public function charsetChanged($charset) } /** - * {@inheritdoc} + * Encode $in to $out. + * + * @param Swift_OutputByteStream $os to read from + * @param Swift_InputByteStream $is to write to + * @param int $firstLineOffset + * @param int $maxLineLength - 0 indicates the default length for this encoding */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { @@ -73,7 +80,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } /** - * {@inheritdoc} + * @return string */ public function getName() { @@ -81,7 +88,13 @@ public function getName() } /** - * {@inheritdoc} + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength - 0 means no wrapping will occur + * + * @return string */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { From ce56d6708f1e33e305a1ea98057f42c367b53c42 Mon Sep 17 00:00:00 2001 From: thePanz Date: Thu, 15 Aug 2024 17:58:38 +0200 Subject: [PATCH 3/4] Fix deprecations for return types in Swift_KeyCache_SimpleKeyCacheInputStream::write() --- .../KeyCache/SimpleKeyCacheInputStream.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index b00d458a6..68fc7edb3 100644 --- a/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -15,16 +15,22 @@ */ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { - /** The KeyCache being written to */ + /** + * @var Swift_KeyCache The KeyCache being written to + */ private $_keyCache; - /** The nsKey of the KeyCache being written to */ + /** + * @var string The nsKey of the KeyCache being written to + */ private $_nsKey; /** The itemKey of the KeyCache being written to */ private $_itemKey; - /** A stream to write through on each write() */ + /** + * @var Swift_InputByteStream|null A stream to write through on each write() + */ private $_writeThrough = null; /** @@ -51,18 +57,23 @@ public function setWriteThroughStream(Swift_InputByteStream $is) * Writes $bytes to the end of the stream. * * @param string $bytes - * @param Swift_InputByteStream $is optional + * @param ?Swift_InputByteStream $is + * + * @throws Swift_IoException + * + * @return int */ public function write($bytes, Swift_InputByteStream $is = null) { $this->_keyCache->setString( $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND - ); + ); + if (isset($is)) { - $is->write($bytes); + return $is->write($bytes); } if (isset($this->_writeThrough)) { - $this->_writeThrough->write($bytes); + return $this->_writeThrough->write($bytes); } } From 9f1b197394edf4c1474b6da7ee441b5fc9aa3c8f Mon Sep 17 00:00:00 2001 From: thePanz Date: Thu, 15 Aug 2024 18:11:41 +0200 Subject: [PATCH 4/4] Fix strtolower() deprecation when invoked with NULL --- lib/classes/Swift/Transport/Esmtp/AuthHandler.php | 4 ++-- lib/classes/Swift/Transport/EsmtpTransport.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index cb36133c9..e0c7395f9 100644 --- a/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -39,7 +39,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler /** * The auth mode for authentication. * - * @var string + * @var string|null */ private $_auth_mode; @@ -248,7 +248,7 @@ public function resetState() */ protected function _getAuthenticatorsForAgent() { - if (!$mode = strtolower($this->_auth_mode)) { + if (!$this->_auth_mode || !$mode = strtolower($this->_auth_mode)) { return $this->_authenticators; } diff --git a/lib/classes/Swift/Transport/EsmtpTransport.php b/lib/classes/Swift/Transport/EsmtpTransport.php index 156e2cf5b..5fef33e30 100644 --- a/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/lib/classes/Swift/Transport/EsmtpTransport.php @@ -134,18 +134,18 @@ public function getTimeout() /** * Set the encryption type (tls or ssl). * - * @param string $encryption + * @param string|null $encryption * * @return $this */ public function setEncryption($encryption) { - $encryption = strtolower($encryption); - if ('tls' == $encryption) { + $normalizedEncryption = $encryption ? strtolower($encryption) : ''; + if ('tls' === $normalizedEncryption) { $this->_params['protocol'] = 'tcp'; $this->_params['tls'] = true; } else { - $this->_params['protocol'] = $encryption; + $this->_params['protocol'] = $normalizedEncryption; $this->_params['tls'] = false; }