mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-17 18:31:37 +00:00
Fix psalm type issues info
This commit is contained in:
+1
-2
@@ -252,8 +252,7 @@ class EmailLexer extends AbstractLexer
|
||||
return self::INVALID;
|
||||
}
|
||||
|
||||
|
||||
return self::GENERIC;
|
||||
return self::GENERIC;
|
||||
}
|
||||
|
||||
protected function isValid(string $value): bool
|
||||
|
||||
@@ -4,15 +4,19 @@ namespace Egulias\EmailValidator\Parser\CommentStrategy;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
interface CommentStrategy
|
||||
{
|
||||
/**
|
||||
* Return "true" to continue, "false" to exit
|
||||
*/
|
||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis) : bool;
|
||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool;
|
||||
|
||||
public function endOfLoopValidations(EmailLexer $lexer) : Result;
|
||||
public function endOfLoopValidations(EmailLexer $lexer): Result;
|
||||
|
||||
public function getWarnings() : array;
|
||||
/**
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings(): array;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,12 @@ use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ConsecutiveDot;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Result\ValidEmail;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
abstract class PartParser
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
* @var Warning[]
|
||||
*/
|
||||
protected $warnings = [];
|
||||
|
||||
@@ -28,7 +29,7 @@ abstract class PartParser
|
||||
abstract public function parse(): Result;
|
||||
|
||||
/**
|
||||
* @return \Egulias\EmailValidator\Warning\Warning[]
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
|
||||
@@ -6,11 +6,15 @@ use Egulias\EmailValidator\Result\Reason\Reason;
|
||||
|
||||
class InvalidEmail implements Result
|
||||
{
|
||||
private $token;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private string $token;
|
||||
|
||||
/**
|
||||
* @var Reason
|
||||
*/
|
||||
protected $reason;
|
||||
protected Reason $reason;
|
||||
|
||||
public function __construct(Reason $reason, string $token)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ use Egulias\EmailValidator\Result\Reason\LocalOrReservedDomain;
|
||||
use Egulias\EmailValidator\Result\Reason\NoDNSRecord as ReasonNoDNSRecord;
|
||||
use Egulias\EmailValidator\Result\Reason\UnableToGetDNSRecord;
|
||||
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
class DNSCheckValidation implements EmailValidation
|
||||
{
|
||||
@@ -20,6 +21,8 @@ class DNSCheckValidation implements EmailValidation
|
||||
/**
|
||||
* Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
|
||||
* mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const RESERVED_DNS_TOP_LEVEL_NAMES = [
|
||||
// Reserved Top Level DNS Names
|
||||
@@ -41,7 +44,7 @@ class DNSCheckValidation implements EmailValidation
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var Warning[]
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
@@ -103,6 +106,9 @@ class DNSCheckValidation implements EmailValidation
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
class DNSGetRecordWrapper
|
||||
@@ -6,13 +7,15 @@ class DNSGetRecordWrapper
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $type
|
||||
*
|
||||
* @return DNSRecords
|
||||
*/
|
||||
public function getRecords(string $host, int $type) : 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): ?bool {
|
||||
static function (int $errorLevel, string $errorMessage): never {
|
||||
throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage");
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
class DNSRecords
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array $records
|
||||
*/
|
||||
@@ -15,21 +15,26 @@ class DNSRecords
|
||||
*/
|
||||
private $error = false;
|
||||
|
||||
/**
|
||||
* @param array $records
|
||||
* @param bool $error
|
||||
*/
|
||||
public function __construct(array $records, bool $error = false)
|
||||
{
|
||||
$this->records = $records;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
public function getRecords() : array
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRecords(): array
|
||||
{
|
||||
return $this->records;
|
||||
}
|
||||
|
||||
public function withError() : bool
|
||||
public function withError(): bool
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\MessageIDParser;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ExceptionFound;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
class MessageIDValidation implements EmailValidation
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var Warning[]
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
@@ -39,6 +40,9 @@ class MessageIDValidation implements EmailValidation
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
|
||||
@@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\Exception\EmptyValidationList;
|
||||
use Egulias\EmailValidator\Result\MultipleErrors;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
class MultipleValidationWithAnd implements EmailValidation
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
||||
private $validations = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var Warning[]
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
@@ -108,7 +109,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings(): array
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ExceptionFound;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
class RFCValidation implements EmailValidation
|
||||
{
|
||||
@@ -15,16 +16,16 @@ class RFCValidation implements EmailValidation
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var Warning[]
|
||||
*/
|
||||
private $warnings = [];
|
||||
private array $warnings = [];
|
||||
|
||||
/**
|
||||
* @var ?InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid(string $email, EmailLexer $emailLexer) : bool
|
||||
public function isValid(string $email, EmailLexer $emailLexer): bool
|
||||
{
|
||||
$this->parser = new EmailParser($emailLexer);
|
||||
try {
|
||||
@@ -43,12 +44,15 @@ class RFCValidation implements EmailValidation
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getError() : ?InvalidEmail
|
||||
public function getError(): ?InvalidEmail
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings() : array
|
||||
/**
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings(): array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
abstract class Warning
|
||||
{
|
||||
/**
|
||||
* @var int CODE
|
||||
*/
|
||||
public const CODE = 0;
|
||||
|
||||
/**
|
||||
@@ -45,6 +48,6 @@ abstract class Warning
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . static::CODE;
|
||||
return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . strval(static::CODE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user