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
339 changes: 326 additions & 13 deletions lib/Horde/Imap/Client/Ids.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Auth/SaslAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private function negotiate(

$binding = $mechanismName->usesChannelBinding() ? $this->binding : null;
$mechanism = $this->factory->create($mechanismName, $credentials, $binding);
} catch (UnsupportedMechanismException | PolicyViolationException | DowngradeDetectedException $e) {
} catch (UnsupportedMechanismException|PolicyViolationException|DowngradeDetectedException $e) {
$this->dispatch(new AuthenticationFailed($e->getMessage()));

throw new AuthenticationException($e->getMessage(), 0, $e);
Expand Down Expand Up @@ -219,7 +219,7 @@ private function runExchange(
$awaitingAdditionalData = true;
}
}
} catch (MechanismException | AuthenticationFailedException $e) {
} catch (MechanismException|AuthenticationFailedException $e) {
$channel->cancel();
$this->dispatch(new AuthenticationFailed($e->getMessage()));

Expand Down
19 changes: 8 additions & 11 deletions src/ImapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/**
* A modern IMAP client (RFC 3501/RFC 9051) built on `Horde\Socket\Client` and `Horde\Sasl`
*
* Reuses {@see Auth\ImapAuthChannel} for SASL `AUTHENTICATE`
* Reuses {@see ImapAuthChannel} for SASL `AUTHENTICATE`
* and {@see ImapCapabilityNegotiator} for `CAPABILITY`/ `ENABLE`.
* `LOGIN` is the one native fallback this class handles directly for
* servers that only advertise SASL mechanisms this library's policy
Expand Down Expand Up @@ -209,7 +209,7 @@ public function logout(): void

try {
$this->interaction->send('LOGOUT');
} catch (ImapProtocolException | ServerResponseException) {
} catch (ImapProtocolException|ServerResponseException) {
// The server is going away regardless; nothing more to do.
} finally {
$this->cache?->flush();
Expand Down Expand Up @@ -1634,7 +1634,7 @@ public function listACLRights(string $mailbox, string $identifier): ImapAclRight
// data: LISTRIGHTS mailbox identifier required optional...
$rights = array_values(array_filter(
array_slice($response->data, 3),
static fn ($value): bool => is_string($value),
static fn($value): bool => is_string($value),
));

$required = $rights === [] ? '' : array_shift($rights);
Expand Down Expand Up @@ -2431,7 +2431,7 @@ private function buildExtendedListCommand(string $pattern, MailboxListMode $mode
if ($statusItems !== []) {
$returnOptions->add(new ImapWireAtom('STATUS'));
$returnOptions->add(new ImapWireList(array_map(
static fn (string $item): ImapWireEncodable => new ImapWireAtom($item),
static fn(string $item): ImapWireEncodable => new ImapWireAtom($item),
$statusItems,
)));
}
Expand Down Expand Up @@ -2546,7 +2546,7 @@ private function parseListResponse(

$rawAttributes = array_values(array_filter(
$response->data[1],
static fn ($value): bool => is_string($value),
static fn($value): bool => is_string($value),
));
$delimiter = is_string($response->data[2]) ? $response->data[2] : null;

Expand Down Expand Up @@ -2598,8 +2598,8 @@ private function listEntryFilteredOut(MailboxListMode $mode, array $attributes,
$subscribed = isset($attributes['\\subscribed']) || strcasecmp($mailbox, 'INBOX') === 0;

return match ($mode) {
MailboxListMode::SubscribedExists =>
isset($attributes['\\nonexistent']) || !$subscribed,
MailboxListMode::SubscribedExists
=> isset($attributes['\\nonexistent']) || !$subscribed,
MailboxListMode::Unsubscribed => $subscribed,
default => false,
};
Expand Down Expand Up @@ -2769,7 +2769,7 @@ private function searchReturnOptions(array $results): array
}

return array_map(
static fn (string $atom): ImapWireEncodable => new ImapWireAtom($atom),
static fn(string $atom): ImapWireEncodable => new ImapWireAtom($atom),
array_keys($atoms),
);
}
Expand Down Expand Up @@ -3367,6 +3367,3 @@ private function hasTryCreate(ServerResponseException $e): bool
return $e->responseCode !== null && strtoupper($e->responseCode->name) === 'TRYCREATE';
}
}



5 changes: 3 additions & 2 deletions src/ImapConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Horde\Imap\Client\Exception\ServerResponseException;
use Horde\Socket\Client\ClientInterface;
use Throwable;

/**
* The IMAP line/literal protocol (RFC 3501 §2.2, §4.3) spoken over a
Expand Down Expand Up @@ -94,12 +95,12 @@ public function sendCommand(ImapCommand $command, bool $nonSynchronizingLiterals
foreach ($segment->stream->chunks() as $chunk) {
$this->client->write($chunk);
}
} catch (\Throwable $e) {
} catch (Throwable $e) {
// The announced literal may be incomplete. Never allow a
// subsequent command to be interpreted as its payload.
try {
$this->client->close();
} catch (\Throwable) {
} catch (Throwable) {
// Preserve the original read/write failure.
}
throw $e;
Expand Down
6 changes: 4 additions & 2 deletions src/ImapFetchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Horde\Imap\Client;

use InvalidArgumentException;

/**
* A fluent `fetch()` query for {@see ImapClient}.
*
Expand Down Expand Up @@ -189,7 +191,7 @@ public function binaryBodyPart(int|string $id, ?int $start = null, ?int $length
$section = $this->binarySection($id);
if (($start !== null && $start < 0) || ($length !== null && $length < 1)
|| ($start !== null && $length === null)) {
throw new \InvalidArgumentException('A BINARY partial requires a nonnegative start and a positive length.');
throw new InvalidArgumentException('A BINARY partial requires a nonnegative start and a positive length.');
}
$this->wantBinary = true;
$this->addItem(($peek ? 'BINARY.PEEK[' : 'BINARY[') . $section . ']' . $this->partialSuffix($start, $length));
Expand All @@ -214,7 +216,7 @@ private function binarySection(int|string $id): string
{
$section = (string) $id;
if ($section !== '' && !preg_match('/^[1-9][0-9]*(?:\.[1-9][0-9]*)*$/D', $section)) {
throw new \InvalidArgumentException('BINARY requires an empty section or a numeric MIME part id.');
throw new InvalidArgumentException('BINARY requires an empty section or a numeric MIME part id.');
}
return $section;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ImapFetchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*
* OO representations reuse the `horde/mime` and `horde/mail` value
* objects rather than inventing parallels: {@see getStructure()} returns
* a {@see \Horde\Mime\Part} tree, {@see getHeaders()} a
* {@see \Horde\Mime\Headers\HeaderCollection}, and {@see getEnvelope()}
* a {@see Part} tree, {@see getHeaders()} a
* {@see HeaderCollection}, and {@see getEnvelope()}
* an {@see ImapEnvelope} whose addresses are `Horde\Mail\Rfc822` types.
*
* @author Ralf Lang <ralf.lang@ralf-lang.de>
Expand Down
Loading
Loading