Skip to content

Commit

Permalink
Used the most strict psalm level and fixed all psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aivchen committed Oct 15, 2023
1 parent ebaaf5b commit e4139dd
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 29 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 0 additions & 8 deletions psalm.baseline.xml

This file was deleted.

15 changes: 5 additions & 10 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
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" />
<ignoreFiles>
<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>
3 changes: 1 addition & 2 deletions src/EmailLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -177,7 +177,6 @@ public function reset(): void
* @throws \UnexpectedValueException
* @return boolean
*
* @psalm-suppress InvalidScalarArgument
*/
public function find($type): bool
{
Expand Down
3 changes: 2 additions & 1 deletion src/Parser/CommentStrategy/LocalComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
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 = [];

Expand Down
1 change: 1 addition & 0 deletions src/Parser/DomainPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ private function isLabelTooLong(string $label): bool
{
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;
Expand Down
3 changes: 1 addition & 2 deletions src/Validation/DNSGetRecordWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/DNSRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
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)
{
}

/**
* @return array
* @return list<array<array-key, mixed>>
*/
public function getRecords(): array
{
Expand Down
3 changes: 0 additions & 3 deletions src/Validation/Extra/SpoofCheckValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public function __construct()
}
}

/**
* @psalm-suppress InvalidArgument
*/
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
$checker = new Spoofchecker();
Expand Down

0 comments on commit e4139dd

Please sign in to comment.