From f1e316bf93a99bfc8ba29b19f4980b0ea7dda363 Mon Sep 17 00:00:00 2001 From: Andrey Lebedev Date: Thu, 17 Feb 2022 13:35:06 +0300 Subject: [PATCH] BUG: An argument $reverse of method \PhpImap\Imap::sort() has type boolean from PHP version 8 only (#659) BUG: And argument $reverse of method \PhpImap\Imap::sort() has type boolean from PHP version 8 only --- src/PhpImap/Imap.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PhpImap/Imap.php b/src/PhpImap/Imap.php index c03a7953..7bc0ebbc 100644 --- a/src/PhpImap/Imap.php +++ b/src/PhpImap/Imap.php @@ -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; @@ -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,