improving types

This commit is contained in:
Eduardo Gulias Davis
2020-12-05 23:16:56 +01:00
parent 3dc66acf64
commit 790881fe75
8 changed files with 8 additions and 13 deletions
-1
View File
@@ -105,7 +105,6 @@ class EmailLexer extends AbstractLexer
'?' => self::QUESTIONMARK,
'#' => self::NUMBER_SIGN,
'¡' => self::INVERT_EXCLAMATION,
null => self::S_EMPTY,
);
/**
+1 -5
View File
@@ -40,11 +40,7 @@ class EmailParser
$this->lexer = $lexer;
}
/**
* @param string $str
* @return Result
*/
public function parse($str) : Result
public function parse(string $str) : Result
{
$this->lexer->setInput($str);
+1 -1
View File
@@ -34,7 +34,7 @@ class DNSCheckValidation implements EmailValidation
}
}
public function isValid($email, EmailLexer $emailLexer) : bool
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
// use the input to check DNS if we cannot extract something similar to a domain
$host = $email;
+1 -1
View File
@@ -16,7 +16,7 @@ interface EmailValidation
*
* @return bool
*/
public function isValid($email, EmailLexer $emailLexer) : bool;
public function isValid(string $email, EmailLexer $emailLexer) : bool;
/**
* Returns the validation error.
+1 -1
View File
@@ -58,7 +58,7 @@ class MultipleValidationWithAnd implements EmailValidation
/**
* {@inheritdoc}
*/
public function isValid($email, EmailLexer $emailLexer) : bool
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
$result = true;
foreach ($this->validations as $validation) {
+1 -1
View File
@@ -16,7 +16,7 @@ class NoRFCWarningsValidation extends RFCValidation
/**
* {@inheritdoc}
*/
public function isValid($email, EmailLexer $emailLexer) : bool
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
if (!parent::isValid($email, $emailLexer)) {
return false;
+2 -2
View File
@@ -24,11 +24,11 @@ class RFCValidation implements EmailValidation
*/
private $error;
public function isValid($email, EmailLexer $emailLexer) : bool
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
$this->parser = new EmailParser($emailLexer);
try {
$result = $this->parser->parse((string)$email);
$result = $this->parser->parse($email);
$this->warnings = $this->parser->getWarnings();
if ($result->isInvalid()) {
/** @psalm-suppress PropertyTypeCoercion */
+1 -1
View File
@@ -24,7 +24,7 @@ class SpoofCheckValidation implements EmailValidation
/**
* @psalm-suppress InvalidArgument
*/
public function isValid($email, EmailLexer $emailLexer) : bool
public function isValid(string $email, EmailLexer $emailLexer) : bool
{
$checker = new Spoofchecker();
$checker->setChecks(Spoofchecker::SINGLE_SCRIPT);