Compare commits

...

10 Commits

Author SHA1 Message Date
Dries Vints b531a23117 GitHub Actions (#348)
* Add GitHub Actions workflow

* Ignore composer.lock

* Separate static analysis build

* Use ramsey/composer-install

* Add 7.2 and 7.3

* Remove coveralls
2023-01-02 18:26:14 +01:00
Alexander M. Turek 5f35e41eba Allow doctrine/lexer 2 (#345) 2022-12-30 15:09:25 +01:00
Alexis Lefebvre 0170967656 CHANGELOG: Fix typo “Breacking” (#333) 2022-09-03 11:54:08 +02:00
Eduardo Gulias Davis 4c72190f32 Update LICENSE 2022-08-14 20:36:33 +02:00
Mathias Reker ⚡️ 413b263617 Nullable type declaration for default null value (#328)
Adds ? before type declarations for parameters with a default null value
2022-07-13 16:53:11 +02:00
Mathias Reker ⚡️ 18b9e5b572 Visibility required (#329)
Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility.
2022-07-13 16:52:42 +02:00
Mathias Reker ⚡️ 1ca313dfcd Single blank line at eof (#330)
A PHP file without end tag must always end with a single empty line feed.
2022-07-13 16:51:51 +02:00
Mathias Reker ⚡️ cf5908bb1a No superfluous elseif (#331)
Replaces superfluous elseif with if.
2022-07-13 16:51:22 +02:00
Mathias Reker ⚡️ b241b54919 No unused imports (#332)
Unused use statements must be removed.
2022-07-13 16:50:27 +02:00
dependabot[bot] 74d2f16d9d Bump guzzlehttp/guzzle from 7.4.3 to 7.4.5 (#326)
Bumps [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) from 7.4.3 to 7.4.5.
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/master/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/7.4.3...7.4.5)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-24 20:51:04 +02:00
72 changed files with 247 additions and 5224 deletions
-3
View File
@@ -1,3 +0,0 @@
service_name: travis-ci
src_dir: .
coverage_clover: build/logs/clover*.xml
+35
View File
@@ -0,0 +1,35 @@
name: static analysis
on:
push:
branches:
- master
- '*.x'
pull_request:
jobs:
psalm:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
name: Psalm
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Execute Psalm
run: vendor/bin/psalm
+48
View File
@@ -0,0 +1,48 @@
name: tests
on:
push:
branches:
- master
- '*.x'
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4, '8.0', 8.1, 8.2]
name: PHP ${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Setup logs directory
run: mkdir -p build/logs
- name: Execute tests
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: logs
path: build/logs
+4 -2
View File
@@ -1,6 +1,8 @@
phpunit.result.cache
.idea
build/
report/
vendor/
composer.lock
phpunit.result.cache
.phpunit*
.idea
.vscode
-32
View File
@@ -1,32 +0,0 @@
language: php
matrix:
include:
- php: 7.4
dist: bionic
env:
- psalm=yes
- php: 8.0
env:
- psalm=yes
dist: bionic
#ppc64le support code
- php: 7.4
arch: ppc64le
env:
- psalm=yes
dist: bionic
install:
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi
- if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm; fi
before_script:
- mkdir -p build/logs
script:
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
- if [ "$psalm" = "yes" ]; then vendor/bin/psalm; fi
after_script:
- php vendor/bin/coveralls
+1 -1
View File
@@ -5,7 +5,7 @@
* Access to local part and domain part from EmailParser
* Validations outside of the scope of the RFC will be considered "extra" validations, thus opening the door for adding new; will live in their own folder "extra" (as requested in #248, #195, #183).
## Breacking changes
## Breaking changes
* PHP version upgraded to match Symfony's (as of 12/2020).
* DNSCheckValidation now fails for missing MX records. While the RFC argues that the existence of only A records to be valid, starting in v3 they will be considered invalid.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2013-2021 Eduardo Gulias Davis
Copyright (c) 2013-2022 Eduardo Gulias Davis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,6 +1,6 @@
# EmailValidator
[![Build Status](https://app.travis-ci.com/egulias/EmailValidator.svg?branch=3.x)](https://app.travis-ci.com/github/egulias/EmailValidator)
[![Build Status](https://github.com/egulias/EmailValidator/workflows/tests/badge.svg)](https://github.com/egulias/EmailValidator/actions)
[![Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=3.x)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=3.x)
[![Test Coverage](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/coverage.png?b=3.x)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=3.x)
+1 -2
View File
@@ -14,11 +14,10 @@
},
"require": {
"php": ">=7.2",
"doctrine/lexer": "^1.2",
"doctrine/lexer": "^1.2|^2",
"symfony/polyfill-intl-idn": "^1.15"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^8.5.8|^9.3.3",
"vimeo/psalm": "^4"
},
Generated
-5028
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
<?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" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" executionOrder="defects" processIsolation="false" stopOnFailure="false">
<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">
<coverage>
<include>
<directory>./src/</directory>
+5 -16
View File
@@ -1,19 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
<file src="src/EmailLexer.php">
<DocblockTypeContradiction occurrences="1">
<code>self::$nullToken</code>
</DocblockTypeContradiction>
</file>
<file src="src/Parser/Parser.php">
<MissingReturnType occurrences="1">
<code>parse</code>
</MissingReturnType>
</file>
<file src="src/Validation/SpoofCheckValidation.php">
<UndefinedClass occurrences="2">
<code>Spoofchecker</code>
<code>Spoofchecker</code>
</UndefinedClass>
<files psalm-version="5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863">
<file src="src/Parser/DomainPart.php">
<RedundantConditionGivenDocblockType occurrences="1">
<code>null !== $this-&gt;lexer-&gt;token['type']</code>
</RedundantConditionGivenDocblockType>
</file>
</files>
+7 -1
View File
@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd"
errorBaseline="./psalm.baseline.xml"
errorBaseline="psalm.baseline.xml"
>
<projectFiles>
<directory name="src" />
@@ -13,5 +13,11 @@
</projectFiles>
<issueHandlers>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- This issue needs to be resolved before upgrading to Lexer 3 -->
<referencedMethod name="Doctrine\Common\Lexer\Token::offsetGet"/>
</errorLevel>
</DeprecatedMethod>
</issueHandlers>
</psalm>
+66 -58
View File
@@ -3,58 +3,62 @@
namespace Egulias\EmailValidator;
use Doctrine\Common\Lexer\AbstractLexer;
use Doctrine\Common\Lexer\Token;
/**
* @extends AbstractLexer<int, string>
*/
class EmailLexer extends AbstractLexer
{
//ASCII values
const S_EMPTY = null;
const C_NUL = 0;
const S_HTAB = 9;
const S_LF = 10;
const S_CR = 13;
const S_SP = 32;
const EXCLAMATION = 33;
const S_DQUOTE = 34;
const NUMBER_SIGN = 35;
const DOLLAR = 36;
const PERCENTAGE = 37;
const AMPERSAND = 38;
const S_SQUOTE = 39;
const S_OPENPARENTHESIS = 40;
const S_CLOSEPARENTHESIS = 41;
const ASTERISK = 42;
const S_PLUS = 43;
const S_COMMA = 44;
const S_HYPHEN = 45;
const S_DOT = 46;
const S_SLASH = 47;
const S_COLON = 58;
const S_SEMICOLON = 59;
const S_LOWERTHAN = 60;
const S_EQUAL = 61;
const S_GREATERTHAN = 62;
const QUESTIONMARK = 63;
const S_AT = 64;
const S_OPENBRACKET = 91;
const S_BACKSLASH = 92;
const S_CLOSEBRACKET = 93;
const CARET = 94;
const S_UNDERSCORE = 95;
const S_BACKTICK = 96;
const S_OPENCURLYBRACES = 123;
const S_PIPE = 124;
const S_CLOSECURLYBRACES = 125;
const S_TILDE = 126;
const C_DEL = 127;
const INVERT_QUESTIONMARK= 168;
const INVERT_EXCLAMATION = 173;
const GENERIC = 300;
const S_IPV6TAG = 301;
const INVALID = 302;
const CRLF = 1310;
const S_DOUBLECOLON = 5858;
const ASCII_INVALID_FROM = 127;
const ASCII_INVALID_TO = 199;
public const S_EMPTY = null;
public const C_NUL = 0;
public const S_HTAB = 9;
public const S_LF = 10;
public const S_CR = 13;
public const S_SP = 32;
public const EXCLAMATION = 33;
public const S_DQUOTE = 34;
public const NUMBER_SIGN = 35;
public const DOLLAR = 36;
public const PERCENTAGE = 37;
public const AMPERSAND = 38;
public const S_SQUOTE = 39;
public const S_OPENPARENTHESIS = 40;
public const S_CLOSEPARENTHESIS = 41;
public const ASTERISK = 42;
public const S_PLUS = 43;
public const S_COMMA = 44;
public const S_HYPHEN = 45;
public const S_DOT = 46;
public const S_SLASH = 47;
public const S_COLON = 58;
public const S_SEMICOLON = 59;
public const S_LOWERTHAN = 60;
public const S_EQUAL = 61;
public const S_GREATERTHAN = 62;
public const QUESTIONMARK = 63;
public const S_AT = 64;
public const S_OPENBRACKET = 91;
public const S_BACKSLASH = 92;
public const S_CLOSEBRACKET = 93;
public const CARET = 94;
public const S_UNDERSCORE = 95;
public const S_BACKTICK = 96;
public const S_OPENCURLYBRACES = 123;
public const S_PIPE = 124;
public const S_CLOSECURLYBRACES = 125;
public const S_TILDE = 126;
public const C_DEL = 127;
public const INVERT_QUESTIONMARK= 168;
public const INVERT_EXCLAMATION = 173;
public const GENERIC = 300;
public const S_IPV6TAG = 301;
public const INVALID = 302;
public const CRLF = 1310;
public const S_DOUBLECOLON = 5858;
public const ASCII_INVALID_FROM = 127;
public const ASCII_INVALID_TO = 199;
/**
* US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
@@ -107,11 +111,11 @@ class EmailLexer extends AbstractLexer
'¡' => self::INVERT_EXCLAMATION,
];
const INVALID_CHARS_REGEX = "/[^\p{S}\p{C}\p{Cc}]+/iu";
public const INVALID_CHARS_REGEX = "/[^\p{S}\p{C}\p{Cc}]+/iu";
const VALID_UTF8_REGEX = '/\p{Cc}+/u';
public const VALID_UTF8_REGEX = '/\p{Cc}+/u';
const CATCHABLE_PATTERNS = [
public const CATCHABLE_PATTERNS = [
'[a-zA-Z]+[46]?', //ASCII and domain literal
'[^\x00-\x7F]', //UTF-8
'[0-9]+',
@@ -121,11 +125,11 @@ class EmailLexer extends AbstractLexer
'.',
];
const NON_CATCHABLE_PATTERNS = [
public const NON_CATCHABLE_PATTERNS = [
'[\xA0-\xff]+',
];
const MODIFIERS = 'iu';
public const MODIFIERS = 'iu';
/** @var bool */
protected $hasInvalidTokens = false;
@@ -140,18 +144,20 @@ class EmailLexer extends AbstractLexer
/**
* The last matched/seen token.
*
* @var array
* @var array|Token
*
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{value:string, type:null|int, position:int}
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{value:string, type:null|int, position:int}|Token<int, string>
*/
public $token;
/**
* The next token in the input.
*
* @var array{position: int, type: int|null|string, value: int|string}|null
* @var array|Token|null
*
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{position: int, type: int|null|string, value: int|string}|Token<int, string>|null
*/
public $lookahead;
@@ -210,7 +216,9 @@ class EmailLexer extends AbstractLexer
$this->accumulator .= $this->token['value'];
}
$this->previous = $this->token;
$this->previous = $this->token instanceof Token
? ['value' => $this->token->value, 'type' => $this->token->type, 'position' => $this->token->position]
: $this->token;
if($this->lookahead === null) {
$this->lookahead = self::$nullToken;
+1 -2
View File
@@ -2,7 +2,6 @@
namespace Egulias\EmailValidator;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Result\Result;
use Egulias\EmailValidator\Parser\LocalPart;
use Egulias\EmailValidator\Parser\DomainPart;
@@ -13,7 +12,7 @@ use Egulias\EmailValidator\Result\Reason\NoLocalPart;
class EmailParser extends Parser
{
const EMAIL_MAX_LENGTH = 254;
public const EMAIL_MAX_LENGTH = 254;
/**
* @var string
+2 -3
View File
@@ -2,7 +2,6 @@
namespace Egulias\EmailValidator;
use Egulias\EmailValidator\Parser;
use Egulias\EmailValidator\Result\Result;
use Egulias\EmailValidator\Parser\IDLeftPart;
use Egulias\EmailValidator\Parser\IDRightPart;
@@ -14,7 +13,7 @@ use Egulias\EmailValidator\Result\Reason\NoLocalPart;
class MessageIDParser extends Parser
{
const EMAILID_MAX_LENGTH = 254;
public const EMAILID_MAX_LENGTH = 254;
/**
* @var string
@@ -89,4 +88,4 @@ class MessageIDParser extends Parser
$this->warnings[EmailTooLong::CODE] = new EmailTooLong();
}
}
}
}
+3 -2
View File
@@ -59,7 +59,8 @@ class Comment extends PartParser
if($this->openedParenthesis >= 1) {
return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']);
} else if ($this->openedParenthesis < 0) {
}
if ($this->openedParenthesis < 0) {
return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']);
}
@@ -100,4 +101,4 @@ class Comment extends PartParser
return true;
}
}
}
}
@@ -15,4 +15,4 @@ interface CommentStrategy
public function endOfLoopValidations(EmailLexer $lexer) : Result;
public function getWarnings() : array;
}
}
+1 -1
View File
@@ -34,4 +34,4 @@ class DomainComment implements CommentStrategy
{
return [];
}
}
}
+1 -1
View File
@@ -34,4 +34,4 @@ class LocalComment implements CommentStrategy
{
return $this->warnings;
}
}
}
+3 -3
View File
@@ -22,9 +22,9 @@ use Egulias\EmailValidator\Warning\DomainLiteral as WarningDomainLiteral;
class DomainLiteral extends PartParser
{
const IPV4_REGEX = '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/';
public const IPV4_REGEX = '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/';
const OBSOLETE_WARNINGS = [
public const OBSOLETE_WARNINGS = [
EmailLexer::INVALID,
EmailLexer::C_DEL,
EmailLexer::S_LF,
@@ -208,4 +208,4 @@ class DomainLiteral extends PartParser
}
}
}
}
+7 -3
View File
@@ -2,6 +2,7 @@
namespace Egulias\EmailValidator\Parser;
use Doctrine\Common\Lexer\Token;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Warning\TLD;
use Egulias\EmailValidator\Result\Result;
@@ -24,8 +25,8 @@ use Egulias\EmailValidator\Parser\DomainLiteral as DomainLiteralParser;
class DomainPart extends PartParser
{
const DOMAIN_MAX_LENGTH = 253;
const LABEL_MAX_LENGTH = 63;
public const DOMAIN_MAX_LENGTH = 253;
public const LABEL_MAX_LENGTH = 63;
/**
* @var string
@@ -212,7 +213,10 @@ class DomainPart extends PartParser
return new ValidEmail();
}
private function checkNotAllowedChars(array $token) : Result
/**
* @psalm-param array|Token<int, string> $token
*/
private function checkNotAllowedChars($token) : Result
{
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
if (isset($notAllowed[$token['type']])) {
+1 -2
View File
@@ -2,7 +2,6 @@
namespace Egulias\EmailValidator\Parser;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Parser\Parser;
use Egulias\EmailValidator\Result\ValidEmail;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Warning\CFWSWithFWS;
@@ -85,4 +84,4 @@ class DoubleQuote extends PartParser
return new ValidEmail();
}
}
}
+2 -2
View File
@@ -15,7 +15,7 @@ use Egulias\EmailValidator\Result\ValidEmail;
class FoldingWhiteSpace extends PartParser
{
const FWS_TYPES = [
public const FWS_TYPES = [
EmailLexer::S_SP,
EmailLexer::S_HTAB,
EmailLexer::S_CR,
@@ -83,4 +83,4 @@ class FoldingWhiteSpace extends PartParser
return in_array($this->lexer->token['type'], self::FWS_TYPES);
}
}
}
+1 -2
View File
@@ -3,7 +3,6 @@
namespace Egulias\EmailValidator\Parser;
use Egulias\EmailValidator\Result\Result;
use Egulias\EmailValidator\Parser\LocalPart;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Result\Reason\CommentsInIDRight;
@@ -13,4 +12,4 @@ class IDLeftPart extends LocalPart
{
return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']);
}
}
}
+1 -1
View File
@@ -26,4 +26,4 @@ class IDRightPart extends DomainPart
}
return new ValidEmail();
}
}
}
+2 -2
View File
@@ -15,7 +15,7 @@ use Egulias\EmailValidator\Parser\CommentStrategy\LocalComment;
class LocalPart extends PartParser
{
const INVALID_TOKENS = [
public const INVALID_TOKENS = [
EmailLexer::S_COMMA => EmailLexer::S_COMMA,
EmailLexer::S_CLOSEBRACKET => EmailLexer::S_CLOSEBRACKET,
EmailLexer::S_OPENBRACKET => EmailLexer::S_OPENBRACKET,
@@ -162,4 +162,4 @@ class LocalPart extends PartParser
return new ValidEmail();
}
}
}
+1 -1
View File
@@ -60,4 +60,4 @@ abstract class PartParser
&&
$this->lexer->token['type'] !== EmailLexer::GENERIC;
}
}
}
+2 -2
View File
@@ -6,7 +6,7 @@ use Egulias\EmailValidator\Result\Reason\Reason;
class InvalidEmail implements Result
{
private $token;
private $token;
/**
* @var Reason
*/
@@ -43,4 +43,4 @@ class InvalidEmail implements Result
return $this->reason;
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class AtextAfterCFWS implements Reason
{
return 'ATEXT found after CFWS';
}
}
}
+2 -2
View File
@@ -4,8 +4,8 @@ namespace Egulias\EmailValidator\Result\Reason;
class CRLFAtTheEnd implements Reason
{
const CODE = 149;
const REASON = "CRLF at the end";
public const CODE = 149;
public const REASON = "CRLF at the end";
public function code() : int
{
+1 -1
View File
@@ -13,4 +13,4 @@ class CharNotAllowed implements Reason
{
return "Character not allowed";
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class CommaInDomain implements Reason
{
return "Comma ',' is not allowed in domain part";
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class CommentsInIDRight implements Reason
{
return 'Comments are not allowed in IDRight for message-id';
}
}
}
+1 -1
View File
@@ -10,4 +10,4 @@ abstract class DetailedReason implements Reason
{
$this->detailedDescription = $details;
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class DomainAcceptsNoMail implements Reason
{
return 'Domain accepts no mail (Null MX, RFC7505)';
}
}
}
+1 -1
View File
@@ -23,4 +23,4 @@ class ExceptionFound implements Reason
{
return $this->exception->getMessage();
}
}
}
@@ -13,4 +13,4 @@ class ExpectingDomainLiteralClose implements Reason
{
return "Closing bracket ']' for domain literal not found";
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class LocalOrReservedDomain implements Reason
{
return 'Local, mDNS or reserved domain (RFC2606, RFC6762)';
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class NoDNSRecord implements Reason
{
return 'No MX or A DSN record was found for this email';
}
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ interface Reason
* Short description of the result, human readable.
*/
public function description() : string;
}
}
+1 -1
View File
@@ -13,4 +13,4 @@ class UnOpenedComment implements Reason
{
return 'Missing opening comment parentheses - https://tools.ietf.org/html/rfc5322#section-3.2.2';
}
}
}
+1 -1
View File
@@ -23,4 +23,4 @@ class UnusualElements implements Reason
{
return 'Unusual element found, wourld render invalid in majority of cases. Element found: ' . $this->element;
}
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ interface Result
* Code for user land to act upon.
*/
public function code() : int;
}
}
+1 -2
View File
@@ -1,7 +1,6 @@
<?php
namespace Egulias\EmailValidator\Result;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Result\Reason\SpoofEmail as ReasonSpoofEmail;
class SpoofEmail extends InvalidEmail
@@ -11,4 +10,4 @@ class SpoofEmail extends InvalidEmail
$this->reason = new ReasonSpoofEmail();
parent::__construct($this->reason, '');
}
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ class ValidEmail implements Result
return 0;
}
}
}
+3 -4
View File
@@ -2,7 +2,6 @@
namespace Egulias\EmailValidator\Validation;
use Egulias\EmailValidator\Validation\DNSGetRecordWrapper;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Result\Reason\DomainAcceptsNoMail;
@@ -22,7 +21,7 @@ class DNSCheckValidation implements EmailValidation
* Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),
* mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)
*/
const RESERVED_DNS_TOP_LEVEL_NAMES = [
public const RESERVED_DNS_TOP_LEVEL_NAMES = [
// Reserved Top Level DNS Names
'test',
'example',
@@ -61,7 +60,7 @@ class DNSCheckValidation implements EmailValidation
*/
private $dnsGetRecord;
public function __construct(DNSGetRecordWrapper $dnsGetRecord = null)
public function __construct(?DNSGetRecordWrapper $dnsGetRecord = null)
{
if (!function_exists('idn_to_ascii')) {
throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
@@ -189,4 +188,4 @@ class DNSCheckValidation implements EmailValidation
return true;
}
}
}
+1 -1
View File
@@ -25,4 +25,4 @@ class DNSGetRecordWrapper
restore_error_handler();
}
}
}
}
+1 -1
View File
@@ -32,4 +32,4 @@ class DNSRecords
}
}
}
@@ -9,7 +9,7 @@ class EmptyValidationList extends \InvalidArgumentException
/**
* @param int $code
*/
public function __construct($code = 0, Exception $previous = null)
public function __construct($code = 0, ?Exception $previous = null)
{
parent::__construct("Empty validation list is not allowed", $code, $previous);
}
+2 -2
View File
@@ -13,13 +13,13 @@ class MultipleValidationWithAnd implements EmailValidation
* If one of validations fails, the remaining validations will be skipped.
* This means MultipleErrors will only contain a single error, the first found.
*/
const STOP_ON_ERROR = 0;
public const STOP_ON_ERROR = 0;
/**
* All of validations will be invoked even if one of them got failure.
* So MultipleErrors will contain all causes.
*/
const ALLOW_ALL_ERRORS = 1;
public const ALLOW_ALL_ERRORS = 1;
/**
* @var EmailValidation[]
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class AddressLiteral extends Warning
{
const CODE = 12;
public const CODE = 12;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class CFWSNearAt extends Warning
{
const CODE = 49;
public const CODE = 49;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class CFWSWithFWS extends Warning
{
const CODE = 18;
public const CODE = 18;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class Comment extends Warning
{
const CODE = 17;
public const CODE = 17;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class DeprecatedComment extends Warning
{
const CODE = 37;
public const CODE = 37;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class DomainLiteral extends Warning
{
const CODE = 70;
public const CODE = 70;
public function __construct()
{
+1 -1
View File
@@ -6,7 +6,7 @@ use Egulias\EmailValidator\EmailParser;
class EmailTooLong extends Warning
{
const CODE = 66;
public const CODE = 66;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6BadChar extends Warning
{
const CODE = 74;
public const CODE = 74;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6ColonEnd extends Warning
{
const CODE = 77;
public const CODE = 77;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6ColonStart extends Warning
{
const CODE = 76;
public const CODE = 76;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6Deprecated extends Warning
{
const CODE = 13;
public const CODE = 13;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6DoubleColon extends Warning
{
const CODE = 73;
public const CODE = 73;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6GroupCount extends Warning
{
const CODE = 72;
public const CODE = 72;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class IPV6MaxGroups extends Warning
{
const CODE = 75;
public const CODE = 75;
public function __construct()
{
+2 -2
View File
@@ -4,8 +4,8 @@ namespace Egulias\EmailValidator\Warning;
class LocalTooLong extends Warning
{
const CODE = 64;
const LOCAL_PART_LENGTH = 64;
public const CODE = 64;
public const LOCAL_PART_LENGTH = 64;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class NoDNSMXRecord extends Warning
{
const CODE = 6;
public const CODE = 6;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class ObsoleteDTEXT extends Warning
{
const CODE = 71;
public const CODE = 71;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class QuotedPart extends Warning
{
const CODE = 36;
public const CODE = 36;
/**
* @param scalar $prevToken
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class QuotedString extends Warning
{
const CODE = 11;
public const CODE = 11;
/**
* @param scalar $prevToken
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
class TLD extends Warning
{
const CODE = 9;
public const CODE = 9;
public function __construct()
{
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Egulias\EmailValidator\Warning;
abstract class Warning
{
const CODE = 0;
public const CODE = 0;
/**
* @var string