Skip to content

Commit 4e2e8ff

Browse files
authored
Merge pull request #116 from CReimer/phpstan-level-4
Implement PHPStan up to level 4
2 parents 5c84594 + fb8abb8 commit 4e2e8ff

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
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: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Exception;
2525
use Generator;
2626
use LogicException;
27+
use Throwable;
2728

2829
class ImapConnection implements ConnectionInterface
2930
{
@@ -122,6 +123,8 @@ public function connect(string $host, ?int $port = null, array $options = []): v
122123

123124
/**
124125
* Get the default socket options for the given transport.
126+
*
127+
* @param 'ssl'|'tls'|'starttls'|'tcp' $transport
125128
*/
126129
protected function getDefaultSocketOptions(string $transport, array $proxy = [], bool $validateCert = true): array
127130
{
@@ -595,6 +598,8 @@ public function done(): void
595598

596599
/**
597600
* Send an IMAP command.
601+
*
602+
* @param-out string $tag
598603
*/
599604
public function send(string $name, array $tokens = [], ?string &$tag = null): void
600605
{
@@ -722,8 +727,12 @@ protected function assertTaggedResponse(string $tag, ?callable $exception = null
722727
*
723728
* @template T of Response
724729
*
725-
* @param callable(T): bool $filter
730+
* @param callable(Response): bool $filter
731+
* @param callable(T): bool $assertion
732+
* @param callable(T): Throwable $exception
726733
* @return T
734+
*
735+
* @throws ImapResponseException
727736
*/
728737
protected function assertNextResponse(callable $filter, callable $assertion, callable $exception): Response
729738
{
@@ -744,9 +753,9 @@ protected function assertNextResponse(callable $filter, callable $assertion, cal
744753
* @template T of Response
745754
*
746755
* @param callable(T): bool $filter
747-
* @return T
756+
* @return T|null
748757
*/
749-
protected function nextResponse(callable $filter): Response
758+
protected function nextResponse(callable $filter): ?Response
750759
{
751760
if (! $this->parser) {
752761
throw new LogicException('No parser instance set');
@@ -764,7 +773,7 @@ protected function nextResponse(callable $filter): Response
764773
}
765774
}
766775

767-
throw new ImapResponseException('No matching response found');
776+
return null;
768777
}
769778

770779
/**

src/Connection/ImapQueryBuilder.php

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

374374
/**
375375
* Build a single expression node from a basic or nested where.
376+
*
377+
* @param array{type: 'basic'|'nested', boolean: 'AND'|'OR', query: ImapQueryBuilder} $where
376378
*/
377379
protected function makeExpressionNode(array $where): array
378380
{
@@ -391,6 +393,8 @@ protected function makeExpressionNode(array $where): array
391393

392394
/**
393395
* Merge the existing expression with the next expression, respecting the boolean operator.
396+
*
397+
* @param 'AND'|'OR' $boolean
394398
*/
395399
protected function mergeExpressions(string $existing, string $next, string $boolean): string
396400
{

src/FlaggableInterface.php

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

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

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ trait QueriesMessages
4242

4343
/**
4444
* The fetch order.
45+
*
46+
* @var 'asc'|'desc'
4547
*/
4648
protected string $fetchOrder = 'desc';
4749

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)