mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-11 18:47:02 +00:00
Return type in signature
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Result\Reason;
|
||||
|
||||
class ExceptionFound implements Reason
|
||||
{
|
||||
public function code() : int
|
||||
{
|
||||
return 999;
|
||||
}
|
||||
|
||||
public function description() : string
|
||||
{
|
||||
return 'An exception occurred during the execution';
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class DNSCheckValidation implements EmailValidation
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool
|
||||
{
|
||||
// use the input to check DNS if we cannot extract something similar to a domain
|
||||
$host = $email;
|
||||
@@ -85,7 +85,7 @@ class DNSCheckValidation implements EmailValidation
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
public function getWarnings() : array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ interface EmailValidation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer);
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool;
|
||||
|
||||
/**
|
||||
* Returns the validation error.
|
||||
@@ -30,5 +30,5 @@ interface EmailValidation
|
||||
*
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings();
|
||||
public function getWarnings() : array;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool
|
||||
{
|
||||
$result = true;
|
||||
foreach ($this->validations as $validation) {
|
||||
@@ -115,7 +115,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getWarnings()
|
||||
public function getWarnings() : array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class NoRFCWarningsValidation extends RFCValidation
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool
|
||||
{
|
||||
if (!parent::isValid($email, $emailLexer)) {
|
||||
return false;
|
||||
|
||||
@@ -6,6 +6,7 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail as ExceptionInvalidEmail;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\ExceptionFound;
|
||||
|
||||
class RFCValidation implements EmailValidation
|
||||
{
|
||||
@@ -24,7 +25,7 @@ class RFCValidation implements EmailValidation
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool
|
||||
{
|
||||
$this->parser = new EmailParser($emailLexer);
|
||||
try {
|
||||
@@ -33,8 +34,8 @@ class RFCValidation implements EmailValidation
|
||||
$this->error = $result;
|
||||
return false;
|
||||
}
|
||||
} catch (ExceptionInvalidEmail $invalid) {
|
||||
$this->error = $invalid;
|
||||
} catch (\Exception $invalid) {
|
||||
$this->error = new InvalidEmail(new ExceptionFound(), '');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ class RFCValidation implements EmailValidation
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
public function getWarnings() : array
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class SpoofCheckValidation implements EmailValidation
|
||||
/**
|
||||
* @psalm-suppress InvalidArgument
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
public function isValid($email, EmailLexer $emailLexer) : bool
|
||||
{
|
||||
$checker = new Spoofchecker();
|
||||
$checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
|
||||
@@ -44,7 +44,7 @@ class SpoofCheckValidation implements EmailValidation
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
public function getWarnings() : array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user