mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-15 04:26:28 +00:00
Psalm dep and new reason added
This commit is contained in:
@@ -59,7 +59,7 @@ class EmailParser
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @return array
|
||||
* @return Result
|
||||
*/
|
||||
public function parse($str) : Result
|
||||
{
|
||||
|
||||
@@ -5,12 +5,11 @@ namespace Egulias\EmailValidator\Parser;
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Result\ValidEmail;
|
||||
use Egulias\EmailValidator\Exception\DotAtEnd;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Warning\LocalTooLong;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Result\Reason\DotAtEnd;
|
||||
use Egulias\EmailValidator\Result\Reason\DotAtStart;
|
||||
use Egulias\EmailValidator\Result\Reason\UnOpenedComment;
|
||||
|
||||
class LocalPart extends Parser
|
||||
{
|
||||
@@ -51,7 +50,7 @@ class LocalPart extends Parser
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$this->lexer->isNextToken(EmailLexer::S_AT)
|
||||
) {
|
||||
throw new DotAtEnd();
|
||||
return new InvalidEmail(new DotAtEnd(), $this->lexer->token['value']);
|
||||
}
|
||||
|
||||
$this->warnEscaping();
|
||||
|
||||
@@ -181,7 +181,7 @@ abstract class Parser
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function warnEscaping()
|
||||
protected function warnEscaping() : bool
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Result\Reason;
|
||||
|
||||
class DotAtEnd implements Reason
|
||||
{
|
||||
public function code() : int
|
||||
{
|
||||
return 142;
|
||||
}
|
||||
|
||||
public function description() : string
|
||||
{
|
||||
return 'Dot at the end';
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
use Egulias\EmailValidator\Exception\UnclosedComment;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment as ExceptionUnopenedComment;
|
||||
use Egulias\EmailValidator\Result\Reason\DotAtEnd as ReasonDotAtEnd;
|
||||
use Egulias\EmailValidator\Result\Reason\NoLocalPart;
|
||||
use Egulias\EmailValidator\Result\Reason\UnOpenedComment;
|
||||
use Egulias\EmailValidator\Result\Reason\DotAtStart as ReasonDotAtStart;
|
||||
@@ -199,7 +200,7 @@ class RFCValidationTest extends TestCase
|
||||
[new InvalidEmail(new ReasonDotAtStart(), '.'), '.example@localhost'],
|
||||
[new DotAtStart(), 'example@.localhost'],
|
||||
[new DotAtEnd(), 'example@localhost.'],
|
||||
[new DotAtEnd(), 'example.@example.co.uk'],
|
||||
[new InvalidEmail(new ReasonDotAtEnd(), '.'), 'example.@example.co.uk'],
|
||||
[new InvalidEmail(new ReasonUnclosedComment(), '('), '(example@localhost'],
|
||||
[new InvalidEmail(new UnclosedQuotedString(), '"'), '"example@localhost'],
|
||||
[
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.2",
|
||||
"phpunit/phpunit": "^8.2",
|
||||
"dominicsayers/isemail": "^3.0.7"
|
||||
"dominicsayers/isemail": "^3.0.7",
|
||||
"vimeo/psalm": "^3.11"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
|
||||
Reference in New Issue
Block a user