mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-13 19:46:36 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebaaf5be6c | |||
| d11195e117 | |||
| 36233f5918 | |||
| 27be0e7157 | |||
| 97c28cd611 | |||
| 178d148438 | |||
| c4f65a68ee | |||
| 3a85486b70 |
@@ -1,4 +1,4 @@
|
|||||||
name: tests
|
name: build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
php: ['8.1', '8.2']
|
php: ['8.1', '8.2', '8.3']
|
||||||
deps: [highest]
|
deps: [highest]
|
||||||
|
|
||||||
include:
|
include:
|
||||||
@@ -47,9 +47,15 @@ jobs:
|
|||||||
|
|
||||||
- name: Execute tests
|
- name: Execute tests
|
||||||
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
|
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
|
||||||
|
- name: Coverage
|
||||||
|
if: ${{ matrix.php == '8.1' && matrix.deps == 'lowest' }}
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||||
|
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r build/logs/clover.xml
|
||||||
|
|
||||||
- name: Store artifacts
|
- name: Store artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: logs
|
name: logs
|
||||||
path: build/logs
|
path: build/logs
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
imports:
|
|
||||||
- php
|
|
||||||
|
|
||||||
build:
|
|
||||||
environment:
|
|
||||||
php: "8.1"
|
|
||||||
tests:
|
|
||||||
override:
|
|
||||||
- command: "vendor/bin/phpunit --coverage-clover=clover.xml --exclude-group flaky"
|
|
||||||
coverage:
|
|
||||||
file: "build/logs/clover.xml"
|
|
||||||
format: "clover"
|
|
||||||
- php-scrutinizer-run
|
|
||||||
+1
-2
@@ -1,4 +1,4 @@
|
|||||||
# EmailValidator v3 Changelog
|
# EmailValidator Changelog
|
||||||
|
|
||||||
## New Features
|
## New Features
|
||||||
|
|
||||||
@@ -30,4 +30,3 @@ PHP version upgrade requirement will happen via MINOR (3.x) version upgrades of
|
|||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
To contributors, be it with PRs, reporting issues or supporting otherwise.
|
To contributors, be it with PRs, reporting issues or supporting otherwise.
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# EmailValidator
|
# EmailValidator
|
||||||
|
|
||||||
[](https://github.com/egulias/EmailValidator/actions)
|
[](https://github.com/egulias/EmailValidator/actions)
|
||||||
[](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=4.x)
|
[](https://app.codacy.com/gh/egulias/EmailValidator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||||
[](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=4.x)
|
[](https://app.codacy.com/gh/egulias/EmailValidator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
|
||||||
|
|
||||||
A library for validating emails against several RFC.
|
A library for validating emails against several RFC.
|
||||||
|
|
||||||
## Supported RFCs ##
|
## Supported RFCs
|
||||||
|
|
||||||
This library aims to support RFCs:
|
This library aims to support RFCs:
|
||||||
|
|
||||||
@@ -21,15 +21,15 @@ This library aims to support RFCs:
|
|||||||
|
|
||||||
**Current major version with full support is v3**
|
**Current major version with full support is v3**
|
||||||
|
|
||||||
| Version | Released | EOL | Only critical bug fixes | Full |
|
| Version | Released | EOL | Only critical bug fixes | Full |
|
||||||
| :-----: | :--------: | :---: | :---------------------: | :---: |
|
|:-------:|:----------:|:---:|:-----------------------:|:----:|
|
||||||
| v4.x | 2023/01/07 | - | X | X |
|
| v4.x | 2023/01/07 | - | X | X |
|
||||||
| v3.x | 2020/12/29 | - | X | |
|
| v3.x | 2020/12/29 | - | X | |
|
||||||
| v2.1.x | 2016/05/16 | YES | | |
|
| v2.1.x | 2016/05/16 | YES | | |
|
||||||
| v1.2 | 2013/19/05 | YES | | |
|
| v1.2 | 2013/19/05 | YES | | |
|
||||||
|
|
||||||
|
|
||||||
## Requirements ##
|
## Requirements
|
||||||
|
|
||||||
* PHP 8.1
|
* PHP 8.1
|
||||||
* [Composer](https://getcomposer.org) is required for installation
|
* [Composer](https://getcomposer.org) is required for installation
|
||||||
@@ -37,7 +37,7 @@ This library aims to support RFCs:
|
|||||||
|
|
||||||
**Note**: `PHP version upgrades will happen to accomodate to the pace of major frameworks. Minor versions bumps will go via minor versions of this library (i.e: PHP7.3 -> v3.x+1). Major versions will go with major versions of the library`
|
**Note**: `PHP version upgrades will happen to accomodate to the pace of major frameworks. Minor versions bumps will go via minor versions of this library (i.e: PHP7.3 -> v3.x+1). Major versions will go with major versions of the library`
|
||||||
|
|
||||||
## Installation ##
|
## Installation
|
||||||
|
|
||||||
Run the command below to install via Composer
|
Run the command below to install via Composer
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ Run the command below to install via Composer
|
|||||||
composer require egulias/email-validator
|
composer require egulias/email-validator
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Started ##
|
## Getting Started
|
||||||
|
|
||||||
`EmailValidator` requires you to decide which (or combination of them) validation/s strategy/ies you'd like to follow for each [validation](#available-validations).
|
`EmailValidator` requires you to decide which (or combination of them) validation/s strategy/ies you'd like to follow for each [validation](#available-validations).
|
||||||
|
|
||||||
@@ -61,14 +61,14 @@ $validator->isValid("example@example.com", new RFCValidation()); //true
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Available validations ###
|
### Available validations
|
||||||
|
|
||||||
1. [RFCValidation](/src/Validation/RFCValidation.php): Standard RFC-like email validation.
|
1. [RFCValidation](/src/Validation/RFCValidation.php): Standard RFC-like email validation.
|
||||||
2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php): RFC-like validation that will fail when warnings* are found.
|
2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php): RFC-like validation that will fail when warnings* are found.
|
||||||
3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php): Will check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists.
|
3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php): Will check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists.
|
||||||
5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php): It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
|
4. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php): It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
|
||||||
6. [MessageIDValidation](/src/Validation/MessageIDValidation.php): Follows [RFC2822 for message-id](https://tools.ietf.org/html/rfc2822#section-3.6.4) to validate that field, that has some differences in the domain part.
|
5. [MessageIDValidation](/src/Validation/MessageIDValidation.php): Follows [RFC2822 for message-id](https://tools.ietf.org/html/rfc2822#section-3.6.4) to validate that field, that has some differences in the domain part.
|
||||||
7. [Your own validation](#how-to-extend): You can extend the library behaviour by implementing your own validations.
|
6. [Your own validation](#how-to-extend): You can extend the library behaviour by implementing your own validations.
|
||||||
|
|
||||||
*warnings: Warnings are deviations from the RFC that in a broader interpretation are accepted.
|
*warnings: Warnings are deviations from the RFC that in a broader interpretation are accepted.
|
||||||
|
|
||||||
@@ -89,21 +89,21 @@ $multipleValidations = new MultipleValidationWithAnd([
|
|||||||
$validator->isValid("example@ietf.org", $multipleValidations); //true
|
$validator->isValid("example@ietf.org", $multipleValidations); //true
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Additional validations ####
|
#### Additional validations
|
||||||
Validations not present in the RFCs
|
Validations not present in the RFCs
|
||||||
|
|
||||||
1. [SpoofCheckValidation](/src/Validation/Extra/SpoofCheckValidation.php): Will check for multi-utf-8 chars that can signal an erroneous email name.
|
1. [SpoofCheckValidation](/src/Validation/Extra/SpoofCheckValidation.php): Will check for multi-utf-8 chars that can signal an erroneous email name.
|
||||||
|
|
||||||
|
|
||||||
### How to extend ###
|
### How to extend
|
||||||
|
|
||||||
It's easy! You just need to implement [EmailValidation](/src/Validation/EmailValidation.php) and you can use your own validation.
|
It's easy! You just need to implement [EmailValidation](/src/Validation/EmailValidation.php) and you can use your own validation.
|
||||||
|
|
||||||
## Contributing ##
|
## Contributing
|
||||||
|
|
||||||
Please follow the [Contribution guide](CONTRIBUTING.md). Is short and simple and will help a lot.
|
Please follow the [Contribution guide](CONTRIBUTING.md). Is short and simple and will help a lot.
|
||||||
|
|
||||||
## Other Contributors ##
|
## Other Contributors
|
||||||
|
|
||||||
(You can find current contributors [here](https://github.com/egulias/EmailValidator/graphs/contributors))
|
(You can find current contributors [here](https://github.com/egulias/EmailValidator/graphs/contributors))
|
||||||
|
|
||||||
@@ -113,6 +113,6 @@ As this is a port from another library and work, here are other people related t
|
|||||||
* Josepf Bielawski [@stloyd](https://github.com/stloyd): For its first re-work of Dominic's lib
|
* Josepf Bielawski [@stloyd](https://github.com/stloyd): For its first re-work of Dominic's lib
|
||||||
* Dominic Sayers [@dominicsayers](https://github.com/dominicsayers): The original isemail function
|
* Dominic Sayers [@dominicsayers](https://github.com/dominicsayers): The original isemail function
|
||||||
|
|
||||||
## License ##
|
## License
|
||||||
|
|
||||||
Released under the MIT License attached with this code.
|
Released under the MIT License attached with this code.
|
||||||
|
|||||||
+2
-2
@@ -18,8 +18,8 @@
|
|||||||
"symfony/polyfill-intl-idn": "^1.26"
|
"symfony/polyfill-intl-idn": "^1.26"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.5.27",
|
"phpunit/phpunit": "^10.2",
|
||||||
"vimeo/psalm": "^4.30"
|
"vimeo/psalm": "^5.12"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||||
|
|||||||
+19
-9
@@ -1,17 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" executionOrder="defects" processIsolation="false" stopOnFailure="false">
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<coverage>
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
<include>
|
bootstrap="vendor/autoload.php"
|
||||||
<directory>./src/</directory>
|
colors="true"
|
||||||
</include>
|
executionOrder="defects"
|
||||||
<exclude>
|
cacheDirectory=".phpunit.cache"
|
||||||
<directory suffix=".php">./src/Result/Reason</directory>
|
>
|
||||||
</exclude>
|
<coverage/>
|
||||||
</coverage>
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="EmailValidator Test Suite">
|
<testsuite name="EmailValidator Test Suite">
|
||||||
<directory>./tests/EmailValidator</directory>
|
<directory>./tests/EmailValidator</directory>
|
||||||
<exclude>./vendor/</exclude>
|
<exclude>./vendor/</exclude>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>./src/</directory>
|
||||||
|
</include>
|
||||||
|
<exclude>
|
||||||
|
<directory suffix=".php">./src/Result/Reason</directory>
|
||||||
|
</exclude>
|
||||||
|
</source>
|
||||||
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
+2
-2
@@ -56,7 +56,7 @@ class EmailParser extends Parser
|
|||||||
$localPartParser = new LocalPart($this->lexer);
|
$localPartParser = new LocalPart($this->lexer);
|
||||||
$localPartResult = $localPartParser->parse();
|
$localPartResult = $localPartParser->parse();
|
||||||
$this->localPart = $localPartParser->localPart();
|
$this->localPart = $localPartParser->localPart();
|
||||||
$this->warnings = array_merge($localPartParser->getWarnings(), $this->warnings);
|
$this->warnings = [...$localPartParser->getWarnings(), ...$this->warnings];
|
||||||
|
|
||||||
return $localPartResult;
|
return $localPartResult;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ class EmailParser extends Parser
|
|||||||
$domainPartParser = new DomainPart($this->lexer);
|
$domainPartParser = new DomainPart($this->lexer);
|
||||||
$domainPartResult = $domainPartParser->parse();
|
$domainPartResult = $domainPartParser->parse();
|
||||||
$this->domainPart = $domainPartParser->domainPart();
|
$this->domainPart = $domainPartParser->domainPart();
|
||||||
$this->warnings = array_merge($domainPartParser->getWarnings(), $this->warnings);
|
$this->warnings = [...$domainPartParser->getWarnings(), ...$this->warnings];
|
||||||
|
|
||||||
return $domainPartResult;
|
return $domainPartResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class MessageIDParser extends Parser
|
|||||||
$localPartParser = new IDLeftPart($this->lexer);
|
$localPartParser = new IDLeftPart($this->lexer);
|
||||||
$localPartResult = $localPartParser->parse();
|
$localPartResult = $localPartParser->parse();
|
||||||
$this->idLeft = $localPartParser->localPart();
|
$this->idLeft = $localPartParser->localPart();
|
||||||
$this->warnings = array_merge($localPartParser->getWarnings(), $this->warnings);
|
$this->warnings = [...$localPartParser->getWarnings(), ...$this->warnings];
|
||||||
|
|
||||||
return $localPartResult;
|
return $localPartResult;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ class MessageIDParser extends Parser
|
|||||||
$domainPartParser = new IDRightPart($this->lexer);
|
$domainPartParser = new IDRightPart($this->lexer);
|
||||||
$domainPartResult = $domainPartParser->parse();
|
$domainPartResult = $domainPartParser->parse();
|
||||||
$this->idRight = $domainPartParser->domainPart();
|
$this->idRight = $domainPartParser->domainPart();
|
||||||
$this->warnings = array_merge($domainPartParser->getWarnings(), $this->warnings);
|
$this->warnings = [...$domainPartParser->getWarnings(), ...$this->warnings];
|
||||||
|
|
||||||
return $domainPartResult;
|
return $domainPartResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,29 +66,28 @@ class Comment extends PartParser
|
|||||||
|
|
||||||
$finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer);
|
$finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer);
|
||||||
|
|
||||||
$this->warnings = array_merge($this->warnings, $this->commentStrategy->getWarnings());
|
$this->warnings = [...$this->warnings, ...$this->commentStrategy->getWarnings()];
|
||||||
|
|
||||||
return $finalValidations;
|
return $finalValidations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function warnEscaping(): bool
|
private function warnEscaping(): void
|
||||||
{
|
{
|
||||||
//Backslash found
|
//Backslash found
|
||||||
if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {
|
if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warnings[QuotedPart::CODE] =
|
$this->warnings[QuotedPart::CODE] =
|
||||||
new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->current->type);
|
new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->current->type);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function noClosingParenthesis(): bool
|
private function noClosingParenthesis(): bool
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ class DomainComment implements CommentStrategy
|
|||||||
{
|
{
|
||||||
public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool
|
public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool
|
||||||
{
|
{
|
||||||
if (($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT))) { // || !$internalLexer->moveNext()) {
|
return !($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function endOfLoopValidations(EmailLexer $lexer): Result
|
public function endOfLoopValidations(EmailLexer $lexer): Result
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ class DomainLiteral extends PartParser
|
|||||||
|
|
||||||
if (!$isAddressLiteralIPv4) {
|
if (!$isAddressLiteralIPv4) {
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
} else {
|
|
||||||
$addressLiteral = $this->convertIPv4ToIPv6($addressLiteral);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$addressLiteral = $this->convertIPv4ToIPv6($addressLiteral);
|
||||||
|
|
||||||
if (!$IPv6TAG) {
|
if (!$IPv6TAG) {
|
||||||
$this->warnings[WarningDomainLiteral::CODE] = new WarningDomainLiteral();
|
$this->warnings[WarningDomainLiteral::CODE] = new WarningDomainLiteral();
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class DomainPart extends PartParser
|
|||||||
{
|
{
|
||||||
$commentParser = new Comment($this->lexer, new DomainComment());
|
$commentParser = new Comment($this->lexer, new DomainComment());
|
||||||
$result = $commentParser->parse();
|
$result = $commentParser->parse();
|
||||||
$this->warnings = array_merge($this->warnings, $commentParser->getWarnings());
|
$this->warnings = [...$this->warnings, ...$commentParser->getWarnings()];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -213,9 +213,9 @@ class DomainPart extends PartParser
|
|||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Token<int, string> $token
|
* @param Token<int, string> $token
|
||||||
*
|
*
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
private function checkNotAllowedChars(Token $token): Result
|
private function checkNotAllowedChars(Token $token): Result
|
||||||
@@ -240,14 +240,14 @@ class DomainPart extends PartParser
|
|||||||
|
|
||||||
$domainLiteralParser = new DomainLiteralParser($this->lexer);
|
$domainLiteralParser = new DomainLiteralParser($this->lexer);
|
||||||
$result = $domainLiteralParser->parse();
|
$result = $domainLiteralParser->parse();
|
||||||
$this->warnings = array_merge($this->warnings, $domainLiteralParser->getWarnings());
|
$this->warnings = [...$this->warnings, ...$domainLiteralParser->getWarnings()];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Token<int, string> $prev
|
* @param Token<int, string> $prev
|
||||||
* @param bool $hasComments
|
* @param bool $hasComments
|
||||||
*
|
*
|
||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result
|
protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result
|
||||||
@@ -323,4 +323,4 @@ class DomainPart extends PartParser
|
|||||||
{
|
{
|
||||||
return $this->domainPart;
|
return $this->domainPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ class DoubleQuote extends PartParser
|
|||||||
{
|
{
|
||||||
|
|
||||||
$validQuotedString = $this->checkDQUOTE();
|
$validQuotedString = $this->checkDQUOTE();
|
||||||
if ($validQuotedString->isInvalid()) return $validQuotedString;
|
if ($validQuotedString->isInvalid()) {
|
||||||
|
return $validQuotedString;
|
||||||
|
}
|
||||||
|
|
||||||
$special = [
|
$special = [
|
||||||
EmailLexer::S_CR => true,
|
EmailLexer::S_CR => true,
|
||||||
@@ -56,7 +58,9 @@ class DoubleQuote extends PartParser
|
|||||||
|
|
||||||
if ($prev->isA(EmailLexer::S_BACKSLASH)) {
|
if ($prev->isA(EmailLexer::S_BACKSLASH)) {
|
||||||
$validQuotedString = $this->checkDQUOTE();
|
$validQuotedString = $this->checkDQUOTE();
|
||||||
if ($validQuotedString->isInvalid()) return $validQuotedString;
|
if ($validQuotedString->isInvalid()) {
|
||||||
|
return $validQuotedString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) {
|
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class LocalPart extends PartParser
|
|||||||
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
||||||
$resultFWS = $foldingWS->parse();
|
$resultFWS = $foldingWS->parse();
|
||||||
if ($resultFWS->isValid()) {
|
if ($resultFWS->isValid()) {
|
||||||
$this->warnings = array_merge($this->warnings, $foldingWS->getWarnings());
|
$this->warnings = [...$this->warnings, ...$foldingWS->getWarnings()];
|
||||||
}
|
}
|
||||||
return $resultFWS;
|
return $resultFWS;
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ class LocalPart extends PartParser
|
|||||||
{
|
{
|
||||||
$dquoteParser = new DoubleQuote($this->lexer);
|
$dquoteParser = new DoubleQuote($this->lexer);
|
||||||
$parseAgain = $dquoteParser->parse();
|
$parseAgain = $dquoteParser->parse();
|
||||||
$this->warnings = array_merge($this->warnings, $dquoteParser->getWarnings());
|
$this->warnings = [...$this->warnings, ...$dquoteParser->getWarnings()];
|
||||||
|
|
||||||
return $parseAgain;
|
return $parseAgain;
|
||||||
}
|
}
|
||||||
@@ -141,10 +141,8 @@ class LocalPart extends PartParser
|
|||||||
{
|
{
|
||||||
$commentParser = new Comment($this->lexer, new LocalComment());
|
$commentParser = new Comment($this->lexer, new LocalComment());
|
||||||
$result = $commentParser->parse();
|
$result = $commentParser->parse();
|
||||||
$this->warnings = array_merge($this->warnings, $commentParser->getWarnings());
|
$this->warnings = [...$this->warnings, ...$commentParser->getWarnings()];
|
||||||
if ($result->isInvalid()) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,10 +157,6 @@ class LocalPart extends PartParser
|
|||||||
return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->current->value);
|
return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->current->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
|
||||||
return new ValidEmail();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ValidEmail();
|
return new ValidEmail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ abstract class PartParser
|
|||||||
{
|
{
|
||||||
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
$foldingWS = new FoldingWhiteSpace($this->lexer);
|
||||||
$resultFWS = $foldingWS->parse();
|
$resultFWS = $foldingWS->parse();
|
||||||
$this->warnings = array_merge($this->warnings, $foldingWS->getWarnings());
|
$this->warnings = [...$this->warnings, ...$foldingWS->getWarnings()];
|
||||||
return $resultFWS;
|
return $resultFWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class UnusualElements implements Reason
|
|||||||
/**
|
/**
|
||||||
* @var string $element
|
* @var string $element
|
||||||
*/
|
*/
|
||||||
private $element = '';
|
private $element;
|
||||||
|
|
||||||
public function __construct(string $element)
|
public function __construct(string $element)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ use Egulias\EmailValidator\Warning\Warning;
|
|||||||
|
|
||||||
class DNSCheckValidation implements EmailValidation
|
class DNSCheckValidation implements EmailValidation
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected const DNS_RECORD_TYPES_TO_CHECK = DNS_MX + DNS_A + DNS_AAAA;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
|
* Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
|
||||||
@@ -123,9 +119,20 @@ class DNSCheckValidation implements EmailValidation
|
|||||||
{
|
{
|
||||||
$variant = INTL_IDNA_VARIANT_UTS46;
|
$variant = INTL_IDNA_VARIANT_UTS46;
|
||||||
|
|
||||||
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.';
|
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.');
|
||||||
|
|
||||||
return $this->validateDnsRecords($host);
|
$hostParts = explode('.', $host);
|
||||||
|
$host = array_pop($hostParts);
|
||||||
|
|
||||||
|
while (count($hostParts) > 0) {
|
||||||
|
$host = array_pop($hostParts) . '.' . $host;
|
||||||
|
|
||||||
|
if ($this->validateDnsRecords($host)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +145,7 @@ class DNSCheckValidation implements EmailValidation
|
|||||||
*/
|
*/
|
||||||
private function validateDnsRecords($host): bool
|
private function validateDnsRecords($host): bool
|
||||||
{
|
{
|
||||||
$dnsRecordsResult = $this->dnsGetRecord->getRecords($host, static::DNS_RECORD_TYPES_TO_CHECK);
|
$dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_A + DNS_MX);
|
||||||
|
|
||||||
if ($dnsRecordsResult->withError()) {
|
if ($dnsRecordsResult->withError()) {
|
||||||
$this->error = new InvalidEmail(new UnableToGetDNSRecord(), '');
|
$this->error = new InvalidEmail(new UnableToGetDNSRecord(), '');
|
||||||
@@ -147,6 +154,13 @@ class DNSCheckValidation implements EmailValidation
|
|||||||
|
|
||||||
$dnsRecords = $dnsRecordsResult->getRecords();
|
$dnsRecords = $dnsRecordsResult->getRecords();
|
||||||
|
|
||||||
|
// Combined check for A+MX+AAAA can fail with SERVFAIL, even in the presence of valid A/MX records
|
||||||
|
$aaaaRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_AAAA);
|
||||||
|
|
||||||
|
if (! $aaaaRecordsResult->withError()) {
|
||||||
|
$dnsRecords = array_merge($dnsRecords, $aaaaRecordsResult->getRecords());
|
||||||
|
}
|
||||||
|
|
||||||
// No MX, A or AAAA DNS records
|
// No MX, A or AAAA DNS records
|
||||||
if ($dnsRecords === []) {
|
if ($dnsRecords === []) {
|
||||||
$this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');
|
$this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');
|
||||||
|
|||||||
@@ -4,25 +4,12 @@ namespace Egulias\EmailValidator\Validation;
|
|||||||
|
|
||||||
class DNSRecords
|
class DNSRecords
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array $records
|
|
||||||
*/
|
|
||||||
private $records = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool $error
|
|
||||||
*/
|
|
||||||
private $error = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $records
|
* @param array $records
|
||||||
* @param bool $error
|
* @param bool $error
|
||||||
*/
|
*/
|
||||||
public function __construct(array $records, bool $error = false)
|
public function __construct(private readonly array $records, private readonly bool $error = false)
|
||||||
{
|
{
|
||||||
$this->records = $records;
|
|
||||||
$this->error = $error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ class SpoofCheckValidation implements EmailValidation
|
|||||||
return $this->error === null;
|
return $this->error === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return InvalidEmail
|
|
||||||
*/
|
|
||||||
public function getError() : ?InvalidEmail
|
public function getError() : ?InvalidEmail
|
||||||
{
|
{
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ class MultipleValidationWithAnd implements EmailValidation
|
|||||||
*/
|
*/
|
||||||
public const ALLOW_ALL_ERRORS = 1;
|
public const ALLOW_ALL_ERRORS = 1;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var EmailValidation[]
|
|
||||||
*/
|
|
||||||
private $validations = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Warning[]
|
* @var Warning[]
|
||||||
*/
|
*/
|
||||||
@@ -37,23 +32,15 @@ class MultipleValidationWithAnd implements EmailValidation
|
|||||||
*/
|
*/
|
||||||
private $error;
|
private $error;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $mode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EmailValidation[] $validations The validations.
|
* @param EmailValidation[] $validations The validations.
|
||||||
* @param int $mode The validation mode (one of the constants).
|
* @param int $mode The validation mode (one of the constants).
|
||||||
*/
|
*/
|
||||||
public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS)
|
public function __construct(private readonly array $validations, private readonly int $mode = self::ALLOW_ALL_ERRORS)
|
||||||
{
|
{
|
||||||
if (count($validations) == 0) {
|
if (count($validations) == 0) {
|
||||||
throw new EmptyValidationList();
|
throw new EmptyValidationList();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validations = $validations;
|
|
||||||
$this->mode = $mode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +53,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
|||||||
$emailLexer->reset();
|
$emailLexer->reset();
|
||||||
$validationResult = $validation->isValid($email, $emailLexer);
|
$validationResult = $validation->isValid($email, $emailLexer);
|
||||||
$result = $result && $validationResult;
|
$result = $result && $validationResult;
|
||||||
$this->warnings = array_merge($this->warnings, $validation->getWarnings());
|
$this->warnings = [...$this->warnings, ...$validation->getWarnings()];
|
||||||
if (!$validationResult) {
|
if (!$validationResult) {
|
||||||
$this->processError($validation);
|
$this->processError($validation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ use Egulias\EmailValidator\Warning\Warning;
|
|||||||
|
|
||||||
class RFCValidation implements EmailValidation
|
class RFCValidation implements EmailValidation
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var EmailParser|null
|
|
||||||
*/
|
|
||||||
private $parser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Warning[]
|
* @var Warning[]
|
||||||
*/
|
*/
|
||||||
@@ -27,10 +22,10 @@ class RFCValidation implements EmailValidation
|
|||||||
|
|
||||||
public function isValid(string $email, EmailLexer $emailLexer): bool
|
public function isValid(string $email, EmailLexer $emailLexer): bool
|
||||||
{
|
{
|
||||||
$this->parser = new EmailParser($emailLexer);
|
$parser = new EmailParser($emailLexer);
|
||||||
try {
|
try {
|
||||||
$result = $this->parser->parse($email);
|
$result = $parser->parse($email);
|
||||||
$this->warnings = $this->parser->getWarnings();
|
$this->warnings = $parser->getWarnings();
|
||||||
if ($result->isInvalid()) {
|
if ($result->isInvalid()) {
|
||||||
/** @psalm-suppress PropertyTypeCoercion */
|
/** @psalm-suppress PropertyTypeCoercion */
|
||||||
$this->error = $result;
|
$this->error = $result;
|
||||||
|
|||||||
@@ -48,6 +48,6 @@ abstract class Warning
|
|||||||
*/
|
*/
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . strval(static::CODE);
|
return $this->message() . " rfc: " . $this->rfcNumber . "internal code: " . static::CODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ class EmailLexerTest extends TestCase
|
|||||||
$this->assertEquals(EmailLexer::INVALID, $lexer->current->type);
|
$this->assertEquals(EmailLexer::INVALID, $lexer->current->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidUTF8CharsProvider()
|
public static function invalidUTF8CharsProvider()
|
||||||
{
|
{
|
||||||
$chars = array();
|
$chars = array();
|
||||||
for ($i = 0; $i < 0x100; ++$i) {
|
for ($i = 0; $i < 0x100; ++$i) {
|
||||||
$c = $this->utf8Chr($i);
|
$c = self::utf8Chr($i);
|
||||||
if (preg_match('/(?=\p{Cc})(?=[^\t\n\n\r])/u', $c) && !preg_match('/\x{0000}/u', $c)) {
|
if (preg_match('/(?=\p{Cc})(?=[^\t\n\n\r])/u', $c) && !preg_match('/\x{0000}/u', $c)) {
|
||||||
$chars[] = array($c);
|
$chars[] = array($c);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ class EmailLexerTest extends TestCase
|
|||||||
return $chars;
|
return $chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function utf8Chr($code_point)
|
protected static function utf8Chr($code_point)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($code_point < 0 || 0x10FFFF < $code_point || (0xD800 <= $code_point && $code_point <= 0xDFFF)) {
|
if ($code_point < 0 || 0x10FFFF < $code_point || (0xD800 <= $code_point && $code_point <= 0xDFFF)) {
|
||||||
@@ -123,7 +123,7 @@ class EmailLexerTest extends TestCase
|
|||||||
$this->assertTrue($lexer->find(EmailLexer::S_HTAB));
|
$this->assertTrue($lexer->find(EmailLexer::S_HTAB));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTokens()
|
public static function getTokens()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array("foo", EmailLexer::GENERIC),
|
array("foo", EmailLexer::GENERIC),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class EmailParserTest extends TestCase
|
class EmailParserTest extends TestCase
|
||||||
{
|
{
|
||||||
public function emailPartsProvider()
|
public static function emailPartsProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['test@foo.com', 'test', 'foo.com'],
|
['test@foo.com', 'test', 'foo.com'],
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class DNSCheckValidationTest extends TestCase
|
class DNSCheckValidationTest extends TestCase
|
||||||
{
|
{
|
||||||
public function validEmailsProvider()
|
public static function validEmailsProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// dot-atom
|
// dot-atom
|
||||||
['Abc@ietf.org'],
|
['Abc@ietf.org'],
|
||||||
|
['Abc@fake.ietf.org'],
|
||||||
['ABC@ietf.org'],
|
['ABC@ietf.org'],
|
||||||
['Abc.123@ietf.org'],
|
['Abc.123@ietf.org'],
|
||||||
['user+mailbox/department=shipping@ietf.org'],
|
['user+mailbox/department=shipping@ietf.org'],
|
||||||
@@ -36,7 +37,7 @@ class DNSCheckValidationTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function localOrReservedEmailsProvider()
|
public static function localOrReservedEmailsProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Reserved Top Level DNS Names
|
// Reserved Top Level DNS Names
|
||||||
@@ -149,4 +150,4 @@ class DNSCheckValidationTest extends TestCase
|
|||||||
$validation->isValid('example@invalid.example.com', new EmailLexer());
|
$validation->isValid('example@invalid.example.com', new EmailLexer());
|
||||||
$this->assertEquals($expectedError, $validation->getError());
|
$this->assertEquals($expectedError, $validation->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class SpoofCheckValidationTest extends TestCase
|
|||||||
$this->assertFalse($validation->isValid("Кириллица"."latin漢字"."ひらがな"."カタカナ", new EmailLexer()));
|
$this->assertFalse($validation->isValid("Кириллица"."latin漢字"."ひらがな"."カタカナ", new EmailLexer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validUTF8EmailsProvider()
|
public static function validUTF8EmailsProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Cyrillic
|
// Cyrillic
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MessageIDValidationTest extends TestCase
|
|||||||
$this->assertTrue($validator->isValid($messageID, new EmailLexer()));
|
$this->assertTrue($validator->isValid($messageID, new EmailLexer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validMessageIDs() : array
|
public static function validMessageIDs() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['a@b.c+&%$.d'],
|
['a@b.c+&%$.d'],
|
||||||
@@ -38,7 +38,7 @@ class MessageIDValidationTest extends TestCase
|
|||||||
$this->assertFalse($validator->isValid($messageID, new EmailLexer()));
|
$this->assertFalse($validator->isValid($messageID, new EmailLexer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidMessageIDs() : array
|
public static function invalidMessageIDs() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['example'],
|
['example'],
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class NoRFCWarningsValidationTest extends TestCase
|
|||||||
$this->assertNull($validation->getError());
|
$this->assertNull($validation->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmailsWithoutWarnings()
|
public static function getValidEmailsWithoutWarnings()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['example@example.com',],
|
['example@example.com',],
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class RFCValidationDomainPartTest extends TestCase
|
|||||||
$this->assertTrue($this->validator->isValid($email, $this->lexer));
|
$this->assertTrue($this->validator->isValid($email, $this->lexer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmails()
|
public static function getValidEmails()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
['fabien@symfony.com'],
|
['fabien@symfony.com'],
|
||||||
@@ -88,7 +88,7 @@ class RFCValidationDomainPartTest extends TestCase
|
|||||||
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmails()
|
public static function getInvalidEmails()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['test@example.com test'],
|
['test@example.com test'],
|
||||||
@@ -161,7 +161,7 @@ class RFCValidationDomainPartTest extends TestCase
|
|||||||
$this->assertEquals($error, $this->validator->getError());
|
$this->assertEquals($error, $this->validator->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmailsWithErrors()
|
public static function getInvalidEmailsWithErrors()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new InvalidEmail(new NoDomainPart(), ''), 'example@'],
|
[new InvalidEmail(new NoDomainPart(), ''), 'example@'],
|
||||||
@@ -203,7 +203,7 @@ class RFCValidationDomainPartTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmailsWithWarnings()
|
public static function getValidEmailsWithWarnings()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//Check if this is actually possible
|
//Check if this is actually possible
|
||||||
@@ -232,7 +232,7 @@ class RFCValidationDomainPartTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidUTF16Chars()
|
public static function invalidUTF16Chars()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['example@symƒony.com'],
|
['example@symƒony.com'],
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class RFCValidationTest extends TestCase
|
|||||||
$this->assertTrue($this->validator->isValid($email, $this->lexer));
|
$this->assertTrue($this->validator->isValid($email, $this->lexer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmails()
|
public static function getValidEmails()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
['â@iana.org'],
|
['â@iana.org'],
|
||||||
@@ -91,7 +91,7 @@ class RFCValidationTest extends TestCase
|
|||||||
$this->assertEquals($expectedWarnings, $this->validator->getWarnings());
|
$this->assertEquals($expectedWarnings, $this->validator->getWarnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmailsWithWarnings()
|
public static function getValidEmailsWithWarnings()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['a5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com', [new LocalTooLong()]],
|
['a5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com', [new LocalTooLong()]],
|
||||||
@@ -120,7 +120,7 @@ class RFCValidationTest extends TestCase
|
|||||||
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmails()
|
public static function getInvalidEmails()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['user name@example.com'],
|
['user name@example.com'],
|
||||||
@@ -164,7 +164,7 @@ class RFCValidationTest extends TestCase
|
|||||||
$this->assertEquals($error, $this->validator->getError());
|
$this->assertEquals($error, $this->validator->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmailsWithErrors()
|
public static function getInvalidEmailsWithErrors()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[new InvalidEmail(new NoLocalPart(), "@"), '@example.co.uk'],
|
[new InvalidEmail(new NoLocalPart(), "@"), '@example.co.uk'],
|
||||||
|
|||||||
Reference in New Issue
Block a user