From aab3386af9691a0b489dbc2baad1ecceb1943771 Mon Sep 17 00:00:00 2001 From: Francesco Bianco Date: Tue, 19 Jul 2022 18:48:29 +0200 Subject: [PATCH] fix --- bootstrap.php | 5 +++-- src/Acl.php | 2 +- src/BodyStructure.php | 2 +- src/Connection.php | 10 +--------- src/Errors.php | 2 +- src/Functions.php | 2 +- src/HeaderInfo.php | 2 +- src/ImapHelpers.php | 2 +- src/Mail.php | 2 +- src/Mailbox.php | 2 +- src/Message.php | 2 +- src/Polyfill.php | 2 +- src/Thread.php | 2 +- src/Timeout.php | 33 +++++++++++++++++++++++++++++++++ tests/legacy/last-error.1.txt | 9 --------- tests/legacy/last-error.2.txt | 12 ------------ tests/legacy/test.php | 19 +++++++++++++++++++ 17 files changed, 67 insertions(+), 43 deletions(-) create mode 100644 src/Timeout.php delete mode 100755 tests/legacy/last-error.1.txt delete mode 100755 tests/legacy/last-error.2.txt create mode 100644 tests/legacy/test.php diff --git a/bootstrap.php b/bootstrap.php index 04cab6e..61f931a 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,7 +1,7 @@ * @@ -16,6 +16,7 @@ use Javanile\Imap2\Message; use Javanile\Imap2\Thread; use Javanile\Imap2\Polyfill; +use Javanile\Imap2\Timeout; define('IMAP2_CHARSET', 'UTF-8'); define('IMAP2_RETROFIT_MODE', function_exists('imap_open')); @@ -324,7 +325,7 @@ function imap2_timeout($timeoutType, $timeout = -1) imap_timeout($timeoutType, $timeout); } - return Connection::timeout($timeoutType, $timeout); + return Timeout::set($timeoutType, $timeout); } } diff --git a/src/Acl.php b/src/Acl.php index 86cd751..f5d41c6 100644 --- a/src/Acl.php +++ b/src/Acl.php @@ -1,7 +1,7 @@ * diff --git a/src/BodyStructure.php b/src/BodyStructure.php index deafee8..11057d0 100644 --- a/src/BodyStructure.php +++ b/src/BodyStructure.php @@ -1,7 +1,7 @@ * diff --git a/src/Connection.php b/src/Connection.php index ddddd49..fe48c75 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -1,7 +1,7 @@ * @@ -222,14 +222,6 @@ public function selectMailbox() } } - /** - * - */ - public static function timeout($timeoutType, $timeout = -1) - { - - } - /** * */ diff --git a/src/Errors.php b/src/Errors.php index 7d4aeb1..fae5bbf 100644 --- a/src/Errors.php +++ b/src/Errors.php @@ -1,7 +1,7 @@ * diff --git a/src/Functions.php b/src/Functions.php index 3dee2fd..3ec4cf5 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -1,7 +1,7 @@ * diff --git a/src/HeaderInfo.php b/src/HeaderInfo.php index 793c338..08a908c 100644 --- a/src/HeaderInfo.php +++ b/src/HeaderInfo.php @@ -1,7 +1,7 @@ * diff --git a/src/ImapHelpers.php b/src/ImapHelpers.php index 504e4c2..2b22609 100644 --- a/src/ImapHelpers.php +++ b/src/ImapHelpers.php @@ -1,7 +1,7 @@ * diff --git a/src/Mail.php b/src/Mail.php index 79fbc1c..47e7a8c 100644 --- a/src/Mail.php +++ b/src/Mail.php @@ -1,7 +1,7 @@ * diff --git a/src/Mailbox.php b/src/Mailbox.php index d0a2780..389681a 100644 --- a/src/Mailbox.php +++ b/src/Mailbox.php @@ -1,7 +1,7 @@ * diff --git a/src/Message.php b/src/Message.php index 5a4907c..8522cd0 100644 --- a/src/Message.php +++ b/src/Message.php @@ -1,7 +1,7 @@ * diff --git a/src/Polyfill.php b/src/Polyfill.php index ee9907b..949e279 100644 --- a/src/Polyfill.php +++ b/src/Polyfill.php @@ -1,7 +1,7 @@ * diff --git a/src/Thread.php b/src/Thread.php index dbcca51..97afb85 100644 --- a/src/Thread.php +++ b/src/Thread.php @@ -1,7 +1,7 @@ * diff --git a/src/Timeout.php b/src/Timeout.php new file mode 100644 index 0000000..858c771 --- /dev/null +++ b/src/Timeout.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Javanile\Imap2; + +class Timeout +{ + protected static $timeout; + + public static function set($timeoutType, $timeout = -1) + { + if ($timeout == -1) { + return self::get($timeoutType); + } + + self::$timeout[$timeoutType] = $timeout; + + return true; + } + + public static function get($timeoutType) + { + return self::$timeout[$timeoutType]; + } +} diff --git a/tests/legacy/last-error.1.txt b/tests/legacy/last-error.1.txt deleted file mode 100755 index 8df5c7b..0000000 --- a/tests/legacy/last-error.1.txt +++ /dev/null @@ -1,9 +0,0 @@ - -Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl} in /app/tests/legacy/last-error.php on line 21 - -Call Stack: - 0.0001 354808 1. {main}() /app/tests/legacy/last-error.php:0 - 0.0001 354808 2. imap_open() /app/tests/legacy/last-error.php:21 - -/app/tests/legacy/last-error.php:23: -string(89) "Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Invalid credentials (Failure)" diff --git a/tests/legacy/last-error.2.txt b/tests/legacy/last-error.2.txt deleted file mode 100755 index d14d4f3..0000000 --- a/tests/legacy/last-error.2.txt +++ /dev/null @@ -1,12 +0,0 @@ - -Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl} in /app/tests/legacy/last-error.php on line 21. Source code in /app/src/Connection.php on line 81 - -Call Stack: - 0.0001 354744 1. {main}() /app/tests/legacy/last-error.php:0 - 0.0033 921080 2. imap_open() /app/tests/legacy/last-error.php:21 - 0.0033 921136 3. imap2_open() /app/bootstrap.php:237 - 0.0035 956504 4. Javanile\Imap2\Connection::open() /app/bootstrap.php:247 - 0.3101 1682632 5. trigger_error() /app/src/Connection.php:81 - -/app/tests/legacy/last-error.php:23: -string(89) "Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Invalid credentials (Failure)" diff --git a/tests/legacy/test.php b/tests/legacy/test.php new file mode 100644 index 0000000..5566a26 --- /dev/null +++ b/tests/legacy/test.php @@ -0,0 +1,19 @@ +