-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use spread syntax instead of array_merge() * use type cast instead of function cast * removed redundant returns * removed redundant phpdoc - type is already inferred * removed invalid phpdoc - type is already inferred The PHPDoc return type hint was incomplete, it should have been `InvalidEmail|null`, however, it can be removed altogether as the return type is already inferred from the code. * changed warnEscaping()'s return value from bool to void This is not a breaking change as the method is private, and it's only used at one place, where the return value was not used anyway. * made private class property local `private $parser` was used in only one place, hence it can be local, there is no reason to put it into the class' scope. * removed unnecessary type casting Concatenation already casts `static::CODE` from `int` to `string`, no reason to do it explicitly. * removed redundant initializers - constructor overwrites them immediately * removed redundant else block * simplified if-else statement * wrapped if body in brackets to comply with PSR12 * fixed README formatting - fixed numbering at the `Available validations` section - fixed overall formatting * Revert "removed redundant phpdoc - type is already inferred" This reverts commit 68a9ae2. * don't wrap long lines * make properties typed Also using constructor property promotion, see more info about it [here](https://php.watch/versions/8.0/constructor-property-promotion).
- Loading branch information
Showing
16 changed files
with
56 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
A library for validating emails against several RFC. | ||
|
||
## Supported RFCs ## | ||
## Supported RFCs | ||
|
||
This library aims to support RFCs: | ||
|
||
|
@@ -21,31 +21,31 @@ This library aims to support RFCs: | |
|
||
**Current major version with full support is v3** | ||
|
||
| Version | Released | EOL | Only critical bug fixes | Full | | ||
| :-----: | :--------: | :---: | :---------------------: | :---: | | ||
| v4.x | 2023/01/07 | - | X | X | | ||
| v3.x | 2020/12/29 | - | X | | | ||
| v2.1.x | 2016/05/16 | YES | | | | ||
| v1.2 | 2013/19/05 | YES | | | | ||
| Version | Released | EOL | Only critical bug fixes | Full | | ||
|:-------:|:----------:|:---:|:-----------------------:|:----:| | ||
| v4.x | 2023/01/07 | - | X | X | | ||
| v3.x | 2020/12/29 | - | X | | | ||
| v2.1.x | 2016/05/16 | YES | | | | ||
| v1.2 | 2013/19/05 | YES | | | | ||
|
||
|
||
## Requirements ## | ||
## Requirements | ||
|
||
* PHP 8.1 | ||
* [Composer](https://getcomposer.org) is required for installation | ||
* [Spoofchecking](/src/Validation/Extra/SpoofCheckValidation.php) and [DNSCheckValidation](/src/Validation/DNSCheckValidation.php) validation requires that your PHP system has the [PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php) (also known as PHP Intl) | ||
|
||
**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 | ||
|
||
```shell | ||
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). | ||
|
||
|
@@ -61,14 +61,14 @@ $validator->isValid("[email protected]", new RFCValidation()); //true | |
``` | ||
|
||
|
||
### Available validations ### | ||
### Available validations | ||
|
||
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. | ||
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. | ||
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. | ||
7. [Your own validation](#how-to-extend): You can extend the library behaviour by implementing your own validations. | ||
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. | ||
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. | ||
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. | ||
|
||
|
@@ -89,21 +89,21 @@ $multipleValidations = new MultipleValidationWithAnd([ | |
$validator->isValid("[email protected]", $multipleValidations); //true | ||
``` | ||
|
||
#### Additional validations #### | ||
#### Additional validations | ||
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. | ||
|
||
|
||
### 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. | ||
|
||
## Contributing ## | ||
## Contributing | ||
|
||
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)) | ||
|
||
|
@@ -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 | ||
* Dominic Sayers [@dominicsayers](https://github.com/dominicsayers): The original isemail function | ||
|
||
## License ## | ||
## License | ||
|
||
Released under the MIT License attached with this code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.