mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-04 22:50:45 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92dd169c32 | |||
| a6c8d7101b |
@@ -1,5 +1,7 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
@@ -9,6 +11,7 @@ php:
|
|||||||
- 7.1
|
- 7.1
|
||||||
- 7.2
|
- 7.2
|
||||||
- 7.3
|
- 7.3
|
||||||
|
- 7.4snapshot
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
@@ -77,10 +77,25 @@ class EmailLexer extends AbstractLexer
|
|||||||
|
|
||||||
protected $previous;
|
protected $previous;
|
||||||
|
|
||||||
|
private static $nullToken = [
|
||||||
|
'value' => '',
|
||||||
|
'type' => null,
|
||||||
|
'position' => 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->previous = $this->token = self::$nullToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->hasInvalidTokens = false;
|
$this->hasInvalidTokens = false;
|
||||||
parent::reset();
|
parent::reset();
|
||||||
|
$this->previous = $this->token = self::$nullToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasInvalidTokens()
|
public function hasInvalidTokens()
|
||||||
@@ -122,8 +137,10 @@ class EmailLexer extends AbstractLexer
|
|||||||
public function moveNext()
|
public function moveNext()
|
||||||
{
|
{
|
||||||
$this->previous = $this->token;
|
$this->previous = $this->token;
|
||||||
|
$hasNext = parent::moveNext();
|
||||||
|
$this->token = $this->token ?: self::$nullToken;
|
||||||
|
|
||||||
return parent::moveNext();
|
return $hasNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,6 +231,9 @@ class EmailLexer extends AbstractLexer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function getModifiers()
|
protected function getModifiers()
|
||||||
{
|
{
|
||||||
return 'iu';
|
return 'iu';
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class DomainPart extends Parser
|
|||||||
|
|
||||||
$domain .= $this->lexer->token['value'];
|
$domain .= $this->lexer->token['value'];
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
} while ($this->lexer->token);
|
} while (null !== $this->lexer->token['type']);
|
||||||
|
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class LocalPart extends Parser
|
|||||||
$closingQuote = false;
|
$closingQuote = false;
|
||||||
$openedParenthesis = 0;
|
$openedParenthesis = 0;
|
||||||
|
|
||||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) {
|
while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) {
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) {
|
if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) {
|
||||||
throw new DotAtStart();
|
throw new DotAtStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ class LocalPart extends Parser
|
|||||||
|
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) {
|
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) {
|
||||||
$parseAgain = false;
|
$parseAgain = false;
|
||||||
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
||||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\EmailValidator;
|
use Egulias\EmailValidator\EmailValidator;
|
||||||
use Egulias\EmailValidator\Exception\CommaInDomain;
|
use Egulias\EmailValidator\Exception\CommaInDomain;
|
||||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||||
@@ -17,7 +18,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testUsesAndLogicalOperation()
|
public function testUsesAndLogicalOperation()
|
||||||
{
|
{
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
$validationTrue = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validationTrue = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validationTrue->expects($this->any())->method("isValid")->willReturn(true);
|
$validationTrue->expects($this->any())->method("isValid")->willReturn(true);
|
||||||
$validationTrue->expects($this->any())->method("getWarnings")->willReturn([]);
|
$validationTrue->expects($this->any())->method("getWarnings")->willReturn([]);
|
||||||
@@ -38,7 +39,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
|
|
||||||
public function testValidationIsValid()
|
public function testValidationIsValid()
|
||||||
{
|
{
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
|
|
||||||
$validation = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validation->expects($this->any())->method("isValid")->willReturn(true);
|
$validation->expects($this->any())->method("isValid")->willReturn(true);
|
||||||
@@ -59,7 +60,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
];
|
];
|
||||||
$expectedResult = array_merge($warnings1, $warnings2);
|
$expectedResult = array_merge($warnings1, $warnings2);
|
||||||
|
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validation1->expects($this->any())->method("isValid")->willReturn(true);
|
$validation1->expects($this->any())->method("isValid")->willReturn(true);
|
||||||
$validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1);
|
$validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1);
|
||||||
@@ -81,7 +82,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
|
|
||||||
$expectedResult = new MultipleErrors([$error1, $error2]);
|
$expectedResult = new MultipleErrors([$error1, $error2]);
|
||||||
|
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
|
|
||||||
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validation1->expects($this->once())->method("isValid")->willReturn(false);
|
$validation1->expects($this->once())->method("isValid")->willReturn(false);
|
||||||
@@ -105,7 +106,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
|
|
||||||
$expectedResult = new MultipleErrors([$error1]);
|
$expectedResult = new MultipleErrors([$error1]);
|
||||||
|
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
|
|
||||||
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validation1->expects($this->any())->method("isValid")->willReturn(false);
|
$validation1->expects($this->any())->method("isValid")->willReturn(false);
|
||||||
@@ -128,7 +129,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
|
|
||||||
$expectedResult = new MultipleErrors([$error]);
|
$expectedResult = new MultipleErrors([$error]);
|
||||||
|
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
|
|
||||||
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validation1->expects($this->any())->method("isValid")->willReturn(false);
|
$validation1->expects($this->any())->method("isValid")->willReturn(false);
|
||||||
@@ -147,7 +148,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
|
|
||||||
public function testBreakoutOnInvalidEmail()
|
public function testBreakoutOnInvalidEmail()
|
||||||
{
|
{
|
||||||
$lexer = $this->getMockBuilder("Egulias\\EmailValidator\\EmailLexer")->getMock();
|
$lexer = new EmailLexer();
|
||||||
|
|
||||||
$validationNotCalled = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validationNotCalled = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
||||||
$validationNotCalled->expects($this->never())->method("isValid");
|
$validationNotCalled->expects($this->never())->method("isValid");
|
||||||
|
|||||||
+2
-1
@@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.0.x-dev"
|
"dev-master": "2.1.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"satooshi/php-coveralls": "^1.0.1",
|
"satooshi/php-coveralls": "^1.0.1",
|
||||||
"phpunit/phpunit": "^4.8.35||^5.7||^6.0",
|
"phpunit/phpunit": "^4.8.35||^5.7||^6.0",
|
||||||
|
"symfony/phpunit-bridge": "^4.4@dev",
|
||||||
"dominicsayers/isemail": "dev-master"
|
"dominicsayers/isemail": "dev-master"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
|||||||
+7
-4
@@ -8,7 +8,6 @@
|
|||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
syntaxCheck="false"
|
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
@@ -19,8 +18,12 @@
|
|||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<blacklist>
|
<whitelist>
|
||||||
<directory>./vendor</directory>
|
<directory>./EmailValidator/</directory>
|
||||||
</blacklist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
|
<listeners>
|
||||||
|
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||||
|
</listeners>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
Reference in New Issue
Block a user