From c0c888ae105f283c40c4c6cc68e3f92cdfb5214d Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 25 Jan 2017 22:45:20 +0100 Subject: [PATCH] removes trailing spaces (#136) --- EmailValidator/EmailValidator.php | 6 +++--- EmailValidator/Exception/InvalidEmail.php | 2 +- EmailValidator/Parser/DomainPart.php | 2 +- EmailValidator/Validation/DNSCheckValidation.php | 2 +- EmailValidator/Validation/MultipleErrors.php | 4 ++-- .../Validation/MultipleValidationWithAnd.php | 2 +- EmailValidator/Validation/RFCValidation.php | 4 ++-- EmailValidator/Validation/SpoofCheckValidation.php | 4 ++-- EmailValidator/Warning/Warning.php | 2 +- Tests/EmailValidator/EmailValidatorTest.php | 2 +- .../Validation/DNSCheckValidationTest.php | 6 +++--- .../EmailValidator/Validation/IsEmailFunctionTests.php | 5 ++--- .../Validation/MultipleValidationWitAndTest.php | 10 +++++----- .../Validation/NoRFCWarningsValidationTest.php | 4 ++-- Tests/EmailValidator/Validation/RFCValidationTest.php | 6 +++--- .../Validation/SpoofCheckValidationTest.php | 6 +++--- 16 files changed, 33 insertions(+), 34 deletions(-) diff --git a/EmailValidator/EmailValidator.php b/EmailValidator/EmailValidator.php index c38c55e..44b4b93 100644 --- a/EmailValidator/EmailValidator.php +++ b/EmailValidator/EmailValidator.php @@ -11,7 +11,7 @@ class EmailValidator * @var EmailLexer */ private $lexer; - + /** * @var array */ @@ -21,7 +21,7 @@ class EmailValidator * @var InvalidEmail */ protected $error; - + public function __construct() { $this->lexer = new EmailLexer(); @@ -37,7 +37,7 @@ public function isValid($email, EmailValidation $emailValidation) $isValid = $emailValidation->isValid($email, $this->lexer); $this->warnings = $emailValidation->getWarnings(); $this->error = $emailValidation->getError(); - + return $isValid; } diff --git a/EmailValidator/Exception/InvalidEmail.php b/EmailValidator/Exception/InvalidEmail.php index cc96d49..1c0218e 100644 --- a/EmailValidator/Exception/InvalidEmail.php +++ b/EmailValidator/Exception/InvalidEmail.php @@ -6,7 +6,7 @@ abstract class InvalidEmail extends \InvalidArgumentException { const REASON = "Invalid email"; const CODE = 0; - + public function __construct() { parent::__construct(static::REASON, static::CODE); diff --git a/EmailValidator/Parser/DomainPart.php b/EmailValidator/Parser/DomainPart.php index 28f450f..51769de 100644 --- a/EmailValidator/Parser/DomainPart.php +++ b/EmailValidator/Parser/DomainPart.php @@ -170,7 +170,7 @@ protected function doParseDomainPart() return $domain; } - + private function checkNotAllowedChars($token) { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; diff --git a/EmailValidator/Validation/DNSCheckValidation.php b/EmailValidator/Validation/DNSCheckValidation.php index c7f86fa..2f3a237 100644 --- a/EmailValidator/Validation/DNSCheckValidation.php +++ b/EmailValidator/Validation/DNSCheckValidation.php @@ -46,7 +46,7 @@ protected function checkDNS($host) { $Aresult = true; $MXresult = checkdnsrr($host, 'MX'); - + if (!$MXresult) { $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); $Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'); diff --git a/EmailValidator/Validation/MultipleErrors.php b/EmailValidator/Validation/MultipleErrors.php index a59c36c..d5e87d8 100644 --- a/EmailValidator/Validation/MultipleErrors.php +++ b/EmailValidator/Validation/MultipleErrors.php @@ -12,13 +12,13 @@ class MultipleErrors extends InvalidEmail * @var array */ private $errors = []; - + public function __construct(array $errors) { $this->errors = $errors; parent::__construct(); } - + public function getErrors() { return $this->errors; diff --git a/EmailValidator/Validation/MultipleValidationWithAnd.php b/EmailValidator/Validation/MultipleValidationWithAnd.php index 3e5b058..43fa42a 100644 --- a/EmailValidator/Validation/MultipleValidationWithAnd.php +++ b/EmailValidator/Validation/MultipleValidationWithAnd.php @@ -48,7 +48,7 @@ public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) if (count($validations) == 0) { throw new EmptyValidationList(); } - + $this->validations = $validations; $this->mode = $mode; } diff --git a/EmailValidator/Validation/RFCValidation.php b/EmailValidator/Validation/RFCValidation.php index 75635d9..c4ffe35 100644 --- a/EmailValidator/Validation/RFCValidation.php +++ b/EmailValidator/Validation/RFCValidation.php @@ -22,7 +22,7 @@ class RFCValidation implements EmailValidation * @var InvalidEmail */ private $error; - + public function isValid($email, EmailLexer $emailLexer) { $this->parser = new EmailParser($emailLexer); @@ -32,7 +32,7 @@ public function isValid($email, EmailLexer $emailLexer) $this->error = $invalid; return false; } - + $this->warnings = $this->parser->getWarnings(); return true; } diff --git a/EmailValidator/Validation/SpoofCheckValidation.php b/EmailValidator/Validation/SpoofCheckValidation.php index 9fc30f1..dcb2b8a 100644 --- a/EmailValidator/Validation/SpoofCheckValidation.php +++ b/EmailValidator/Validation/SpoofCheckValidation.php @@ -18,11 +18,11 @@ public function isValid($email, EmailLexer $emailLexer) { $checker = new Spoofchecker(); $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); - + if ($checker->isSuspicious($email)) { $this->error = new SpoofEmail(); } - + return $this->error === null; } diff --git a/EmailValidator/Warning/Warning.php b/EmailValidator/Warning/Warning.php index ffd5ad4..ec6a365 100644 --- a/EmailValidator/Warning/Warning.php +++ b/EmailValidator/Warning/Warning.php @@ -22,7 +22,7 @@ public function RFCNumber() { return $this->rfcNumber; } - + public function __toString() { return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; diff --git a/Tests/EmailValidator/EmailValidatorTest.php b/Tests/EmailValidator/EmailValidatorTest.php index 4b018db..fbd4f45 100644 --- a/Tests/EmailValidator/EmailValidatorTest.php +++ b/Tests/EmailValidator/EmailValidatorTest.php @@ -17,7 +17,7 @@ public function testValidationIsUsed() $this->assertTrue($validator->isValid("example@example.com", $validation)); } - + public function testMultipleValidation() { $validator = new EmailValidator(); diff --git a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php b/Tests/EmailValidator/Validation/DNSCheckValidationTest.php index 105de80..27806a2 100644 --- a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php +++ b/Tests/EmailValidator/Validation/DNSCheckValidationTest.php @@ -34,13 +34,13 @@ public function testValidDNS($validEmail) $validation = new DNSCheckValidation(); $this->assertTrue($validation->isValid($validEmail, new EmailLexer())); } - + public function testInvalidDNS() { $validation = new DNSCheckValidation(); $this->assertFalse($validation->isValid("example@invalid.example.com", new EmailLexer())); } - + public function testDNSWarnings() { $validation = new DNSCheckValidation(); @@ -48,7 +48,7 @@ public function testDNSWarnings() $validation->isValid("example@invalid.example.com", new EmailLexer()); $this->assertEquals($expectedWarnings, $validation->getWarnings()); } - + public function testNoDNSError() { $validation = new DNSCheckValidation(); diff --git a/Tests/EmailValidator/Validation/IsEmailFunctionTests.php b/Tests/EmailValidator/Validation/IsEmailFunctionTests.php index 511182b..adac6e7 100644 --- a/Tests/EmailValidator/Validation/IsEmailFunctionTests.php +++ b/Tests/EmailValidator/Validation/IsEmailFunctionTests.php @@ -28,8 +28,8 @@ public function testAgainstIsEmailTestSuite($email) public function isEmailTestSuite() { $testSuite = dirname(__FILE__) . '/../../resources/is_email_tests.xml'; - $document = new \DOMDocument(); - $document->load($testSuite); + $document = new \DOMDocument(); + $document->load($testSuite); $elements = $document->getElementsByTagName('test'); $tests = []; @@ -40,5 +40,4 @@ public function isEmailTestSuite() return $tests; } - } diff --git a/Tests/EmailValidator/Validation/MultipleValidationWitAndTest.php b/Tests/EmailValidator/Validation/MultipleValidationWitAndTest.php index ab4ecdf..357c478 100644 --- a/Tests/EmailValidator/Validation/MultipleValidationWitAndTest.php +++ b/Tests/EmailValidator/Validation/MultipleValidationWitAndTest.php @@ -54,16 +54,16 @@ public function testAccumulatesWarnings() DomainLiteral::CODE => new DomainLiteral() ]; $expectedResult = array_merge($warnings1, $warnings2); - + $lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer"); $validation1 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); $validation1->expects($this->any())->method("isValid")->willReturn(true); $validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1); - + $validation2 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); $validation2->expects($this->any())->method("isValid")->willReturn(false); $validation2->expects($this->once())->method("getWarnings")->willReturn($warnings2); - + $multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2]); $multipleValidation->isValid("example@example.com", $lexer); $this->assertEquals($expectedResult, $multipleValidation->getWarnings()); @@ -73,11 +73,11 @@ public function testGathersAllTheErrors() { $error1 = new CommaInDomain(); $error2 = new NoDomainPart(); - + $expectedResult = new MultipleErrors([$error1, $error2]); $lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer"); - + $validation1 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); $validation1->expects($this->any())->method("isValid")->willReturn(true); $validation1->expects($this->once())->method("getWarnings")->willReturn([]); diff --git a/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php b/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php index e200b94..b0b0676 100644 --- a/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php +++ b/Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php @@ -12,7 +12,7 @@ class NoRFCWarningsValidationTest extends \PHPUnit_Framework_TestCase public function testInvalidEmailIsInvalid() { $validation = new NoRFCWarningsValidation(); - + $this->assertFalse($validation->isValid('non-email-string', new EmailLexer())); $this->assertInstanceOf(NoDomainPart::class, $validation->getError()); } @@ -24,7 +24,7 @@ public function testEmailWithWarningsIsInvalid() $this->assertFalse($validation->isValid(str_repeat('x', 254).'@example.com', new EmailLexer())); // too long email $this->assertInstanceOf(RFCWarnings::class, $validation->getError()); } - + public function testEmailWithoutWarningsIsValid() { $validation = new NoRFCWarningsValidation(); diff --git a/Tests/EmailValidator/Validation/RFCValidationTest.php b/Tests/EmailValidator/Validation/RFCValidationTest.php index c13f7c1..23edf06 100644 --- a/Tests/EmailValidator/Validation/RFCValidationTest.php +++ b/Tests/EmailValidator/Validation/RFCValidationTest.php @@ -47,7 +47,7 @@ class RFCValidationTest extends \PHPUnit_Framework_TestCase * @var EmailLexer */ protected $lexer; - + protected function setUp() { $this->validator = new RFCValidation(); @@ -106,7 +106,7 @@ public function testInvalidUTF8Email() $email = "\x80\x81\x82@\x83\x84\x85.\x86\x87\x88"; $this->assertFalse($this->validator->isValid($email, $this->lexer)); } - + /** * @dataProvider getInvalidEmails */ @@ -228,7 +228,7 @@ public function testInvalidEmailsWithWarningsCheck($expectedWarnings, $email) $this->assertTrue(isset($expectedWarnings[$warning->code()])); } } - + public function getInvalidEmailsWithWarnings() { return [ diff --git a/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php b/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php index 2e5de7b..7889bde 100644 --- a/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php +++ b/Tests/EmailValidator/Validation/SpoofCheckValidationTest.php @@ -14,17 +14,17 @@ public function testUTF8EmailAreValid($email) { $this->markTestSkipped("Skipped for Travis CI since it is failing on this test for unknown reasons."); $validation = new SpoofCheckValidation(); - + $this->assertTrue($validation->isValid($email, new EmailLexer())); } - + public function testEmailWithSpoofsIsInvalid() { $validation = new SpoofCheckValidation(); $this->assertFalse($validation->isValid("Кириллица"."latin漢字"."ひらがな"."カタカナ", new EmailLexer())); } - + public function validUTF8EmailsProvider() { return [