Skip to content

Commit

Permalink
Merge pull request #578 from janbarasek/patch-1
Browse files Browse the repository at this point in the history
Composer.json: Add support for PHP 8
  • Loading branch information
Sebbo94BY authored Feb 23, 2021
2 parents da6068c + 68d4666 commit 36aa169
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"sort-packages": true
},
"require": {
"php": "^7.2",
"php": "^7.2 || ^8.0 <8.1",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-imap": "*",
Expand Down
3 changes: 1 addition & 2 deletions src/PhpImap/DataPartInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ protected function convertEncodingAfterFetch(): string
{
if (isset($this->charset) and !empty(\trim($this->charset))) {
$this->data = $this->mail->decodeMimeStr(
(string) $this->data, // Data to convert
(string) \trim($this->charset)
(string) $this->data // Data to convert
);
}

Expand Down
5 changes: 2 additions & 3 deletions src/PhpImap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,14 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object
* Decodes a mime string.
*
* @param string $string MIME string to decode
* @param string|null $charsetPreferred The charset of the data part info if it was set
*
* @return string Converted string if conversion was successful, or the original string if not
*
* @throws Exception
*
* @todo update implementation pending resolution of https://github.com/vimeo/psalm/issues/2619 & https://github.com/vimeo/psalm/issues/2620
*/
public function decodeMimeStr(string $string, ?string $charsetPreferred = null): string
public function decodeMimeStr(string $string): string
{
$newString = '';
/** @var list<object{charset?:string, text?:string}>|false */
Expand All @@ -1354,7 +1353,7 @@ public function decodeMimeStr(string $string, ?string $charsetPreferred = null):
$charset = \strtolower($element->charset);

if ('default' === $charset) {
$charset = !empty($charsetPreferred) ? $charsetPreferred : $this->decodeMimeStrDefaultCharset;
$charset = $this->decodeMimeStrDefaultCharset;
}

switch ($charset) {
Expand Down

0 comments on commit 36aa169

Please sign in to comment.