Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/PhpImap/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use const IMAP_WRITETIMEOUT;
use InvalidArgumentException;
use const NIL;
use const PHP_MAJOR_VERSION;
use PhpImap\Exceptions\ConnectionException;
use const SE_FREE;
use const SORTARRIVAL;
Expand Down Expand Up @@ -911,11 +912,18 @@ public static function sort(
\imap_errors(); // flush errors

$imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
$reverse = $reverse;

/** @var int */
$criteria = $criteria;

if (PHP_MAJOR_VERSION < 8) {
/** @var int */
$reverse = (int) $reverse;
} else {
/** @var bool */
$reverse = $reverse;
}

if (null !== $search_criteria && null !== $charset) {
$result = \imap_sort(
$imap_stream,
Expand Down