Used the most strict psalm level and fixed all psalm errors (#377)

This commit is contained in:
Andrew Ivchenkov
2023-10-16 00:39:26 +03:00
committed by GitHub
parent ebaaf5be6c
commit 87b8b8506e
9 changed files with 12 additions and 29 deletions
-1
View File
@@ -3,5 +3,4 @@
/.* export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/psalm.baseline.xml export-ignore
/README.md export-ignore
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863">
<file src="src/Parser/DomainPart.php">
<RedundantConditionGivenDocblockType occurrences="1">
<code>null !== $this-&gt;lexer-&gt;token['type']</code>
</RedundantConditionGivenDocblockType>
</file>
</files>
+5 -10
View File
@@ -3,7 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm.baseline.xml"
errorLevel="1"
findUnusedCode="false"
findUnusedPsalmSuppress="true"
disableSuppressAll="true"
findUnusedVariablesAndParams="true"
>
<projectFiles>
<directory name="src" />
@@ -11,13 +15,4 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- This issue needs to be resolved before upgrading to Lexer 3 -->
<referencedMethod name="Doctrine\Common\Lexer\Token::offsetGet"/>
</errorLevel>
</DeprecatedMethod>
</issueHandlers>
</psalm>
+1 -2
View File
@@ -61,7 +61,7 @@ class EmailLexer extends AbstractLexer
/**
* US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
*
* @var array
* @var array<string, int>
*/
protected $charValue = [
'{' => self::S_OPENCURLYBRACES,
@@ -177,7 +177,6 @@ class EmailLexer extends AbstractLexer
* @throws \UnexpectedValueException
* @return boolean
*
* @psalm-suppress InvalidScalarArgument
*/
public function find($type): bool
{
+2 -1
View File
@@ -8,11 +8,12 @@ use Egulias\EmailValidator\Result\ValidEmail;
use Egulias\EmailValidator\Warning\CFWSNearAt;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Result\Reason\ExpectingATEXT;
use Egulias\EmailValidator\Warning\Warning;
class LocalComment implements CommentStrategy
{
/**
* @var array
* @var array<int, Warning>
*/
private $warnings = [];
+1
View File
@@ -307,6 +307,7 @@ class DomainPart extends PartParser
{
if (preg_match('/[^\x00-\x7F]/', $label)) {
idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
/** @psalm-var array{errors: int, ...} $idnaInfo */
return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG);
}
return strlen($label) > self::LABEL_MAX_LENGTH;
+1 -2
View File
@@ -7,13 +7,12 @@ class DNSGetRecordWrapper
/**
* @param string $host
* @param int $type
*
*
* @return DNSRecords
*/
public function getRecords(string $host, int $type): DNSRecords
{
// A workaround to fix https://bugs.php.net/bug.php?id=73149
/** @psalm-suppress InvalidArgument */
set_error_handler(
static function (int $errorLevel, string $errorMessage): never {
throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage");
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Egulias\EmailValidator\Validation;
class DNSRecords
{
/**
* @param array $records
* @param list<array<array-key, mixed>> $records
* @param bool $error
*/
public function __construct(private readonly array $records, private readonly bool $error = false)
@@ -13,7 +13,7 @@ class DNSRecords
}
/**
* @return array
* @return list<array<array-key, mixed>>
*/
public function getRecords(): array
{
@@ -22,9 +22,6 @@ class SpoofCheckValidation implements EmailValidation
}
}
/**
* @psalm-suppress InvalidArgument
*/
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
$checker = new Spoofchecker();