Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/Connection/ImapParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ public function __construct(ImapTokenizer $tokenizer)
*/
public function next(): Data|Token|Response|null
{
// Load the first token.
// Attempt to load the first token.
if (! $this->currentToken) {
$this->advance();
}

// No token was found, return null.
if (! $this->currentToken) {
throw new ImapParserException('Empty response');
return null;
}

// If the token indicates the beginning of a list, parse it.
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Connection/ImapConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use DirectoryTree\ImapEngine\Connection\ImapConnection;
use DirectoryTree\ImapEngine\Connection\Streams\FakeStream;
use DirectoryTree\ImapEngine\Exceptions\ImapCommandException;
use DirectoryTree\ImapEngine\Exceptions\ImapConnectionException;
use DirectoryTree\ImapEngine\Exceptions\ImapConnectionFailedException;
use DirectoryTree\ImapEngine\Exceptions\ImapParserException;
use DirectoryTree\ImapEngine\Support\Str;

test('connect success', function () {
Expand Down Expand Up @@ -681,7 +681,7 @@

expect(function () use ($connection) {
iterator_to_array($connection->idle(30));
})->toThrow(ImapParserException::class);
})->toThrow(ImapConnectionException::class);

$stream->assertWritten('TAG1 IDLE');
});
Expand Down
Loading