Skip to content

Commit aca3864

Browse files
committed
Implement PHPStan up to level 4
1 parent 5c84594 commit aca3864

File tree

7 files changed

+12
-5
lines changed

7 files changed

+12
-5
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 3
2+
level: 4
33
ignoreErrors:
44
-
55
identifier: new.static

src/Connection/ImapConnection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function connect(string $host, ?int $port = null, array $options = []): v
122122

123123
/**
124124
* Get the default socket options for the given transport.
125+
* @param 'ssl'|'tls'|'starttls'|'tcp' $transport
125126
*/
126127
protected function getDefaultSocketOptions(string $transport, array $proxy = [], bool $validateCert = true): array
127128
{
@@ -595,6 +596,7 @@ public function done(): void
595596

596597
/**
597598
* Send an IMAP command.
599+
* @param-out string $tag
598600
*/
599601
public function send(string $name, array $tokens = [], ?string &$tag = null): void
600602
{
@@ -744,9 +746,9 @@ protected function assertNextResponse(callable $filter, callable $assertion, cal
744746
* @template T of Response
745747
*
746748
* @param callable(T): bool $filter
747-
* @return T
749+
* @return null|T
748750
*/
749-
protected function nextResponse(callable $filter): Response
751+
protected function nextResponse(callable $filter): ?Response
750752
{
751753
if (! $this->parser) {
752754
throw new LogicException('No parser instance set');

src/Connection/ImapQueryBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ protected function parseDate(mixed $date): CarbonInterface
373373

374374
/**
375375
* Build a single expression node from a basic or nested where.
376+
* @param array{type: 'basic'|'nested', boolean: 'AND'|'OR', query: ImapQueryBuilder} $where
376377
*/
377378
protected function makeExpressionNode(array $where): array
378379
{
@@ -391,6 +392,7 @@ protected function makeExpressionNode(array $where): array
391392

392393
/**
393394
* Merge the existing expression with the next expression, respecting the boolean operator.
395+
* @param 'AND'|'OR' $boolean
394396
*/
395397
protected function mergeExpressions(string $existing, string $next, string $boolean): string
396398
{

src/FlaggableInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function hasFlag(BackedEnum|string $flag): bool;
120120

121121
/**
122122
* Add or remove a flag from the message.
123+
* @param '+'|'-' $operation
123124
*/
124125
public function flag(BackedEnum|string $flag, string $operation, bool $expunge = false): void;
125126
}

src/MessageQuery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ protected function fetch(Collection $messages): array
302302
return [
303303
$uid => [
304304
'flags' => $data->lookup('FLAGS')?->values() ?? [],
305-
'headers' => $data->lookup('[HEADER]')?->value ?? '',
306-
'contents' => $data->lookup('[TEXT]')?->value ?? '',
305+
'headers' => $data->lookup('[HEADER]')->value ?? '',
306+
'contents' => $data->lookup('[TEXT]')->value ?? '',
307307
],
308308
];
309309
})->all();

src/QueriesMessages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ trait QueriesMessages
4242

4343
/**
4444
* The fetch order.
45+
* @var 'asc'|'desc' $fetchOrder
4546
*/
4647
protected string $fetchOrder = 'desc';
4748

src/Support/Str.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public static function fromImapUtf7(string $string): string
148148

149149
// Direct implementation of IMAP's modified UTF-7 decoding.
150150
return preg_replace_callback('/&([^-]*)-?/', function ($matches) {
151+
/** @var array{0: string, 1: string, 2?: string} $matches */
151152
// If it's just an ampersand.
152153
if ($matches[1] === '') {
153154
return '&';

0 commit comments

Comments
 (0)