Skip to content

Commit 87b8b85

Browse files
authored
Used the most strict psalm level and fixed all psalm errors (#377)
1 parent ebaaf5b commit 87b8b85

File tree

9 files changed

+12
-29
lines changed

9 files changed

+12
-29
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/.* export-ignore
44
/phpunit.xml.dist export-ignore
55
/psalm.xml export-ignore
6-
/psalm.baseline.xml export-ignore
76
/README.md export-ignore

psalm.baseline.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

psalm.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
55
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd"
6-
errorBaseline="psalm.baseline.xml"
6+
errorLevel="1"
7+
findUnusedCode="false"
8+
findUnusedPsalmSuppress="true"
9+
disableSuppressAll="true"
10+
findUnusedVariablesAndParams="true"
711
>
812
<projectFiles>
913
<directory name="src" />
1014
<ignoreFiles>
1115
<directory name="vendor" />
1216
</ignoreFiles>
1317
</projectFiles>
14-
15-
<issueHandlers>
16-
<DeprecatedMethod>
17-
<errorLevel type="suppress">
18-
<!-- This issue needs to be resolved before upgrading to Lexer 3 -->
19-
<referencedMethod name="Doctrine\Common\Lexer\Token::offsetGet"/>
20-
</errorLevel>
21-
</DeprecatedMethod>
22-
</issueHandlers>
2318
</psalm>

src/EmailLexer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class EmailLexer extends AbstractLexer
6161
/**
6262
* US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
6363
*
64-
* @var array
64+
* @var array<string, int>
6565
*/
6666
protected $charValue = [
6767
'{' => self::S_OPENCURLYBRACES,
@@ -177,7 +177,6 @@ public function reset(): void
177177
* @throws \UnexpectedValueException
178178
* @return boolean
179179
*
180-
* @psalm-suppress InvalidScalarArgument
181180
*/
182181
public function find($type): bool
183182
{

src/Parser/CommentStrategy/LocalComment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
use Egulias\EmailValidator\Warning\CFWSNearAt;
99
use Egulias\EmailValidator\Result\InvalidEmail;
1010
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
11+
use Egulias\EmailValidator\Warning\Warning;
1112

1213
class LocalComment implements CommentStrategy
1314
{
1415
/**
15-
* @var array
16+
* @var array<int, Warning>
1617
*/
1718
private $warnings = [];
1819

src/Parser/DomainPart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ private function isLabelTooLong(string $label): bool
307307
{
308308
if (preg_match('/[^\x00-\x7F]/', $label)) {
309309
idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
310+
/** @psalm-var array{errors: int, ...} $idnaInfo */
310311
return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG);
311312
}
312313
return strlen($label) > self::LABEL_MAX_LENGTH;

src/Validation/DNSGetRecordWrapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ class DNSGetRecordWrapper
77
/**
88
* @param string $host
99
* @param int $type
10-
*
10+
*
1111
* @return DNSRecords
1212
*/
1313
public function getRecords(string $host, int $type): DNSRecords
1414
{
1515
// A workaround to fix https://bugs.php.net/bug.php?id=73149
16-
/** @psalm-suppress InvalidArgument */
1716
set_error_handler(
1817
static function (int $errorLevel, string $errorMessage): never {
1918
throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage");

src/Validation/DNSRecords.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
class DNSRecords
66
{
77
/**
8-
* @param array $records
8+
* @param list<array<array-key, mixed>> $records
99
* @param bool $error
1010
*/
1111
public function __construct(private readonly array $records, private readonly bool $error = false)
1212
{
1313
}
1414

1515
/**
16-
* @return array
16+
* @return list<array<array-key, mixed>>
1717
*/
1818
public function getRecords(): array
1919
{

src/Validation/Extra/SpoofCheckValidation.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ public function __construct()
2222
}
2323
}
2424

25-
/**
26-
* @psalm-suppress InvalidArgument
27-
*/
2825
public function isValid(string $email, EmailLexer $emailLexer) : bool
2926
{
3027
$checker = new Spoofchecker();

0 commit comments

Comments
 (0)