[
  {
    "path": ".gitattributes",
    "content": "/documentation export-ignore\n/tests export-ignore\n/.* export-ignore\n/phpunit.xml.dist export-ignore\n/psalm.xml export-ignore\n/README.md export-ignore\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# Thanks!\n\ngithub: [egulias]"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"composer\" \n    directory: \"/\" \n    schedule:\n      interval: \"weekly\"\n"
  },
  {
    "path": ".github/workflows/static-analysis.yml",
    "content": "name: static analysis\n\non:\n  push:\n    branches:\n      - '*.x'\n  pull_request:\n\njobs:\n  psalm:\n    runs-on: ubuntu-22.04\n\n    strategy:\n      fail-fast: true\n\n    name: Psalm\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: 8.2\n          ini-values: error_reporting=E_ALL\n          tools: composer:v2\n          coverage: none\n\n      - name: Install dependencies\n        uses: ramsey/composer-install@v2\n\n      - name: Execute Psalm\n        run: vendor/bin/psalm\n"
  },
  {
    "path": ".github/workflows/tests.yml",
    "content": "name: unit-tests\n\non:\n  push:\n    branches:\n      - '*.x'\n  pull_request:\n\njobs:\n  tests:\n    runs-on: ubuntu-22.04\n\n    strategy:\n      fail-fast: true\n      matrix:\n        php: ['8.1', '8.2', '8.3']\n        deps: [highest]\n\n        include:\n          - php: '8.1'\n            deps: lowest\n\n    name: PHP ${{ matrix.php }} / ${{ matrix.deps }}\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php }}\n          ini-values: error_reporting=E_ALL\n          tools: composer:v2\n          coverage: xdebug\n\n      - name: Install dependencies\n        uses: ramsey/composer-install@v3\n        with:\n          dependency-versions: ${{ matrix.deps }}\n\n      - name: Setup logs directory\n        run: mkdir -p build/logs\n\n      - name: Execute tests\n        run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky\n\n      - name: Store artifacts\n        if: ${{ matrix.php == '8.1' && matrix.deps == 'lowest' }}\n        uses: actions/upload-artifact@v4\n        with:\n          name: clover.xml\n          path: build/logs\n"
  },
  {
    "path": ".github/workflows/upload-to-codacy.yml",
    "content": "name: upload-coverage-to-codacy\non:\n  workflow_run:\n    workflows: [\"unit-tests\"]\n    types:\n      - completed\n\njobs:\n  upload:\n    runs-on: ubuntu-latest\n    if: >\n      github.event.workflow_run.event == 'pull_request' &&\n      github.event.workflow_run.conclusion == 'success'\n    strategy:\n      fail-fast: true\n    name: upload-coverage\n    \n    steps:\n      - name: Setup logs directory\n        run: mkdir -p build/coverage\n      - name: Download clover.xml artifact\n        uses: dawidd6/action-download-artifact@v7\n        with:\n          workflow: tests.yml\n          name: clover.xml\n          path: build/coverage\n\n      - name: Upload Coverage to Codacy\n        shell: bash\n        env:\n          CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}\n\n        run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r build/coverage/clover.xml"
  },
  {
    "path": ".gitignore",
    "content": "build/\nreport/\nvendor/\ncomposer.lock\nphpunit.result.cache\n.phpunit*\n.idea\n.vscode\n.php-version\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\nWhen contributing to this repository make sure to follow the Pull request process below.\nReduce to the minimum 3rd party dependencies.\n\nPlease note we have a [code of conduct](#Code of Conduct), please follow it in all your interactions with the project.\n\n## Pull Request Process\n\nWhen doing a PR to v2 remember that you also have to do the PR port to v3, or tests confirming the bug is not reproducible.\n\n1. Supported version is v3. If you are fixing a bug in v2, please port to v3\n2. Use the title as a brief description of the changes\n3. Describe the changes you are proposing\n    1. If adding an extra validation state the benefits of adding it and the problem is solving\n    2. Document in the readme, by adding it to the list\n4. Provide appropriate tests for the code you are submitting: aim to keep the existing coverage percentage.\n5. Add your Twitter handle (if you have) so we can thank you there.\n\n## License\nBy contributing, you agree that your contributions will be licensed under its MIT License.\n\n## Code of Conduct\n\n### Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, religion, or sexual identity\nand orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n### Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n* Demonstrating empathy and kindness toward other people\n* Being respectful of differing opinions, viewpoints, and experiences\n* Giving and gracefully accepting constructive feedback\n* Accepting responsibility and apologizing to those affected by our mistakes,\n  and learning from the experience\n* Focusing on what is best not just for us as individuals, but for the\n  overall community\n\nExamples of unacceptable behavior include:\n\n* The use of sexualized language or imagery, and sexual attention or\n  advances of any kind\n* Trolling, insulting or derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or email\n  address, without their explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n### Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n### Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official e-mail address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n### Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at <emailvalidatorrfc.ccreport@gmail.com>.\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n#### Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n#### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n#### 2. Warning\n\n**Community Impact**: A violation through a single incident or series\nof actions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or\npermanent ban.\n\n#### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n#### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior,  harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within\nthe community.\n\n### Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.0, available at\n[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].\n\nCommunity Impact Guidelines were inspired by\n[Mozilla's code of conduct enforcement ladder][Mozilla CoC].\n\nFor answers to common questions about this code of conduct, see the FAQ at\n[https://www.contributor-covenant.org/faq][FAQ]. Translations are available\nat [https://www.contributor-covenant.org/translations][translations].\n\n[homepage]: https://www.contributor-covenant.org\n[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html\n[Mozilla CoC]: https://github.com/mozilla/diversity\n[FAQ]: https://www.contributor-covenant.org/faq\n[translations]: https://www.contributor-covenant.org/translations\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2013-2023 Eduardo Gulias Davis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is furnished\nto do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# EmailValidator\n\n[![Build Status](https://github.com/egulias/EmailValidator/actions/workflows/tests.yml/badge.svg)](https://github.com/egulias/EmailValidator/actions/workflows/tests.yml)\n[![Quality Badge](https://app.codacy.com/project/badge/Grade/55d44898c7e44ebdb4e457523563ad63)](https://app.codacy.com/gh/egulias/EmailValidator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)\n[![Test Coverage](https://app.codacy.com/project/badge/Coverage/55d44898c7e44ebdb4e457523563ad63)](https://app.codacy.com/gh/egulias/EmailValidator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)\n![Latest Release](https://img.shields.io/github/v/release/egulias/EmailValidator)\n\nA library for validating emails against several RFC.\n\n## Supported RFCs\n\nThis library aims to support RFCs:\n\n* [5321](https://tools.ietf.org/html/rfc5321),\n* [5322](https://tools.ietf.org/html/rfc5322),\n* [6530](https://tools.ietf.org/html/rfc6530),\n* [6531](https://tools.ietf.org/html/rfc6531),\n* [6532](https://tools.ietf.org/html/rfc6532),\n* [1035](https://tools.ietf.org/html/rfc1035) \n\n## Supported versions\n\n| Version |  Released  | EOL | Only critical bug fixes | Full |\n|:-------:|:----------:|:---:|:-----------------------:|:----:|\n|**v4.x** |**2023/01/07** |  -  |            **X**        |**X** |\n|  v3.x   | 2020/12/29 | YES |                         |      |\n| v2.1.x  | 2016/05/16 | YES |                         |      |\n|  v1.2   | 2013/19/05 | YES |                         |      |\n\n## Requirements\n\n* PHP 8.1\n* [Composer](https://getcomposer.org) is required for installation\n* [Spoofchecking](/src/Validation/Extra/SpoofCheckValidation.php) and\n[DNSCheckValidation](/src/Validation/DNSCheckValidation.php) validation\nrequires that your PHP system has the\n[PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php)\n(also known as PHP Intl)\n\n**Note**: `PHP version upgrades will happen to accomodate to the pace of major\nframeworks. Minor versions bumps will go via minor versions of this library\n(i.e: PHP7.3 -> v3.x+1). Major versions will go with major versions\nof the library`\n\n## Installation\n\nRun the command below to install via Composer\n\n```shell\ncomposer require egulias/email-validator\n```\n\n## Getting Started\n\n`EmailValidator` requires you to decide which (or combination of them)\nvalidation/s strategy/ies you'd like to follow for each\n[validation](#available-validations).\n\nA basic example with the RFC validation\n\n```php\n<?php\n\nuse Egulias\\EmailValidator\\EmailValidator;\nuse Egulias\\EmailValidator\\Validation\\RFCValidation;\n\n$validator = new EmailValidator();\n$validator->isValid(\"example@example.com\", new RFCValidation()); //true\n```\n\n### Available validations\n\n1. [RFCValidation](/src/Validation/RFCValidation.php): Standard RFC-like email validation.\n2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php):\nRFC-like validation that will fail when warnings* are found.\n3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php):\nWill check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists.\n4. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php):\nIt is a validation that operates over other validations performing a logical and (&&) over the result of each validation.\n5. [MessageIDValidation](/src/Validation/MessageIDValidation.php):\nFollows [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.\n6. [Your own validation](#how-to-extend): You can extend the library behaviour\nby implementing your own validations.\n\n*warnings: Warnings are deviations from the RFC that in a broader interpretation\nare accepted.\n\n```php\n<?php\n\nuse Egulias\\EmailValidator\\EmailValidator;\nuse Egulias\\EmailValidator\\Validation\\DNSCheckValidation;\nuse Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd;\nuse Egulias\\EmailValidator\\Validation\\RFCValidation;\n\n$validator = new EmailValidator();\n$multipleValidations = new MultipleValidationWithAnd([\n    new RFCValidation(),\n    new DNSCheckValidation()\n]);\n//ietf.org has MX records signaling a server with email capabilities\n$validator->isValid(\"example@ietf.org\", $multipleValidations); //true\n```\n\n#### Additional validations\n\nValidations not present in the RFCs\n\n1. [SpoofCheckValidation](/src/Validation/Extra/SpoofCheckValidation.php): \nWill check for multi-utf-8 chars that can signal an erroneous email name.\n\n### How to extend\n\nIt's easy! You just need to implement\n[EmailValidation](/src/Validation/EmailValidation.php) and you can use your own\nvalidation.\n\n## Contributing\n\nPlease follow the [Contribution guide](CONTRIBUTING.md).\nIs short and simple and will help a lot.\n\n## Other Contributors\n\n(You can find current contributors\n[here](https://github.com/egulias/EmailValidator/graphs/contributors))\n\nAs this is a port from another library and work, here are other people related\nto the previous one:\n\n* Ricard Clau [@ricardclau](https://github.com/ricardclau):\nPerformance against PHP built-in filter_var (v2 and earlier)\n* Josepf Bielawski [@stloyd](https://github.com/stloyd):\nFor its first re-work of Dominic's lib\n* Dominic Sayers [@dominicsayers](https://github.com/dominicsayers):\nThe original `isemail` function\n\n## License\n\nReleased under the MIT License attached with this code."
  },
  {
    "path": "composer.json",
    "content": "{\n  \"name\":        \"egulias/email-validator\",\n  \"description\": \"A library for validating emails against several RFCs\",\n  \"homepage\":    \"https://github.com/egulias/EmailValidator\",\n  \"keywords\":    [\"email\", \"validation\", \"validator\", \"emailvalidation\", \"emailvalidator\"],\n  \"license\":     \"MIT\",\n  \"authors\": [\n    {\"name\": \"Eduardo Gulias Davis\"}\n  ],\n  \"extra\": {\n    \"branch-alias\": {\n      \"dev-master\": \"4.0.x-dev\"\n    }\n  },\n  \"require\": {\n    \"php\": \">=8.1\",\n    \"doctrine/lexer\": \"^2.0 || ^3.0\",\n    \"symfony/polyfill-intl-idn\": \"^1.26\"\n  },\n  \"require-dev\": {\n    \"phpunit/phpunit\": \"^10.2\",\n    \"vimeo/psalm\": \"^5.12\"\n  },\n  \"suggest\": {\n    \"ext-intl\": \"PHP Internationalization Libraries are required to use the SpoofChecking validation\"\n  },\n  \"autoload\": {\n    \"psr-4\": {\n      \"Egulias\\\\EmailValidator\\\\\": \"src\"\n    }\n  },\n  \"autoload-dev\": {\n    \"psr-4\": {\n      \"Egulias\\\\EmailValidator\\\\Tests\\\\\": \"tests\"\n    }\n  }\n}\n"
  },
  {
    "path": "documentation/Other.md",
    "content": "Email length\n------------\nhttps://tools.ietf.org/html/rfc5321#section-4.1.2\n  Forward-path   = Path\n\n  Path           = \"<\" [ A-d-l \":\" ] Mailbox \">\"\n\nhttps://tools.ietf.org/html/rfc5321#section-4.5.3.1.3\nhttps://tools.ietf.org/html/rfc1035#section-2.3.4\n\nDNS\n---\n\nhttps://tools.ietf.org/html/rfc5321#section-2.3.5\n  Names that can\n  be resolved to MX RRs or address (i.e., A or AAAA) RRs (as discussed\n  in Section 5) are permitted, as are CNAME RRs whose targets can be\n  resolved, in turn, to MX or address RRs.\n\nhttps://tools.ietf.org/html/rfc5321#section-5.1\n  The lookup first attempts to locate an MX record associated with the\n  name.  If a CNAME record is found, the resulting name is processed as\n  if it were the initial name. ... If an empty list of MXs is returned,\n  the address is treated as if it was associated with an implicit MX\n  RR, with a preference of 0, pointing to that host.\n\nis_email() author's note: We will regard the existence of a CNAME to be\nsufficient evidence of the domain's existence. For performance reasons\nwe will not repeat the DNS lookup for the CNAME's target, but we will\nraise a warning because we didn't immediately find an MX record.\n\nCheck for TLD addresses\n-----------------------\nTLD addresses are specifically allowed in RFC 5321 but they are\nunusual to say the least. We will allocate a separate\nstatus to these addresses on the basis that they are more likely\nto be typos than genuine addresses (unless we've already\nestablished that the domain does have an MX record)\n\nhttps://tools.ietf.org/html/rfc5321#section-2.3.5\n  In the case\n  of a top-level domain used by itself in an email address, a single\n  string is used without any dots.  This makes the requirement,\n  described in more detail below, that only fully-qualified domain\n  names appear in SMTP transactions on the public Internet,\n  particularly important where top-level domains are involved.\n\nTLD format\n----------\nThe format of TLDs has changed a number of times. The standards\nused by IANA have been largely ignored by ICANN, leading to\nconfusion over the standards being followed. These are not defined\nanywhere, except as a general component of a DNS host name (a label).\nHowever, this could potentially lead to 123.123.123.123 being a\nvalid DNS name (rather than an IP address) and thereby creating\nan ambiguity. The most authoritative statement on TLD formats that\nthe author can find is in a (rejected!) erratum to RFC 1123\nsubmitted by John Klensin, the author of RFC 5321:\n\nhttps://www.rfc-editor.org/errata_search.php?rfc=1123&eid=1353\n  However, a valid host name can never have the dotted-decimal\n  form #.#.#.#, since this change does not permit the highest-level\n  component label to start with a digit even if it is not all-numeric.\n\nComments\n--------\nComments at the start of the domain are deprecated in the text\nComments at the start of a subdomain are obs-domain\n(https://tools.ietf.org/html/rfc5322#section-3.4.1)\n"
  },
  {
    "path": "documentation/RFC5321BNF.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\n<title>The BNF from RFC 5321 defining parts of a valid SMTP address</title>\n</head>\n\n<body>\n<pre style=\"font-size:11px;\">\n   Mailbox        = Local-part \"@\" ( Domain / address-literal )\n\n   Local-part     = Dot-string / Quoted-string\n                  ; MAY be case-sensitive\n\n\n   Dot-string     = Atom *(\".\"  Atom)\n\n   Atom           = 1*atext\n\n   Quoted-string  = DQUOTE *QcontentSMTP DQUOTE\n\n   QcontentSMTP   = qtextSMTP / quoted-pairSMTP\n\n   quoted-pairSMTP  = %d92 %d32-126\n                    ; i.e., backslash followed by any ASCII\n                    ; graphic (including itself) or SPace\n\n   qtextSMTP      = %d32-33 / %d35-91 / %d93-126\n                  ; i.e., within a quoted string, any\n                  ; ASCII graphic or space is permitted\n                  ; without blackslash-quoting except\n                  ; double-quote and the backslash itself.\n\n   Domain         = sub-domain *(\".\" sub-domain)\n\n   sub-domain     = Let-dig [Ldh-str]\n\n   Let-dig        = ALPHA / DIGIT\n\n   Ldh-str        = *( ALPHA / DIGIT / \"-\" ) Let-dig\n\n   address-literal  = \"[\" ( IPv4-address-literal /\n                    IPv6-address-literal /\n                    General-address-literal ) \"]\"\n                    ; See Section 4.1.3\n\n   IPv4-address-literal  = Snum 3(\".\"  Snum)\n\n   IPv6-address-literal  = \"IPv6:\" IPv6-addr\n\n   General-address-literal  = Standardized-tag \":\" 1*dcontent\n\n   Standardized-tag  = Ldh-str\n                     ; Standardized-tag MUST be specified in a\n                     ; Standards-Track RFC and registered with IANA\n\n   dcontent       = %d33-90 / ; Printable US-ASCII\n                  %d94-126 ; excl. \"[\", \"\\\", \"]\"\n\n   Snum           = 1*3DIGIT\n                  ; representing a decimal integer\n                  ; value in the range 0 through 255\n\n   IPv6-addr      = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp\n\n   IPv6-hex       = 1*4HEXDIG\n\n   IPv6-full      = IPv6-hex 7(\":\" IPv6-hex)\n\n   IPv6-comp      = [IPv6-hex *5(\":\" IPv6-hex)] \"::\"\n                  [IPv6-hex *5(\":\" IPv6-hex)]\n                  ; The \"::\" represents at least 2 16-bit groups of\n                  ; zeros.  No more than 6 groups in addition to the\n                  ; \"::\" may be present.\n\n   IPv6v4-full    = IPv6-hex 5(\":\" IPv6-hex) \":\" IPv4-address-literal\n\n   IPv6v4-comp    = [IPv6-hex *3(\":\" IPv6-hex)] \"::\"\n                  [IPv6-hex *3(\":\" IPv6-hex) \":\"]\n                  IPv4-address-literal\n                  ; The \"::\" represents at least 2 16-bit groups of\n                  ; zeros.  No more than 4 groups in addition to the\n                  ; \"::\" and IPv4-address-literal may be present.\n\n</pre>\n</body>\n\n</html>\n"
  },
  {
    "path": "documentation/RFC5322BNF.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\n<title>The BNF from RFC 5322 defining parts of a valid internet message address</title>\n</head>\n\n<body>\n<pre style=\"font-size:11px;\">\n   addr-spec       =   local-part \"@\" domain\n\n   local-part      =   dot-atom / quoted-string / obs-local-part\n\n   dot-atom        =   [CFWS] dot-atom-text [CFWS]\n\n   CFWS            =   (1*([FWS] comment) [FWS]) / FWS\n\n   FWS             =   ([*WSP CRLF] 1*WSP) /  obs-FWS\n                                          ; Folding white space\n\n   WSP             =   SP / HTAB          ; white space\n\n   obs-FWS         =   1*([CRLF] WSP)     ; As amended in erratum #1908\n\n   ctext           =   %d33-39 /          ; Printable US-ASCII\n                       %d42-91 /          ;  characters not including\n                       %d93-126 /         ;  \"(\", \")\", or \"\\\"\n                       obs-ctext\n\n   obs-ctext       =   obs-NO-WS-CTL\n   ccontent        =   ctext / quoted-pair / comment\n\n   comment         =   \"(\" *([FWS] ccontent) [FWS] \")\"\n\n   dot-atom-text   =   1*atext *(\".\" 1*atext)\n\n   atext           =   ALPHA / DIGIT /    ; Printable US-ASCII\n                       \"!\" / \"#\" /        ;  characters not including\n                       \"$\" / \"%\" /        ;  specials.  Used for atoms.\n                       \"&amp;\" / \"'\" /\n                       \"*\" / \"+\" /\n                       \"-\" / \"/\" /\n                       \"=\" / \"?\" /\n                       \"^\" / \"_\" /\n                       \"`\" / \"{\" /\n                       \"|\" / \"}\" /\n                       \"~\"\n\n   specials        =   \"(\" / \")\" /        ; Special characters that do\n                       \"&lt;\" / \"&gt;\" /        ;  not appear in atext\n                       \"[\" / \"]\" /\n                       \":\" / \";\" /\n                       \"@\" / \"\\\" /\n                       \",\" / \".\" /\n                       DQUOTE\n\n   quoted-string   =   [CFWS]\n                       DQUOTE *([FWS] qcontent) [FWS] DQUOTE\n                       [CFWS]\n\n   qcontent        =   qtext / quoted-pair\n\n   qtext           =   %d33 /             ; Printable US-ASCII\n                       %d35-91 /          ;  characters not including\n                       %d93-126 /         ;  \"\\\" or the quote character\n                       obs-qtext\n\n   obs-qtext       =   obs-NO-WS-CTL\n\n   obs-NO-WS-CTL   =   %d1-8 /            ; US-ASCII control\n                       %d11 /             ;  characters that do not\n                       %d12 /             ;  include the carriage\n                       %d14-31 /          ;  return, line feed, and\n                       %d127              ;  white space characters\n\n   quoted-pair     =   (\"\\\" (VCHAR / WSP)) / obs-qp\n\n   VCHAR           =   %x21-7E            ; visible (printing) characters\n\n   obs-qp          =   \"\\\" (%d0 / obs-NO-WS-CTL / LF / CR)\n\n   obs-local-part  =   word *(\".\" word)\n\n   word            =   atom / quoted-string\n\n   atom            =   [CFWS] 1*atext [CFWS]\n\n   domain          =   dot-atom / domain-literal / obs-domain\n\n   domain-literal  =   [CFWS] \"[\" *([FWS] dtext) [FWS] \"]\" [CFWS]\n\n   dtext           =   %d33-90 /          ; Printable US-ASCII\n                       %d94-126 /         ;  characters not including\n                       obs-dtext          ;  \"[\", \"]\", or \"\\\"\n\n   obs-dtext       =   obs-NO-WS-CTL / quoted-pair\n\n   obs-domain      =   atom *(\".\" atom)\n\nNB For SMTP mail, the domain-literal is restricted by RFC5321 as follows:\n\n   Mailbox        = Local-part \"@\" ( Domain / address-literal )\n\n   address-literal  = \"[\" ( IPv4-address-literal /\n                    IPv6-address-literal /\n                    General-address-literal ) \"]\"\n\n   IPv4-address-literal  = Snum 3(\".\"  Snum)\n\n   IPv6-address-literal  = \"IPv6:\" IPv6-addr\n\n   Snum           = 1*3DIGIT\n                  ; representing a decimal integer\n                  ; value in the range 0 through 255\n\n   IPv6-addr      = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp\n\n   IPv6-hex       = 1*4HEXDIG\n\n   IPv6-full      = IPv6-hex 7(\":\" IPv6-hex)\n\n   IPv6-comp      = [IPv6-hex *5(\":\" IPv6-hex)] \"::\"\n                  [IPv6-hex *5(\":\" IPv6-hex)]\n                  ; The \"::\" represents at least 2 16-bit groups of\n                  ; zeros.  No more than 6 groups in addition to the\n                  ; \"::\" may be present.\n\n   IPv6v4-full    = IPv6-hex 5(\":\" IPv6-hex) \":\" IPv4-address-literal\n\n   IPv6v4-comp    = [IPv6-hex *3(\":\" IPv6-hex)] \"::\"\n                  [IPv6-hex *3(\":\" IPv6-hex) \":\"]\n                  IPv4-address-literal\n                  ; The \"::\" represents at least 2 16-bit groups of\n                  ; zeros.  No more than 4 groups in addition to the\n                  ; \"::\" and IPv4-address-literal may be present.\n\n</pre>\n</body>\n\n</html>\n"
  },
  {
    "path": "phpunit.xml.dist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"vendor/phpunit/phpunit/phpunit.xsd\"\n         bootstrap=\"vendor/autoload.php\"\n         colors=\"true\"\n         executionOrder=\"defects\"\n         cacheDirectory=\".phpunit.cache\"\n>\n  <coverage/>\n\n  <testsuites>\n    <testsuite name=\"EmailValidator Test Suite\">\n      <directory>./tests/EmailValidator</directory>\n      <exclude>./vendor/</exclude>\n    </testsuite>\n  </testsuites>\n\n  <source>\n    <include>\n      <directory>./src/</directory>\n    </include>\n    <exclude>\n      <directory suffix=\".php\">./src/Result/Reason</directory>\n    </exclude>\n  </source>\n\n</phpunit>\n"
  },
  {
    "path": "psalm.xml",
    "content": "<?xml version=\"1.0\"?>\n<psalm\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xmlns=\"https://getpsalm.org/schema/config\"\n    xsi:schemaLocation=\"https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd\"\n    errorLevel=\"1\"\n    findUnusedCode=\"false\"\n    findUnusedPsalmSuppress=\"true\"\n    disableSuppressAll=\"true\"\n    findUnusedVariablesAndParams=\"true\"\n>\n    <projectFiles>\n        <directory name=\"src\" />\n        <ignoreFiles>\n            <directory name=\"vendor\" />\n        </ignoreFiles>\n    </projectFiles>\n</psalm>\n"
  },
  {
    "path": "src/EmailLexer.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator;\n\nuse Doctrine\\Common\\Lexer\\AbstractLexer;\nuse Doctrine\\Common\\Lexer\\Token;\n\n/** @extends AbstractLexer<int, string> */\nclass EmailLexer extends AbstractLexer\n{\n    //ASCII values\n    public const S_EMPTY            = -1;\n    public const C_NUL              = 0;\n    public const S_HTAB             = 9;\n    public const S_LF               = 10;\n    public const S_CR               = 13;\n    public const S_SP               = 32;\n    public const EXCLAMATION        = 33;\n    public const S_DQUOTE           = 34;\n    public const NUMBER_SIGN        = 35;\n    public const DOLLAR             = 36;\n    public const PERCENTAGE         = 37;\n    public const AMPERSAND          = 38;\n    public const S_SQUOTE           = 39;\n    public const S_OPENPARENTHESIS  = 40;\n    public const S_CLOSEPARENTHESIS = 41;\n    public const ASTERISK           = 42;\n    public const S_PLUS             = 43;\n    public const S_COMMA            = 44;\n    public const S_HYPHEN           = 45;\n    public const S_DOT              = 46;\n    public const S_SLASH            = 47;\n    public const S_COLON            = 58;\n    public const S_SEMICOLON        = 59;\n    public const S_LOWERTHAN        = 60;\n    public const S_EQUAL            = 61;\n    public const S_GREATERTHAN      = 62;\n    public const QUESTIONMARK       = 63;\n    public const S_AT               = 64;\n    public const S_OPENBRACKET      = 91;\n    public const S_BACKSLASH        = 92;\n    public const S_CLOSEBRACKET     = 93;\n    public const CARET              = 94;\n    public const S_UNDERSCORE       = 95;\n    public const S_BACKTICK         = 96;\n    public const S_OPENCURLYBRACES  = 123;\n    public const S_PIPE             = 124;\n    public const S_CLOSECURLYBRACES = 125;\n    public const S_TILDE            = 126;\n    public const C_DEL              = 127;\n    public const INVERT_QUESTIONMARK = 168;\n    public const INVERT_EXCLAMATION = 173;\n    public const GENERIC            = 300;\n    public const S_IPV6TAG          = 301;\n    public const INVALID            = 302;\n    public const CRLF               = 1310;\n    public const S_DOUBLECOLON      = 5858;\n    public const ASCII_INVALID_FROM = 127;\n    public const ASCII_INVALID_TO   = 199;\n\n    /**\n     * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)\n     *\n     * @var array<string, int>\n     */\n    protected $charValue = [\n        '{'    => self::S_OPENCURLYBRACES,\n        '}'    => self::S_CLOSECURLYBRACES,\n        '('    => self::S_OPENPARENTHESIS,\n        ')'    => self::S_CLOSEPARENTHESIS,\n        '<'    => self::S_LOWERTHAN,\n        '>'    => self::S_GREATERTHAN,\n        '['    => self::S_OPENBRACKET,\n        ']'    => self::S_CLOSEBRACKET,\n        ':'    => self::S_COLON,\n        ';'    => self::S_SEMICOLON,\n        '@'    => self::S_AT,\n        '\\\\'   => self::S_BACKSLASH,\n        '/'    => self::S_SLASH,\n        ','    => self::S_COMMA,\n        '.'    => self::S_DOT,\n        \"'\"    => self::S_SQUOTE,\n        \"`\"    => self::S_BACKTICK,\n        '\"'    => self::S_DQUOTE,\n        '-'    => self::S_HYPHEN,\n        '::'   => self::S_DOUBLECOLON,\n        ' '    => self::S_SP,\n        \"\\t\"   => self::S_HTAB,\n        \"\\r\"   => self::S_CR,\n        \"\\n\"   => self::S_LF,\n        \"\\r\\n\" => self::CRLF,\n        'IPv6' => self::S_IPV6TAG,\n        ''     => self::S_EMPTY,\n        '\\0'   => self::C_NUL,\n        '*'    => self::ASTERISK,\n        '!'    => self::EXCLAMATION,\n        '&'    => self::AMPERSAND,\n        '^'    => self::CARET,\n        '$'    => self::DOLLAR,\n        '%'    => self::PERCENTAGE,\n        '~'    => self::S_TILDE,\n        '|'    => self::S_PIPE,\n        '_'    => self::S_UNDERSCORE,\n        '='    => self::S_EQUAL,\n        '+'    => self::S_PLUS,\n        '¿'    => self::INVERT_QUESTIONMARK,\n        '?'    => self::QUESTIONMARK,\n        '#'    => self::NUMBER_SIGN,\n        '¡'    => self::INVERT_EXCLAMATION,\n    ];\n\n    public const INVALID_CHARS_REGEX = \"/[^\\p{S}\\p{C}\\p{Cc}]+/iu\";\n\n    public const VALID_UTF8_REGEX = '/\\p{Cc}+/u';\n\n    public const CATCHABLE_PATTERNS = [\n        '[a-zA-Z]+[46]?', //ASCII and domain literal\n        '[^\\x00-\\x7F]',  //UTF-8\n        '[0-9]+',\n        '\\r\\n',\n        '::',\n        '\\s+?',\n        '.',\n    ];\n\n    public const NON_CATCHABLE_PATTERNS = [\n        '[\\xA0-\\xff]+',\n    ];\n\n    public const MODIFIERS = 'iu';\n\n    /** @var bool */\n    protected $hasInvalidTokens = false;\n\n    /**\n     * @var Token<int, string>\n     */\n    protected Token $previous;\n\n    /**\n     * The last matched/seen token.\n     *\n     * @var Token<int, string>\n     */\n    public Token $current;\n\n    /**\n     * @var Token<int, string>\n     */\n    private Token $nullToken;\n\n    /** @var string */\n    private $accumulator = '';\n\n    /** @var bool */\n    private $hasToRecord = false;\n\n    public function __construct()\n    {\n        /** @var Token<int, string> $nullToken */\n        $nullToken = new Token('', self::S_EMPTY, 0);\n        $this->nullToken = $nullToken;\n\n        $this->current = $this->previous = $this->nullToken;\n        $this->lookahead = null;\n    }\n\n    public function reset(): void\n    {\n        $this->hasInvalidTokens = false;\n        parent::reset();\n        $this->current = $this->previous = $this->nullToken;\n    }\n\n    /**\n     * @param int $type\n     * @throws \\UnexpectedValueException\n     * @return boolean\n     *\n     */\n    public function find($type): bool\n    {\n        $search = clone $this;\n        $search->skipUntil($type);\n\n        if (!$search->lookahead) {\n            throw new \\UnexpectedValueException($type . ' not found');\n        }\n        return true;\n    }\n\n    /**\n     * moveNext\n     *\n     * @return boolean\n     */\n    public function moveNext(): bool\n    {\n        if ($this->hasToRecord && $this->previous === $this->nullToken) {\n            $this->accumulator .= $this->current->value;\n        }\n\n        $this->previous = $this->current;\n\n        if ($this->lookahead === null) {\n            $this->lookahead = $this->nullToken;\n        }\n\n        $hasNext = parent::moveNext();\n        $this->current = $this->token ?? $this->nullToken;\n\n        if ($this->hasToRecord) {\n            $this->accumulator .= $this->current->value;\n        }\n\n        return $hasNext;\n    }\n\n    /**\n     * Retrieve token type. Also processes the token value if necessary.\n     *\n     * @param string $value\n     * @throws \\InvalidArgumentException\n     * @return integer\n     */\n    protected function getType(&$value): int\n    {\n        $encoded = $value;\n\n        if (mb_detect_encoding($value, 'auto', true) !== 'UTF-8') {\n            $encoded = mb_convert_encoding($value, 'UTF-8', 'Windows-1252');\n        }\n\n        if ($this->isValid($encoded)) {\n            return $this->charValue[$encoded];\n        }\n\n        if ($this->isNullType($encoded)) {\n            return self::C_NUL;\n        }\n\n        if ($this->isInvalidChar($encoded)) {\n            $this->hasInvalidTokens = true;\n            return self::INVALID;\n        }\n\n        return self::GENERIC;\n    }\n\n    protected function isValid(string $value): bool\n    {\n        return isset($this->charValue[$value]);\n    }\n\n    protected function isNullType(string $value): bool\n    {\n        return $value === \"\\0\";\n    }\n\n    protected function isInvalidChar(string $value): bool\n    {\n        return !preg_match(self::INVALID_CHARS_REGEX, $value);\n    }\n\n    protected function isUTF8Invalid(string $value): bool\n    {\n        return preg_match(self::VALID_UTF8_REGEX, $value) !== false;\n    }\n\n    public function hasInvalidTokens(): bool\n    {\n        return $this->hasInvalidTokens;\n    }\n\n    /**\n     * getPrevious\n     *\n     * @return Token<int, string>\n     */\n    public function getPrevious(): Token\n    {\n        return $this->previous;\n    }\n\n    /**\n     * Lexical catchable patterns.\n     *\n     * @return string[]\n     */\n    protected function getCatchablePatterns(): array\n    {\n        return self::CATCHABLE_PATTERNS;\n    }\n\n    /**\n     * Lexical non-catchable patterns.\n     *\n     * @return string[]\n     */\n    protected function getNonCatchablePatterns(): array\n    {\n        return self::NON_CATCHABLE_PATTERNS;\n    }\n\n    protected function getModifiers(): string\n    {\n        return self::MODIFIERS;\n    }\n\n    public function getAccumulatedValues(): string\n    {\n        return $this->accumulator;\n    }\n\n    public function startRecording(): void\n    {\n        $this->hasToRecord = true;\n    }\n\n    public function stopRecording(): void\n    {\n        $this->hasToRecord = false;\n    }\n\n    public function clearRecorded(): void\n    {\n        $this->accumulator = '';\n    }\n}\n"
  },
  {
    "path": "src/EmailParser.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator;\n\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Parser\\LocalPart;\nuse Egulias\\EmailValidator\\Parser\\DomainPart;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\EmailTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoLocalPart;\n\nclass EmailParser extends Parser\n{\n    public const EMAIL_MAX_LENGTH = 254;\n\n    /**\n     * @var string\n     */\n    protected $domainPart = '';\n\n    /**\n     * @var string\n     */\n    protected $localPart = '';\n\n    public function parse(string $str): Result\n    {\n        $result = parent::parse($str);\n\n        $this->addLongEmailWarning($this->localPart, $this->domainPart);\n\n        return $result;\n    }\n\n    protected function preLeftParsing(): Result\n    {\n        if (!$this->hasAtToken()) {\n            return new InvalidEmail(new NoLocalPart(), $this->lexer->current->value);\n        }\n        return new ValidEmail();\n    }\n\n    protected function parseLeftFromAt(): Result\n    {\n        return $this->processLocalPart();\n    }\n\n    protected function parseRightFromAt(): Result\n    {\n        return $this->processDomainPart();\n    }\n\n    private function processLocalPart(): Result\n    {\n        $localPartParser = new LocalPart($this->lexer);\n        $localPartResult = $localPartParser->parse();\n        $this->localPart = $localPartParser->localPart();\n        $this->warnings = [...$localPartParser->getWarnings(), ...$this->warnings];\n\n        return $localPartResult;\n    }\n\n    private function processDomainPart(): Result\n    {\n        $domainPartParser = new DomainPart($this->lexer);\n        $domainPartResult = $domainPartParser->parse();\n        $this->domainPart = $domainPartParser->domainPart();\n        $this->warnings = [...$domainPartParser->getWarnings(), ...$this->warnings];\n\n        return $domainPartResult;\n    }\n\n    public function getDomainPart(): string\n    {\n        return $this->domainPart;\n    }\n\n    public function getLocalPart(): string\n    {\n        return $this->localPart;\n    }\n\n    private function addLongEmailWarning(string $localPart, string $parsedDomainPart): void\n    {\n        if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) {\n            $this->warnings[EmailTooLong::CODE] = new EmailTooLong();\n        }\n    }\n}\n"
  },
  {
    "path": "src/EmailValidator.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator;\n\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Validation\\EmailValidation;\n\nclass EmailValidator\n{\n    /**\n     * @var EmailLexer\n     */\n    private $lexer;\n\n    /**\n     * @var Warning\\Warning[]\n     */\n    private $warnings = [];\n\n    /**\n     * @var ?InvalidEmail\n     */\n    private $error;\n\n    public function __construct()\n    {\n        $this->lexer = new EmailLexer();\n    }\n\n    /**\n     * @param string          $email\n     * @param EmailValidation $emailValidation\n     * @return bool\n     */\n    public function isValid(string $email, EmailValidation $emailValidation)\n    {\n        $isValid = $emailValidation->isValid($email, $this->lexer);\n        $this->warnings = $emailValidation->getWarnings();\n        $this->error = $emailValidation->getError();\n\n        return $isValid;\n    }\n\n    /**\n     * @return boolean\n     */\n    public function hasWarnings()\n    {\n        return !empty($this->warnings);\n    }\n\n    /**\n     * @return array\n     */\n    public function getWarnings()\n    {\n        return $this->warnings;\n    }\n\n    /**\n     * @return InvalidEmail|null\n     */\n    public function getError()\n    {\n        return $this->error;\n    }\n}\n"
  },
  {
    "path": "src/MessageIDParser.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator;\n\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Parser\\IDLeftPart;\nuse Egulias\\EmailValidator\\Parser\\IDRightPart;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\EmailTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoLocalPart;\n\nclass MessageIDParser extends Parser\n{\n\n    public const EMAILID_MAX_LENGTH = 254;\n\n    /**\n     * @var string\n     */\n    protected $idLeft = '';\n\n    /**\n     * @var string\n     */\n    protected $idRight = '';\n\n    public function parse(string $str): Result\n    {\n        $result = parent::parse($str);\n\n        $this->addLongEmailWarning($this->idLeft, $this->idRight);\n\n        return $result;\n    }\n\n    protected function preLeftParsing(): Result\n    {\n        if (!$this->hasAtToken()) {\n            return new InvalidEmail(new NoLocalPart(), $this->lexer->current->value);\n        }\n        return new ValidEmail();\n    }\n\n    protected function parseLeftFromAt(): Result\n    {\n        return $this->processIDLeft();\n    }\n\n    protected function parseRightFromAt(): Result\n    {\n        return $this->processIDRight();\n    }\n\n    private function processIDLeft(): Result\n    {\n        $localPartParser = new IDLeftPart($this->lexer);\n        $localPartResult = $localPartParser->parse();\n        $this->idLeft = $localPartParser->localPart();\n        $this->warnings = [...$localPartParser->getWarnings(), ...$this->warnings];\n\n        return $localPartResult;\n    }\n\n    private function processIDRight(): Result\n    {\n        $domainPartParser = new IDRightPart($this->lexer);\n        $domainPartResult = $domainPartParser->parse();\n        $this->idRight = $domainPartParser->domainPart();\n        $this->warnings = [...$domainPartParser->getWarnings(), ...$this->warnings];\n\n        return $domainPartResult;\n    }\n\n    public function getLeftPart(): string\n    {\n        return $this->idLeft;\n    }\n\n    public function getRightPart(): string\n    {\n        return $this->idRight;\n    }\n\n    private function addLongEmailWarning(string $localPart, string $parsedDomainPart): void\n    {\n        if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAILID_MAX_LENGTH) {\n            $this->warnings[EmailTooLong::CODE] = new EmailTooLong();\n        }\n    }\n}\n"
  },
  {
    "path": "src/Parser/Comment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Warning\\QuotedPart;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Parser\\CommentStrategy\\CommentStrategy;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnclosedComment;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnOpenedComment;\nuse Egulias\\EmailValidator\\Warning\\Comment as WarningComment;\n\nclass Comment extends PartParser\n{\n    /**\n     * @var int\n     */\n    private $openedParenthesis = 0;\n\n    /**\n     * @var CommentStrategy\n     */\n    private $commentStrategy;\n\n    public function __construct(EmailLexer $lexer, CommentStrategy $commentStrategy)\n    {\n        $this->lexer = $lexer;\n        $this->commentStrategy = $commentStrategy;\n    }\n\n    public function parse(): Result\n    {\n        if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) {\n            $this->openedParenthesis++;\n            if ($this->noClosingParenthesis()) {\n                return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);\n            }\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS)) {\n            return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value);\n        }\n\n        $this->warnings[WarningComment::CODE] = new WarningComment();\n\n        $moreTokens = true;\n        while ($this->commentStrategy->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens) {\n\n            if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {\n                $this->openedParenthesis++;\n            }\n            $this->warnEscaping();\n            if ($this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {\n                $this->openedParenthesis--;\n            }\n            $moreTokens = $this->lexer->moveNext();\n        }\n\n        if ($this->openedParenthesis >= 1) {\n            return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);\n        }\n        if ($this->openedParenthesis < 0) {\n            return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value);\n        }\n\n        $finalValidations = $this->commentStrategy->endOfLoopValidations($this->lexer);\n\n        $this->warnings = [...$this->warnings, ...$this->commentStrategy->getWarnings()];\n\n        return $finalValidations;\n    }\n\n\n    /**\n     * @return void\n     */\n    private function warnEscaping(): void\n    {\n        //Backslash found\n        if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {\n            return;\n        }\n\n        if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {\n            return;\n        }\n\n        $this->warnings[QuotedPart::CODE] =\n            new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->current->type);\n    }\n\n    private function noClosingParenthesis(): bool\n    {\n        try {\n            $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);\n            return false;\n        } catch (\\RuntimeException $e) {\n            return true;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Parser/CommentStrategy/CommentStrategy.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser\\CommentStrategy;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\ninterface CommentStrategy\n{\n    /**\n     * Return \"true\" to continue, \"false\" to exit\n     */\n    public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool;\n\n    public function endOfLoopValidations(EmailLexer $lexer): Result;\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings(): array;\n}\n"
  },
  {
    "path": "src/Parser/CommentStrategy/DomainComment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser\\CommentStrategy;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\n\nclass DomainComment implements CommentStrategy\n{\n    public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool\n    {\n        return !($openedParenthesis === 0 && $lexer->isNextToken(EmailLexer::S_DOT));\n    }\n\n    public function endOfLoopValidations(EmailLexer $lexer): Result\n    {\n        //test for end of string\n        if (!$lexer->isNextToken(EmailLexer::S_DOT)) {\n            return new InvalidEmail(new ExpectingATEXT('DOT not found near CLOSEPARENTHESIS'), $lexer->current->value);\n        }\n        //add warning\n        //Address is valid within the message but cannot be used unmodified for the envelope\n        return new ValidEmail();\n    }\n\n    public function getWarnings(): array\n    {\n        return [];\n    }\n}\n"
  },
  {
    "path": "src/Parser/CommentStrategy/LocalComment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser\\CommentStrategy;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Warning\\CFWSNearAt;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nclass LocalComment implements CommentStrategy\n{\n    /**\n     * @var array<int, Warning>\n     */\n    private $warnings = [];\n\n    public function exitCondition(EmailLexer $lexer, int $openedParenthesis): bool\n    {\n        return !$lexer->isNextToken(EmailLexer::S_AT);\n    }\n\n    public function endOfLoopValidations(EmailLexer $lexer): Result\n    {\n        if (!$lexer->isNextToken(EmailLexer::S_AT)) {\n            return new InvalidEmail(new ExpectingATEXT('ATEX is not expected after closing comments'), $lexer->current->value);\n        }\n        $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();\n        return new ValidEmail();\n    }\n\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n}\n"
  },
  {
    "path": "src/Parser/DomainLiteral.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\CFWSWithFWS;\nuse Egulias\\EmailValidator\\Warning\\IPV6BadChar;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRNoLF;\nuse Egulias\\EmailValidator\\Warning\\IPV6ColonEnd;\nuse Egulias\\EmailValidator\\Warning\\IPV6MaxGroups;\nuse Egulias\\EmailValidator\\Warning\\ObsoleteDTEXT;\nuse Egulias\\EmailValidator\\Warning\\AddressLiteral;\nuse Egulias\\EmailValidator\\Warning\\IPV6ColonStart;\nuse Egulias\\EmailValidator\\Warning\\IPV6Deprecated;\nuse Egulias\\EmailValidator\\Warning\\IPV6GroupCount;\nuse Egulias\\EmailValidator\\Warning\\IPV6DoubleColon;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingDTEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnusualElements;\nuse Egulias\\EmailValidator\\Warning\\DomainLiteral as WarningDomainLiteral;\n\nclass DomainLiteral extends PartParser\n{\n    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]?)$/';\n\n    public const OBSOLETE_WARNINGS = [\n        EmailLexer::INVALID,\n        EmailLexer::C_DEL,\n        EmailLexer::S_LF,\n        EmailLexer::S_BACKSLASH\n    ];\n\n    public function parse(): Result\n    {\n        $this->addTagWarnings();\n\n        $IPv6TAG = false;\n        $addressLiteral = '';\n\n        do {\n            if ($this->lexer->current->isA(EmailLexer::C_NUL)) {\n                return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->current->value);\n            }\n\n            $this->addObsoleteWarnings();\n\n            if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENBRACKET, EmailLexer::S_OPENBRACKET))) {\n                return new InvalidEmail(new ExpectingDTEXT(), $this->lexer->current->value);\n            }\n\n            if ($this->lexer->isNextTokenAny(\n                array(EmailLexer::S_HTAB, EmailLexer::S_SP, EmailLexer::CRLF)\n            )) {\n                $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();\n                $this->parseFWS();\n            }\n\n            if ($this->lexer->isNextToken(EmailLexer::S_CR)) {\n                return new InvalidEmail(new CRNoLF(), $this->lexer->current->value);\n            }\n\n            if ($this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {\n                return new InvalidEmail(new UnusualElements($this->lexer->current->value), $this->lexer->current->value);\n            }\n            if ($this->lexer->current->isA(EmailLexer::S_IPV6TAG)) {\n                $IPv6TAG = true;\n            }\n\n            if ($this->lexer->current->isA(EmailLexer::S_CLOSEBRACKET)) {\n                break;\n            }\n\n            $addressLiteral .= $this->lexer->current->value;\n        } while ($this->lexer->moveNext());\n\n\n        //Encapsulate\n        $addressLiteral = str_replace('[', '', $addressLiteral);\n        $isAddressLiteralIPv4 = $this->checkIPV4Tag($addressLiteral);\n\n        if (!$isAddressLiteralIPv4) {\n            return new ValidEmail();\n        }\n\n        $addressLiteral = $this->convertIPv4ToIPv6($addressLiteral);\n\n        if (!$IPv6TAG) {\n            $this->warnings[WarningDomainLiteral::CODE] = new WarningDomainLiteral();\n            return new ValidEmail();\n        }\n\n        $this->warnings[AddressLiteral::CODE] = new AddressLiteral();\n\n        $this->checkIPV6Tag($addressLiteral);\n\n        return new ValidEmail();\n    }\n\n    /**\n     * @param string $addressLiteral\n     * @param int $maxGroups\n     */\n    public function checkIPV6Tag($addressLiteral, $maxGroups = 8): void\n    {\n        $prev = $this->lexer->getPrevious();\n        if ($prev->isA(EmailLexer::S_COLON)) {\n            $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd();\n        }\n\n        $IPv6       = substr($addressLiteral, 5);\n        //Daniel Marschall's new IPv6 testing strategy\n        $matchesIP  = explode(':', $IPv6);\n        $groupCount = count($matchesIP);\n        $colons     = strpos($IPv6, '::');\n\n        if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) {\n            $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar();\n        }\n\n        if ($colons === false) {\n            // We need exactly the right number of groups\n            if ($groupCount !== $maxGroups) {\n                $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount();\n            }\n            return;\n        }\n\n        if ($colons !== strrpos($IPv6, '::')) {\n            $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon();\n            return;\n        }\n\n        if ($colons === 0 || $colons === (strlen($IPv6) - 2)) {\n            // RFC 4291 allows :: at the start or end of an address\n            //with 7 other groups in addition\n            ++$maxGroups;\n        }\n\n        if ($groupCount > $maxGroups) {\n            $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups();\n        } elseif ($groupCount === $maxGroups) {\n            $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();\n        }\n    }\n\n    public function convertIPv4ToIPv6(string $addressLiteralIPv4): string\n    {\n        $matchesIP  = [];\n        $IPv4Match = preg_match(self::IPV4_REGEX, $addressLiteralIPv4, $matchesIP);\n\n        // Extract IPv4 part from the end of the address-literal (if there is one)\n        if ($IPv4Match > 0) {\n            $index = (int) strrpos($addressLiteralIPv4, $matchesIP[0]);\n            //There's a match but it is at the start\n            if ($index > 0) {\n                // Convert IPv4 part to IPv6 format for further testing\n                return substr($addressLiteralIPv4, 0, $index) . '0:0';\n            }\n        }\n\n        return $addressLiteralIPv4;\n    }\n\n    /**\n     * @param string $addressLiteral\n     *\n     * @return bool\n     */\n    protected function checkIPV4Tag($addressLiteral): bool\n    {\n        $matchesIP  = [];\n        $IPv4Match = preg_match(self::IPV4_REGEX, $addressLiteral, $matchesIP);\n\n        // Extract IPv4 part from the end of the address-literal (if there is one)\n\n        if ($IPv4Match > 0) {\n            $index = strrpos($addressLiteral, $matchesIP[0]);\n            //There's a match but it is at the start\n            if ($index === 0) {\n                $this->warnings[AddressLiteral::CODE] = new AddressLiteral();\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    private function addObsoleteWarnings(): void\n    {\n        if (in_array($this->lexer->current->type, self::OBSOLETE_WARNINGS)) {\n            $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();\n        }\n    }\n\n    private function addTagWarnings(): void\n    {\n        if ($this->lexer->isNextToken(EmailLexer::S_COLON)) {\n            $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();\n        }\n        if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) {\n            $lexer = clone $this->lexer;\n            $lexer->moveNext();\n            if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) {\n                $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Parser/DomainPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Doctrine\\Common\\Lexer\\Token;\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Warning\\TLD;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtEnd;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtStart;\nuse Egulias\\EmailValidator\\Warning\\DeprecatedComment;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRLFAtTheEnd;\nuse Egulias\\EmailValidator\\Result\\Reason\\LabelTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoDomainPart;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveAt;\nuse Egulias\\EmailValidator\\Result\\Reason\\DomainTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\CharNotAllowed;\nuse Egulias\\EmailValidator\\Result\\Reason\\DomainHyphened;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Parser\\CommentStrategy\\DomainComment;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingDomainLiteralClose;\nuse Egulias\\EmailValidator\\Parser\\DomainLiteral as DomainLiteralParser;\n\nclass DomainPart extends PartParser\n{\n    public const DOMAIN_MAX_LENGTH = 253;\n    public const LABEL_MAX_LENGTH = 63;\n\n    /**\n     * @var string\n     */\n    protected $domainPart = '';\n\n    /**\n     * @var string\n     */\n    protected $label = '';\n\n    public function parse(): Result\n    {\n        $this->lexer->clearRecorded();\n        $this->lexer->startRecording();\n\n        $this->lexer->moveNext();\n\n        $domainChecks = $this->performDomainStartChecks();\n        if ($domainChecks->isInvalid()) {\n            return $domainChecks;\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_AT)) {\n            return new InvalidEmail(new ConsecutiveAt(), $this->lexer->current->value);\n        }\n\n        $result = $this->doParseDomainPart();\n        if ($result->isInvalid()) {\n            return $result;\n        }\n\n        $end = $this->checkEndOfDomain();\n        if ($end->isInvalid()) {\n            return $end;\n        }\n\n        $this->lexer->stopRecording();\n        $this->domainPart = $this->lexer->getAccumulatedValues();\n\n        $length = strlen($this->domainPart);\n        if ($length > self::DOMAIN_MAX_LENGTH) {\n            return new InvalidEmail(new DomainTooLong(), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    private function checkEndOfDomain(): Result\n    {\n        $prev = $this->lexer->getPrevious();\n        if ($prev->isA(EmailLexer::S_DOT)) {\n            return new InvalidEmail(new DotAtEnd(), $this->lexer->current->value);\n        }\n        if ($prev->isA(EmailLexer::S_HYPHEN)) {\n            return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev->value);\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_SP)) {\n            return new InvalidEmail(new CRLFAtTheEnd(), $prev->value);\n        }\n        return new ValidEmail();\n    }\n\n    private function performDomainStartChecks(): Result\n    {\n        $invalidTokens = $this->checkInvalidTokensAfterAT();\n        if ($invalidTokens->isInvalid()) {\n            return $invalidTokens;\n        }\n\n        $missingDomain = $this->checkEmptyDomain();\n        if ($missingDomain->isInvalid()) {\n            return $missingDomain;\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) {\n            $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();\n        }\n        return new ValidEmail();\n    }\n\n    private function checkEmptyDomain(): Result\n    {\n        $thereIsNoDomain = $this->lexer->current->isA(EmailLexer::S_EMPTY) ||\n            ($this->lexer->current->isA(EmailLexer::S_SP) &&\n                !$this->lexer->isNextToken(EmailLexer::GENERIC));\n\n        if ($thereIsNoDomain) {\n            return new InvalidEmail(new NoDomainPart(), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    private function checkInvalidTokensAfterAT(): Result\n    {\n        if ($this->lexer->current->isA(EmailLexer::S_DOT)) {\n            return new InvalidEmail(new DotAtStart(), $this->lexer->current->value);\n        }\n        if ($this->lexer->current->isA(EmailLexer::S_HYPHEN)) {\n            return new InvalidEmail(new DomainHyphened('After AT'), $this->lexer->current->value);\n        }\n        return new ValidEmail();\n    }\n\n    protected function parseComments(): Result\n    {\n        $commentParser = new Comment($this->lexer, new DomainComment());\n        $result = $commentParser->parse();\n        $this->warnings = [...$this->warnings, ...$commentParser->getWarnings()];\n\n        return $result;\n    }\n\n    protected function doParseDomainPart(): Result\n    {\n        $tldMissing = true;\n        $hasComments = false;\n        $domain = '';\n        do {\n            $prev = $this->lexer->getPrevious();\n\n            $notAllowedChars = $this->checkNotAllowedChars($this->lexer->current);\n            if ($notAllowedChars->isInvalid()) {\n                return $notAllowedChars;\n            }\n\n            if (\n                $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) ||\n                $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS)\n            ) {\n                $hasComments = true;\n                $commentsResult = $this->parseComments();\n\n                //Invalid comment parsing\n                if ($commentsResult->isInvalid()) {\n                    return $commentsResult;\n                }\n            }\n\n            $dotsResult = $this->checkConsecutiveDots();\n            if ($dotsResult->isInvalid()) {\n                return $dotsResult;\n            }\n\n            if ($this->lexer->current->isA(EmailLexer::S_OPENBRACKET)) {\n                $literalResult = $this->parseDomainLiteral();\n\n                $this->addTLDWarnings($tldMissing);\n                return $literalResult;\n            }\n\n            $labelCheck = $this->checkLabelLength();\n            if ($labelCheck->isInvalid()) {\n                return $labelCheck;\n            }\n\n            $FwsResult = $this->parseFWS();\n            if ($FwsResult->isInvalid()) {\n                return $FwsResult;\n            }\n\n            $domain .= $this->lexer->current->value;\n\n            if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::GENERIC)) {\n                $tldMissing = false;\n            }\n\n            $exceptionsResult = $this->checkDomainPartExceptions($prev, $hasComments);\n            if ($exceptionsResult->isInvalid()) {\n                return $exceptionsResult;\n            }\n            $this->lexer->moveNext();\n        } while (!$this->lexer->current->isA(EmailLexer::S_EMPTY));\n\n        $labelCheck = $this->checkLabelLength(true);\n        if ($labelCheck->isInvalid()) {\n            return $labelCheck;\n        }\n        $this->addTLDWarnings($tldMissing);\n\n        $this->domainPart = $domain;\n        return new ValidEmail();\n    }\n\n     /**\n     * @param Token<int, string> $token\n     *\n     * @return Result\n     */\n    private function checkNotAllowedChars(Token $token): Result\n    {\n        $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH => true];\n        if (isset($notAllowed[$token->type])) {\n            return new InvalidEmail(new CharNotAllowed(), $token->value);\n        }\n        return new ValidEmail();\n    }\n\n    /**\n     * @return Result\n     */\n    protected function parseDomainLiteral(): Result\n    {\n        try {\n            $this->lexer->find(EmailLexer::S_CLOSEBRACKET);\n        } catch (\\RuntimeException $e) {\n            return new InvalidEmail(new ExpectingDomainLiteralClose(), $this->lexer->current->value);\n        }\n\n        $domainLiteralParser = new DomainLiteralParser($this->lexer);\n        $result = $domainLiteralParser->parse();\n        $this->warnings = [...$this->warnings, ...$domainLiteralParser->getWarnings()];\n        return $result;\n    }\n\n    /**\n     * @param Token<int, string> $prev\n     * @param bool $hasComments\n     *\n     * @return Result\n     */\n    protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result\n    {\n        if ($this->lexer->current->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) {\n            return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->current->value);\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_HYPHEN) && $this->lexer->isNextToken(EmailLexer::S_DOT)) {\n            return new InvalidEmail(new DomainHyphened('Hypen found near DOT'), $this->lexer->current->value);\n        }\n\n        if (\n            $this->lexer->current->isA(EmailLexer::S_BACKSLASH)\n            && $this->lexer->isNextToken(EmailLexer::GENERIC)\n        ) {\n            return new InvalidEmail(new ExpectingATEXT('Escaping following \"ATOM\"'), $this->lexer->current->value);\n        }\n\n        return $this->validateTokens($hasComments);\n    }\n\n    protected function validateTokens(bool $hasComments): Result\n    {\n        $validDomainTokens = array(\n            EmailLexer::GENERIC => true,\n            EmailLexer::S_HYPHEN => true,\n            EmailLexer::S_DOT => true,\n        );\n\n        if ($hasComments) {\n            $validDomainTokens[EmailLexer::S_OPENPARENTHESIS] = true;\n            $validDomainTokens[EmailLexer::S_CLOSEPARENTHESIS] = true;\n        }\n\n        if (!isset($validDomainTokens[$this->lexer->current->type])) {\n            return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->current->value), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    private function checkLabelLength(bool $isEndOfDomain = false): Result\n    {\n        if ($this->lexer->current->isA(EmailLexer::S_DOT) || $isEndOfDomain) {\n            if ($this->isLabelTooLong($this->label)) {\n                return new InvalidEmail(new LabelTooLong(), $this->lexer->current->value);\n            }\n            $this->label = '';\n        }\n        $this->label .= $this->lexer->current->value;\n        return new ValidEmail();\n    }\n\n\n    private function isLabelTooLong(string $label): bool\n    {\n        if (preg_match('/[^\\x00-\\x7F]/', $label)) {\n            idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);\n            /** @psalm-var array{errors: int, ...} $idnaInfo */\n            return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG);\n        }\n        return strlen($label) > self::LABEL_MAX_LENGTH;\n    }\n\n    private function addTLDWarnings(bool $isTLDMissing): void\n    {\n        if ($isTLDMissing) {\n            $this->warnings[TLD::CODE] = new TLD();\n        }\n    }\n\n    public function domainPart(): string\n    {\n        return $this->domainPart;\n    }\n}\n"
  },
  {
    "path": "src/Parser/DoubleQuote.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\CFWSWithFWS;\nuse Egulias\\EmailValidator\\Warning\\QuotedString;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnclosedQuotedString;\nuse Egulias\\EmailValidator\\Result\\Result;\n\nclass DoubleQuote extends PartParser\n{\n    public function parse(): Result\n    {\n\n        $validQuotedString = $this->checkDQUOTE();\n        if ($validQuotedString->isInvalid()) {\n            return $validQuotedString;\n        }\n\n        $special = [\n            EmailLexer::S_CR => true,\n            EmailLexer::S_HTAB => true,\n            EmailLexer::S_LF => true\n        ];\n\n        $invalid = [\n            EmailLexer::C_NUL => true,\n            EmailLexer::S_HTAB => true,\n            EmailLexer::S_CR => true,\n            EmailLexer::S_LF => true\n        ];\n\n        $setSpecialsWarning = true;\n\n        $this->lexer->moveNext();\n\n        while (!$this->lexer->current->isA(EmailLexer::S_DQUOTE) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) {\n            if (isset($special[$this->lexer->current->type]) && $setSpecialsWarning) {\n                $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();\n                $setSpecialsWarning = false;\n            }\n            if ($this->lexer->current->isA(EmailLexer::S_BACKSLASH) && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) {\n                $this->lexer->moveNext();\n            }\n\n            $this->lexer->moveNext();\n\n            if (!$this->escaped() && isset($invalid[$this->lexer->current->type])) {\n                return new InvalidEmail(new ExpectingATEXT(\"Expecting ATEXT between DQUOTE\"), $this->lexer->current->value);\n            }\n        }\n\n        $prev = $this->lexer->getPrevious();\n\n        if ($prev->isA(EmailLexer::S_BACKSLASH)) {\n            $validQuotedString = $this->checkDQUOTE();\n            if ($validQuotedString->isInvalid()) {\n                return $validQuotedString;\n            }\n        }\n\n        if (!$this->lexer->isNextToken(EmailLexer::S_AT) && !$prev->isA(EmailLexer::S_BACKSLASH)) {\n            return new InvalidEmail(new ExpectingATEXT(\"Expecting ATEXT between DQUOTE\"), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    protected function checkDQUOTE(): Result\n    {\n        $previous = $this->lexer->getPrevious();\n\n        if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous->isA(EmailLexer::GENERIC)) {\n            $description = 'https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit';\n            return new InvalidEmail(new ExpectingATEXT($description), $this->lexer->current->value);\n        }\n\n        try {\n            $this->lexer->find(EmailLexer::S_DQUOTE);\n        } catch (\\Exception $e) {\n            return new InvalidEmail(new UnclosedQuotedString(), $this->lexer->current->value);\n        }\n        $this->warnings[QuotedString::CODE] = new QuotedString($previous->value, $this->lexer->current->value);\n\n        return new ValidEmail();\n    }\n}\n"
  },
  {
    "path": "src/Parser/FoldingWhiteSpace.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Warning\\CFWSNearAt;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\CFWSWithFWS;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRNoLF;\nuse Egulias\\EmailValidator\\Result\\Reason\\AtextAfterCFWS;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRLFAtTheEnd;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRLFX2;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingCTEXT;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\n\nclass  FoldingWhiteSpace extends PartParser\n{\n    public const FWS_TYPES = [\n        EmailLexer::S_SP,\n        EmailLexer::S_HTAB,\n        EmailLexer::S_CR,\n        EmailLexer::S_LF,\n        EmailLexer::CRLF\n    ];\n\n    public function parse(): Result\n    {\n        if (!$this->isFWS()) {\n            return new ValidEmail();\n        }\n\n        $previous = $this->lexer->getPrevious();\n\n        $resultCRLF = $this->checkCRLFInFWS();\n        if ($resultCRLF->isInvalid()) {\n            return $resultCRLF;\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_CR)) {\n            return new InvalidEmail(new CRNoLF(), $this->lexer->current->value);\n        }\n\n        if ($this->lexer->isNextToken(EmailLexer::GENERIC) && !$previous->isA(EmailLexer::S_AT)) {\n            return new InvalidEmail(new AtextAfterCFWS(), $this->lexer->current->value);\n        }\n\n        if ($this->lexer->current->isA(EmailLexer::S_LF) || $this->lexer->current->isA(EmailLexer::C_NUL)) {\n            return new InvalidEmail(new ExpectingCTEXT(), $this->lexer->current->value);\n        }\n\n        if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous->isA(EmailLexer::S_AT)) {\n            $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();\n        } else {\n            $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();\n        }\n\n        return new ValidEmail();\n    }\n\n    protected function checkCRLFInFWS(): Result\n    {\n        if (!$this->lexer->current->isA(EmailLexer::CRLF)) {\n            return new ValidEmail();\n        }\n\n        if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {\n            return new InvalidEmail(new CRLFX2(), $this->lexer->current->value);\n        }\n\n        //this has no coverage. Condition is repeated from above one\n        if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {\n            return new InvalidEmail(new CRLFAtTheEnd(), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    protected function isFWS(): bool\n    {\n        if ($this->escaped()) {\n            return false;\n        }\n\n        return in_array($this->lexer->current->type, self::FWS_TYPES);\n    }\n}\n"
  },
  {
    "path": "src/Parser/IDLeftPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\CommentsInIDRight;\n\nclass IDLeftPart extends LocalPart\n{\n    protected function parseComments(): Result\n    {\n        return new InvalidEmail(new CommentsInIDRight(), $this->lexer->current->value);\n    }\n}\n"
  },
  {
    "path": "src/Parser/IDRightPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\n\nclass IDRightPart extends DomainPart\n{\n    protected function validateTokens(bool $hasComments): Result\n    {\n        $invalidDomainTokens = [\n            EmailLexer::S_DQUOTE => true,\n            EmailLexer::S_SQUOTE => true,\n            EmailLexer::S_BACKTICK => true,\n            EmailLexer::S_SEMICOLON => true,\n            EmailLexer::S_GREATERTHAN => true,\n            EmailLexer::S_LOWERTHAN => true,\n        ];\n\n        if (isset($invalidDomainTokens[$this->lexer->current->type])) {\n            return new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ' . $this->lexer->current->value), $this->lexer->current->value);\n        }\n        return new ValidEmail();\n    }\n}\n"
  },
  {
    "path": "src/Parser/LocalPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\LocalTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtEnd;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtStart;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveDot;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Parser\\CommentStrategy\\LocalComment;\n\nclass LocalPart extends PartParser\n{\n    public const INVALID_TOKENS = [\n        EmailLexer::S_COMMA => EmailLexer::S_COMMA,\n        EmailLexer::S_CLOSEBRACKET => EmailLexer::S_CLOSEBRACKET,\n        EmailLexer::S_OPENBRACKET => EmailLexer::S_OPENBRACKET,\n        EmailLexer::S_GREATERTHAN => EmailLexer::S_GREATERTHAN,\n        EmailLexer::S_LOWERTHAN => EmailLexer::S_LOWERTHAN,\n        EmailLexer::S_COLON => EmailLexer::S_COLON,\n        EmailLexer::S_SEMICOLON => EmailLexer::S_SEMICOLON,\n        EmailLexer::INVALID => EmailLexer::INVALID\n    ];\n\n    /**\n     * @var string\n     */\n    private $localPart = '';\n\n\n    public function parse(): Result\n    {\n        $this->lexer->clearRecorded();\n        $this->lexer->startRecording();\n\n        while (!$this->lexer->current->isA(EmailLexer::S_AT) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) {\n            if ($this->hasDotAtStart()) {\n                return new InvalidEmail(new DotAtStart(), $this->lexer->current->value);\n            }\n\n            if ($this->lexer->current->isA(EmailLexer::S_DQUOTE)) {\n                $dquoteParsingResult = $this->parseDoubleQuote();\n\n                //Invalid double quote parsing\n                if ($dquoteParsingResult->isInvalid()) {\n                    return $dquoteParsingResult;\n                }\n            }\n\n            if (\n                $this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS) ||\n                $this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS)\n            ) {\n                $commentsResult = $this->parseComments();\n\n                //Invalid comment parsing\n                if ($commentsResult->isInvalid()) {\n                    return $commentsResult;\n                }\n            }\n\n            if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) {\n                return new InvalidEmail(new ConsecutiveDot(), $this->lexer->current->value);\n            }\n\n            if (\n                $this->lexer->current->isA(EmailLexer::S_DOT) &&\n                $this->lexer->isNextToken(EmailLexer::S_AT)\n            ) {\n                return new InvalidEmail(new DotAtEnd(), $this->lexer->current->value);\n            }\n\n            $resultEscaping = $this->validateEscaping();\n            if ($resultEscaping->isInvalid()) {\n                return $resultEscaping;\n            }\n\n            $resultToken = $this->validateTokens(false);\n            if ($resultToken->isInvalid()) {\n                return $resultToken;\n            }\n\n            $resultFWS = $this->parseLocalFWS();\n            if ($resultFWS->isInvalid()) {\n                return $resultFWS;\n            }\n\n            $this->lexer->moveNext();\n        }\n\n        $this->lexer->stopRecording();\n        $this->localPart = rtrim($this->lexer->getAccumulatedValues(), '@');\n        if (strlen($this->localPart) > LocalTooLong::LOCAL_PART_LENGTH) {\n            $this->warnings[LocalTooLong::CODE] = new LocalTooLong();\n        }\n\n        return new ValidEmail();\n    }\n\n    protected function validateTokens(bool $hasComments): Result\n    {\n        if (isset(self::INVALID_TOKENS[$this->lexer->current->type])) {\n            return new InvalidEmail(new ExpectingATEXT('Invalid token found'), $this->lexer->current->value);\n        }\n        return new ValidEmail();\n    }\n\n    public function localPart(): string\n    {\n        return $this->localPart;\n    }\n\n    private function parseLocalFWS(): Result\n    {\n        $foldingWS = new FoldingWhiteSpace($this->lexer);\n        $resultFWS = $foldingWS->parse();\n        if ($resultFWS->isValid()) {\n            $this->warnings = [...$this->warnings, ...$foldingWS->getWarnings()];\n        }\n        return $resultFWS;\n    }\n\n    private function hasDotAtStart(): bool\n    {\n        return $this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->getPrevious()->isA(EmailLexer::S_EMPTY);\n    }\n\n    private function parseDoubleQuote(): Result\n    {\n        $dquoteParser = new DoubleQuote($this->lexer);\n        $parseAgain = $dquoteParser->parse();\n        $this->warnings = [...$this->warnings, ...$dquoteParser->getWarnings()];\n\n        return $parseAgain;\n    }\n\n    protected function parseComments(): Result\n    {\n        $commentParser = new Comment($this->lexer, new LocalComment());\n        $result = $commentParser->parse();\n        $this->warnings = [...$this->warnings, ...$commentParser->getWarnings()];\n\n        return $result;\n    }\n\n    private function validateEscaping(): Result\n    {\n        //Backslash found\n        if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {\n            return new ValidEmail();\n        }\n\n        if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {\n            return new InvalidEmail(new ExpectingATEXT('Found ATOM after escaping'), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n}\n"
  },
  {
    "path": "src/Parser/PartParser.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Parser;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveDot;\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nabstract class PartParser\n{\n    /**\n     * @var Warning[]\n     */\n    protected $warnings = [];\n\n    /**\n     * @var EmailLexer\n     */\n    protected $lexer;\n\n    public function __construct(EmailLexer $lexer)\n    {\n        $this->lexer = $lexer;\n    }\n\n    abstract public function parse(): Result;\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings()\n    {\n        return $this->warnings;\n    }\n\n    protected function parseFWS(): Result\n    {\n        $foldingWS = new FoldingWhiteSpace($this->lexer);\n        $resultFWS = $foldingWS->parse();\n        $this->warnings = [...$this->warnings, ...$foldingWS->getWarnings()];\n        return $resultFWS;\n    }\n\n    protected function checkConsecutiveDots(): Result\n    {\n        if ($this->lexer->current->isA(EmailLexer::S_DOT) && $this->lexer->isNextToken(EmailLexer::S_DOT)) {\n            return new InvalidEmail(new ConsecutiveDot(), $this->lexer->current->value);\n        }\n\n        return new ValidEmail();\n    }\n\n    protected function escaped(): bool\n    {\n        $previous = $this->lexer->getPrevious();\n\n        return $previous->isA(EmailLexer::S_BACKSLASH)\n            && !$this->lexer->current->isA(EmailLexer::GENERIC);\n    }\n}\n"
  },
  {
    "path": "src/Parser.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator;\n\nuse Egulias\\EmailValidator\\Result\\Result;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\n\nabstract class Parser\n{\n    /**\n     * @var Warning\\Warning[]\n     */\n    protected $warnings = [];\n\n    /**\n     * @var EmailLexer\n     */\n    protected $lexer;\n\n    /**\n     * id-left \"@\" id-right\n     */\n    abstract protected function parseRightFromAt(): Result;\n    abstract protected function parseLeftFromAt(): Result;\n    abstract protected function preLeftParsing(): Result;\n\n\n    public function __construct(EmailLexer $lexer)\n    {\n        $this->lexer = $lexer;\n    }\n\n    public function parse(string $str): Result\n    {\n        $this->lexer->setInput($str);\n\n        if ($this->lexer->hasInvalidTokens()) {\n            return new InvalidEmail(new ExpectingATEXT(\"Invalid tokens found\"), $this->lexer->current->value);\n        }\n\n        $preParsingResult = $this->preLeftParsing();\n        if ($preParsingResult->isInvalid()) {\n            return $preParsingResult;\n        }\n\n        $localPartResult = $this->parseLeftFromAt();\n\n        if ($localPartResult->isInvalid()) {\n            return $localPartResult;\n        }\n\n        $domainPartResult = $this->parseRightFromAt();\n\n        if ($domainPartResult->isInvalid()) {\n            return $domainPartResult;\n        }\n\n        return new ValidEmail();\n    }\n\n    /**\n     * @return Warning\\Warning[]\n     */\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n\n    protected function hasAtToken(): bool\n    {\n        $this->lexer->moveNext();\n        $this->lexer->moveNext();\n\n        return !$this->lexer->current->isA(EmailLexer::S_AT);\n    }\n}\n"
  },
  {
    "path": "src/Result/InvalidEmail.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result;\n\nuse Egulias\\EmailValidator\\Result\\Reason\\Reason;\n\nclass InvalidEmail implements Result\n{\n    /**\n     * @var string\n     */\n    private string $token;\n\n    /**\n     * @var Reason\n     */\n    protected Reason $reason;\n\n    public function __construct(Reason $reason, string $token)\n    {\n        $this->token = $token;\n        $this->reason = $reason;\n    }\n\n    public function isValid(): bool\n    {\n        return false;\n    }\n\n    public function isInvalid(): bool\n    {\n        return true;\n    }\n\n    public function description(): string\n    {\n        return $this->reason->description() . \" in char \" . $this->token;\n    }\n\n    public function code(): int\n    {\n        return $this->reason->code();\n    }\n\n    public function reason(): Reason\n    {\n        return $this->reason;\n    }\n}\n"
  },
  {
    "path": "src/Result/MultipleErrors.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result;\n\nuse Egulias\\EmailValidator\\Result\\Reason\\EmptyReason;\nuse Egulias\\EmailValidator\\Result\\Reason\\Reason;\n\n/**\n * @psalm-suppress PropertyNotSetInConstructor\n */\nclass MultipleErrors extends InvalidEmail\n{\n    /**\n     * @var Reason[]\n     */\n    private $reasons = [];\n\n    public function __construct()\n    {\n    }\n\n    public function addReason(Reason $reason) : void\n    {\n        $this->reasons[$reason->code()] = $reason;\n    }\n\n    /**\n     * @return Reason[]\n     */\n    public function getReasons() : array\n    {\n        return $this->reasons;\n    }\n\n    public function reason() : Reason\n    {\n        return 0 !== count($this->reasons)\n            ? current($this->reasons)\n            : new EmptyReason();\n    }\n\n    public function description() : string\n    {\n        $description = '';\n        foreach($this->reasons as $reason) {\n            $description .= $reason->description() . PHP_EOL;\n        }\n\n        return $description;\n    }\n\n    public function code() : int\n    {\n        return 0;\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/AtextAfterCFWS.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass AtextAfterCFWS implements Reason\n{\n    public function code() : int\n    {\n        return 133;\n    }\n\n    public function description() : string\n    {\n        return 'ATEXT found after CFWS';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CRLFAtTheEnd.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CRLFAtTheEnd implements Reason\n{\n    public const CODE = 149;\n    public const REASON = \"CRLF at the end\";\n\n    public function code() : int\n    {\n        return 149;\n    }\n\n    public function description() : string\n    {\n        return 'CRLF at the end';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CRLFX2.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CRLFX2 implements Reason\n{\n    public function code() : int\n    {\n        return 148;\n    }\n\n    public function description() : string\n    {\n        return 'CR  LF tokens found twice';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CRNoLF.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CRNoLF implements Reason\n{\n    public function code() : int\n    {\n        return 150;\n    }\n\n    public function description() : string\n    {\n        return 'Missing LF after CR';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CharNotAllowed.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CharNotAllowed implements Reason\n{\n    public function code() : int\n    {\n        return 1;\n    }\n\n    public function description() : string\n    {\n        return \"Character not allowed\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CommaInDomain.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CommaInDomain implements Reason\n{\n    public function code() : int\n    {\n        return 200;\n    }\n\n    public function description() : string\n    {\n        return \"Comma ',' is not allowed in domain part\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/CommentsInIDRight.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass CommentsInIDRight implements Reason\n{\n    public function code() : int\n    {\n        return 400;\n    }\n\n    public function description() : string\n    {\n        return 'Comments are not allowed in IDRight for message-id';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ConsecutiveAt.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ConsecutiveAt implements Reason\n{\n    public function code() : int\n    {\n        return 128;\n    }\n\n    public function description() : string\n    {\n        return '@ found after another @';\n    }\n\n}\n"
  },
  {
    "path": "src/Result/Reason/ConsecutiveDot.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ConsecutiveDot implements Reason\n{\n    public function code() : int\n    {\n        return 132;\n    }\n\n    public function description() : string\n    {\n        return 'Concecutive DOT found';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DetailedReason.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nabstract class DetailedReason implements Reason\n{\n    protected $detailedDescription;\n\n    public function __construct(string $details)\n    {\n        $this->detailedDescription = $details;\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DomainAcceptsNoMail.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass DomainAcceptsNoMail implements Reason\n{\n    public function code() : int\n    {\n        return 154;\n    }\n\n    public function description() : string\n    {\n        return 'Domain accepts no mail (Null MX, RFC7505)';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DomainHyphened.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass DomainHyphened extends DetailedReason\n{\n    public function code() : int\n    {\n        return 144;\n    }\n\n    public function description() : string\n    {\n        return 'S_HYPHEN found in domain';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DomainTooLong.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass DomainTooLong implements Reason\n{\n    public function code() : int\n    {\n        return 244;\n    }\n\n    public function description() : string\n    {\n        return 'Domain is longer than 253 characters';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DotAtEnd.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass DotAtEnd implements Reason\n{\n    public function code() : int\n    {\n        return 142;\n    }\n\n    public function description() : string\n    {\n        return 'Dot at the end';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/DotAtStart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass DotAtStart implements Reason\n{\n    public function code() : int\n    {\n        return 141;\n    }\n\n    public function description() : string\n    {\n        return \"Starts with a DOT\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/EmptyReason.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass EmptyReason implements Reason\n{\n    public function code() : int\n    {\n        return 0;\n    }\n\n    public function description() : string\n    {\n        return 'Empty reason';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ExceptionFound.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ExceptionFound implements Reason\n{\n    /**\n     * @var \\Exception\n     */\n    private $exception;\n\n    public function __construct(\\Exception $exception)\n    {\n        $this->exception = $exception;\n        \n    }\n    public function code() : int\n    {\n        return 999;\n    }\n\n    public function description() : string\n    {\n        return $this->exception->getMessage();\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ExpectingATEXT.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ExpectingATEXT extends DetailedReason\n{\n    public function code() : int\n    {\n        return 137;\n    }\n\n    public function description() : string\n    {\n        return \"Expecting ATEXT (Printable US-ASCII). Extended: \" . $this->detailedDescription;\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ExpectingCTEXT.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ExpectingCTEXT implements Reason\n{\n    public function code() : int\n    {\n        return 139;\n    }\n\n    public function description() : string\n    {\n        return 'Expecting CTEXT';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ExpectingDTEXT.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ExpectingDTEXT implements Reason\n{\n    public function code() : int\n    {\n        return 129;\n    }\n\n    public function description() : string\n    {\n        return 'Expecting DTEXT';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/ExpectingDomainLiteralClose.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass ExpectingDomainLiteralClose implements Reason\n{\n    public function code() : int\n    {\n        return 137;\n    }\n\n    public function description() : string\n    {\n        return \"Closing bracket ']' for domain literal not found\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/LabelTooLong.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass LabelTooLong implements Reason\n{\n    public function code() : int\n    {\n        return 245;\n    }\n\n    public function description() : string\n    {\n        return 'Domain \"label\" is longer than 63 characters';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/LocalOrReservedDomain.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass LocalOrReservedDomain implements Reason\n{\n    public function code() : int\n    {\n        return 153;\n    }\n\n    public function description() : string\n    {\n        return 'Local, mDNS or reserved domain (RFC2606, RFC6762)';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/NoDNSRecord.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass NoDNSRecord implements Reason \n{\n    public function code() : int\n    {\n        return 5;\n    }\n\n    public function description() : string\n    {\n        return 'No MX or A DNS record was found for this email';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/NoDomainPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass NoDomainPart implements Reason\n{\n    public function code() : int\n    {\n        return 131;\n    }\n\n    public function description() : string\n    {\n        return 'No domain part found';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/NoLocalPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass NoLocalPart implements Reason \n{\n    public function code() : int\n    {\n        return 130;\n    }\n\n    public function description() : string\n    {\n        return \"No local part\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/RFCWarnings.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass RFCWarnings implements Reason\n{\n    public function code() : int\n    {\n        return 997;\n    }\n\n    public function description() : string\n    {\n        return 'Warnings found after validating';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/Reason.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\ninterface Reason\n{\n    /**\n     * Code for user land to act upon;\n     */\n    public function code() : int;\n\n    /**\n     * Short description of the result, human readable.\n     */\n    public function description() : string;\n}\n"
  },
  {
    "path": "src/Result/Reason/SpoofEmail.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass SpoofEmail implements Reason\n{\n    public function code() : int\n    {\n        return 298;\n    }\n\n    public function description() : string\n    {\n        return 'The email contains mixed UTF8 chars that makes it suspicious'; \n    }\n\n}\n"
  },
  {
    "path": "src/Result/Reason/UnOpenedComment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass UnOpenedComment implements Reason\n{\n    public function code() : int\n    {\n        return 152;\n    }\n\n    public function description(): string\n    {\n        return 'Missing opening comment parentheses - https://tools.ietf.org/html/rfc5322#section-3.2.2';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/UnableToGetDNSRecord.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\n/**\n * Used on SERVFAIL, TIMEOUT or other runtime and network errors\n */\nclass UnableToGetDNSRecord extends NoDNSRecord\n{\n    public function code() : int\n    {\n        return 3;\n    }\n\n    public function description() : string\n    {\n        return 'Unable to get DNS records for the host';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/UnclosedComment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass UnclosedComment implements Reason \n{\n    public function code() : int\n    {\n        return 146;\n    }\n\n    public function description(): string\n    {\n        return 'No closing comment token found';\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/UnclosedQuotedString.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass UnclosedQuotedString implements Reason\n{\n    public function code() : int\n    {\n        return 145;\n    }\n\n    public function description() : string\n    {\n        return \"Unclosed quoted string\";\n    }\n}\n"
  },
  {
    "path": "src/Result/Reason/UnusualElements.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result\\Reason;\n\nclass UnusualElements implements Reason\n{\n    /**\n     * @var string $element\n     */\n    private $element;\n\n    public function __construct(string $element)\n    {\n        $this->element = $element;\n    }\n\n    public function code() : int\n    {\n        return 201;\n    }\n\n    public function description() : string\n    {\n        return 'Unusual element found, wourld render invalid in majority of cases. Element found: ' . $this->element;\n    }\n}\n"
  },
  {
    "path": "src/Result/Result.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result;\n\ninterface Result\n{\n    /**\n     * Is validation result valid?\n     * \n     */\n    public function isValid(): bool;\n\n    /**\n     * Is validation result invalid?\n     * Usually the inverse of isValid()\n     * \n     */\n    public function isInvalid(): bool;\n\n    /**\n     * Short description of the result, human readable.\n     * \n     */\n    public function description(): string;\n\n    /**\n     * Code for user land to act upon.\n     * \n     */\n    public function code(): int;\n}\n"
  },
  {
    "path": "src/Result/SpoofEmail.php",
    "content": "<?php\nnamespace Egulias\\EmailValidator\\Result;\n\nuse Egulias\\EmailValidator\\Result\\Reason\\SpoofEmail as ReasonSpoofEmail;\n\nclass SpoofEmail extends InvalidEmail\n{\n    public function __construct()\n    {\n        $this->reason = new ReasonSpoofEmail();\n        parent::__construct($this->reason, '');\n    }\n}\n"
  },
  {
    "path": "src/Result/ValidEmail.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Result;\n\nclass ValidEmail implements Result\n{\n    public function isValid(): bool\n    {\n        return true;\n    }\n\n    public function isInvalid(): bool\n    {\n        return false;\n    }\n\n    public function description(): string\n    {\n        return \"Valid email\";\n    }\n\n    public function code(): int\n    {\n        return 0;\n    }\n\n}\n"
  },
  {
    "path": "src/Validation/DNSCheckValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\DomainAcceptsNoMail;\nuse Egulias\\EmailValidator\\Result\\Reason\\LocalOrReservedDomain;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoDNSRecord as ReasonNoDNSRecord;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnableToGetDNSRecord;\nuse Egulias\\EmailValidator\\Warning\\NoDNSMXRecord;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nclass DNSCheckValidation implements EmailValidation\n{\n\n    /**\n     * Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2),\n     * mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G)\n     * \n     * @var string[]\n     */\n    public const RESERVED_DNS_TOP_LEVEL_NAMES = [\n        // Reserved Top Level DNS Names\n        'test',\n        'example',\n        'invalid',\n        'localhost',\n\n        // mDNS\n        'local',\n\n        // Private DNS Namespaces\n        'intranet',\n        'internal',\n        'private',\n        'corp',\n        'home',\n        'lan',\n    ];\n\n    /**\n     * @var Warning[]\n     */\n    private $warnings = [];\n\n    /**\n     * @var InvalidEmail|null\n     */\n    private $error;\n\n    /**\n     * @var array\n     */\n    private $mxRecords = [];\n\n    /**\n     * @var DNSGetRecordWrapper\n     */\n    private $dnsGetRecord;\n\n    public function __construct(?DNSGetRecordWrapper $dnsGetRecord = null)\n    {\n        if (!function_exists('idn_to_ascii')) {\n            throw new \\LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));\n        }\n\n        if ($dnsGetRecord == null) {\n            $dnsGetRecord = new DNSGetRecordWrapper();\n        }\n\n        $this->dnsGetRecord = $dnsGetRecord;\n    }\n\n    public function isValid(string $email, EmailLexer $emailLexer): bool\n    {\n        // use the input to check DNS if we cannot extract something similar to a domain\n        $host = $email;\n\n        // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email\n        if (false !== $lastAtPos = strrpos($email, '@')) {\n            $host = substr($email, $lastAtPos + 1);\n        }\n\n        // Get the domain parts\n        $hostParts = explode('.', $host);\n\n        $isLocalDomain = count($hostParts) <= 1;\n        $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], self::RESERVED_DNS_TOP_LEVEL_NAMES, true);\n\n        // Exclude reserved top level DNS names\n        if ($isLocalDomain || $isReservedTopLevel) {\n            $this->error = new InvalidEmail(new LocalOrReservedDomain(), $host);\n            return false;\n        }\n\n        return $this->checkDns($host);\n    }\n\n    public function getError(): ?InvalidEmail\n    {\n        return $this->error;\n    }\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n\n    /**\n     * @param string $host\n     *\n     * @return bool\n     */\n    protected function checkDns($host)\n    {\n        $variant = INTL_IDNA_VARIANT_UTS46;\n\n        $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.');\n\n        $hostParts = explode('.', $host);\n        $host = array_pop($hostParts);\n\n        while (count($hostParts) > 0) {\n            $host = array_pop($hostParts) . '.' . $host;\n\n            if ($this->validateDnsRecords($host)) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n\n    /**\n     * Validate the DNS records for given host.\n     *\n     * @param string $host A set of DNS records in the format returned by dns_get_record.\n     *\n     * @return bool True on success.\n     */\n    private function validateDnsRecords($host): bool\n    {\n        $dnsRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_A + DNS_MX);\n\n        if ($dnsRecordsResult->withError()) {\n            $this->error = new InvalidEmail(new UnableToGetDNSRecord(), '');\n            return false;\n        }\n\n        $dnsRecords = $dnsRecordsResult->getRecords();\n\n        // Combined check for A+MX+AAAA can fail with SERVFAIL, even in the presence of valid A/MX records\n        $aaaaRecordsResult = $this->dnsGetRecord->getRecords($host, DNS_AAAA);\n\n        if (! $aaaaRecordsResult->withError()) {\n            $dnsRecords = array_merge($dnsRecords, $aaaaRecordsResult->getRecords());\n        }\n\n        // No MX, A or AAAA DNS records\n        if ($dnsRecords === []) {\n            $this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');\n            return false;\n        }\n\n        // For each DNS record\n        foreach ($dnsRecords as $dnsRecord) {\n            if (!$this->validateMXRecord($dnsRecord)) {\n                // No MX records (fallback to A or AAAA records)\n                if (empty($this->mxRecords)) {\n                    $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord();\n                }\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Validate an MX record\n     *\n     * @param array $dnsRecord Given DNS record.\n     *\n     * @return bool True if valid.\n     */\n    private function validateMxRecord($dnsRecord): bool\n    {\n        if (!isset($dnsRecord['type'])) {\n            $this->error = new InvalidEmail(new ReasonNoDNSRecord(), '');\n            return false;\n        }\n\n        if ($dnsRecord['type'] !== 'MX') {\n            return true;\n        }\n\n        // \"Null MX\" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505)\n        if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') {\n            $this->error = new InvalidEmail(new DomainAcceptsNoMail(), \"\");\n            return false;\n        }\n\n        $this->mxRecords[] = $dnsRecord;\n\n        return true;\n    }\n}\n"
  },
  {
    "path": "src/Validation/DNSGetRecordWrapper.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nclass DNSGetRecordWrapper\n{\n    /**\n     * @param string $host\n     * @param int $type\n     *\n     * @return DNSRecords\n     */\n    public function getRecords(string $host, int $type): DNSRecords\n    {\n        // A workaround to fix https://bugs.php.net/bug.php?id=73149\n        set_error_handler(\n            static function (int $errorLevel, string $errorMessage): never {\n                throw new \\RuntimeException(\"Unable to get DNS record for the host: $errorMessage\");\n            }\n        );\n        try {\n            // Get all MX, A and AAAA DNS records for host\n            return new DNSRecords(dns_get_record($host, $type));\n        } catch (\\RuntimeException $exception) {\n            return new DNSRecords([], true);\n        } finally {\n            restore_error_handler();\n        }\n    }\n}\n"
  },
  {
    "path": "src/Validation/DNSRecords.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nclass DNSRecords\n{\n    /**\n     * @param list<array<array-key, mixed>> $records\n     * @param bool $error\n     */\n    public function __construct(private readonly array $records, private readonly bool $error = false)\n    {\n    }\n\n    /**\n     * @return list<array<array-key, mixed>>\n     */\n    public function getRecords(): array\n    {\n        return $this->records;\n    }\n\n    public function withError(): bool\n    {\n        return $this->error;\n    }\n}\n"
  },
  {
    "path": "src/Validation/EmailValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\ninterface EmailValidation\n{\n    /**\n     * Returns true if the given email is valid.\n     *\n     * @param string     $email      The email you want to validate.\n     * @param EmailLexer $emailLexer The email lexer.\n     *\n     * @return bool\n     */\n    public function isValid(string $email, EmailLexer $emailLexer) : bool;\n\n    /**\n     * Returns the validation error.\n     *\n     * @return InvalidEmail|null\n     */\n    public function getError() : ?InvalidEmail;\n\n    /**\n     * Returns the validation warnings.\n     *\n     * @return Warning[]\n     */\n    public function getWarnings() : array;\n}\n"
  },
  {
    "path": "src/Validation/Exception/EmptyValidationList.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation\\Exception;\n\nuse Exception;\n\nclass EmptyValidationList extends \\InvalidArgumentException\n{\n    /**\n    * @param int $code\n    */\n    public function __construct($code = 0, ?Exception $previous = null)\n    {\n        parent::__construct(\"Empty validation list is not allowed\", $code, $previous);\n    }\n}\n"
  },
  {
    "path": "src/Validation/Extra/SpoofCheckValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation\\Extra;\n\nuse \\Spoofchecker;\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\SpoofEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Validation\\EmailValidation;\n\nclass SpoofCheckValidation implements EmailValidation\n{\n    /**\n     * @var InvalidEmail|null\n     */\n    private $error;\n\n    public function __construct()\n    {\n        if (!extension_loaded('intl')) {\n            throw new \\LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));\n        }\n    }\n\n    public function isValid(string $email, EmailLexer $emailLexer) : bool\n    {\n        $checker = new Spoofchecker();\n        $checker->setChecks(Spoofchecker::SINGLE_SCRIPT);\n\n        if ($checker->isSuspicious($email)) {\n            $this->error = new SpoofEmail();\n        }\n\n        return $this->error === null;\n    }\n\n    public function getError() : ?InvalidEmail\n    {\n        return $this->error;\n    }\n\n    public function getWarnings() : array\n    {\n        return [];\n    }\n}\n"
  },
  {
    "path": "src/Validation/MessageIDValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\MessageIDParser;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExceptionFound;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nclass MessageIDValidation implements EmailValidation\n{\n\n    /**\n     * @var Warning[]\n     */\n    private $warnings = [];\n\n    /**\n     * @var ?InvalidEmail\n     */\n    private $error;\n\n    public function isValid(string $email, EmailLexer $emailLexer): bool\n    {\n        $parser = new MessageIDParser($emailLexer);\n        try {\n            $result = $parser->parse($email);\n            $this->warnings = $parser->getWarnings();\n            if ($result->isInvalid()) {\n                /** @psalm-suppress PropertyTypeCoercion */\n                $this->error = $result;\n                return false;\n            }\n        } catch (\\Exception $invalid) {\n            $this->error = new InvalidEmail(new ExceptionFound($invalid), '');\n            return false;\n        }\n\n        return true;\n    }\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n\n    public function getError(): ?InvalidEmail\n    {\n        return $this->error;\n    }\n}\n"
  },
  {
    "path": "src/Validation/MultipleValidationWithAnd.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Validation\\Exception\\EmptyValidationList;\nuse Egulias\\EmailValidator\\Result\\MultipleErrors;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nclass MultipleValidationWithAnd implements EmailValidation\n{\n    /**\n     * If one of validations fails, the remaining validations will be skipped.\n     * This means MultipleErrors will only contain a single error, the first found.\n     */\n    public const STOP_ON_ERROR = 0;\n\n    /**\n     * All of validations will be invoked even if one of them got failure.\n     * So MultipleErrors will contain all causes.\n     */\n    public const ALLOW_ALL_ERRORS = 1;\n\n    /**\n     * @var Warning[]\n     */\n    private $warnings = [];\n\n    /**\n     * @var MultipleErrors|null\n     */\n    private $error;\n\n    /**\n     * @param EmailValidation[] $validations The validations.\n     * @param int               $mode        The validation mode (one of the constants).\n     */\n    public function __construct(private readonly array $validations, private readonly int $mode = self::ALLOW_ALL_ERRORS)\n    {\n        if (count($validations) == 0) {\n            throw new EmptyValidationList();\n        }\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function isValid(string $email, EmailLexer $emailLexer): bool\n    {\n        $result = true;\n        foreach ($this->validations as $validation) {\n            $emailLexer->reset();\n            $validationResult = $validation->isValid($email, $emailLexer);\n            $result = $result && $validationResult;\n            $this->warnings = [...$this->warnings, ...$validation->getWarnings()];\n            if (!$validationResult) {\n                $this->processError($validation);\n            }\n\n            if ($this->shouldStop($result)) {\n                break;\n            }\n        }\n\n        return $result;\n    }\n\n    private function initErrorStorage(): void\n    {\n        if (null === $this->error) {\n            $this->error = new MultipleErrors();\n        }\n    }\n\n    private function processError(EmailValidation $validation): void\n    {\n        if (null !== $validation->getError()) {\n            $this->initErrorStorage();\n            /** @psalm-suppress PossiblyNullReference */\n            $this->error->addReason($validation->getError()->reason());\n        }\n    }\n\n    private function shouldStop(bool $result): bool\n    {\n        return !$result && $this->mode === self::STOP_ON_ERROR;\n    }\n\n    /**\n     * Returns the validation errors.\n     */\n    public function getError(): ?InvalidEmail\n    {\n        return $this->error;\n    }\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n}\n"
  },
  {
    "path": "src/Validation/NoRFCWarningsValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\RFCWarnings;\n\nclass NoRFCWarningsValidation extends RFCValidation\n{\n    /**\n     * @var InvalidEmail|null\n     */\n    private $error;\n\n    /**\n     * {@inheritdoc}\n     */\n    public function isValid(string $email, EmailLexer $emailLexer) : bool\n    {\n        if (!parent::isValid($email, $emailLexer)) {\n            return false;\n        }\n\n        if (empty($this->getWarnings())) {\n            return true;\n        }\n\n        $this->error = new InvalidEmail(new RFCWarnings(), '');\n\n        return false;\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function getError() : ?InvalidEmail\n    {\n        return $this->error ?: parent::getError();\n    }\n}\n"
  },
  {
    "path": "src/Validation/RFCValidation.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\EmailParser;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExceptionFound;\nuse Egulias\\EmailValidator\\Warning\\Warning;\n\nclass RFCValidation implements EmailValidation\n{\n    /**\n     * @var Warning[]\n     */\n    private array $warnings = [];\n\n    /**\n     * @var ?InvalidEmail\n     */\n    private $error;\n\n    public function isValid(string $email, EmailLexer $emailLexer): bool\n    {\n        $parser = new EmailParser($emailLexer);\n        try {\n            $result = $parser->parse($email);\n            $this->warnings = $parser->getWarnings();\n            if ($result->isInvalid()) {\n                /** @psalm-suppress PropertyTypeCoercion */\n                $this->error = $result;\n                return false;\n            }\n        } catch (\\Exception $invalid) {\n            $this->error = new InvalidEmail(new ExceptionFound($invalid), '');\n            return false;\n        }\n\n        return true;\n    }\n\n    public function getError(): ?InvalidEmail\n    {\n        return $this->error;\n    }\n\n    /**\n     * @return Warning[]\n     */\n    public function getWarnings(): array\n    {\n        return $this->warnings;\n    }\n}\n"
  },
  {
    "path": "src/Warning/AddressLiteral.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass AddressLiteral extends Warning\n{\n    public const CODE = 12;\n\n    public function __construct()\n    {\n        $this->message = 'Address literal in domain part';\n        $this->rfcNumber = 5321;\n    }\n}\n"
  },
  {
    "path": "src/Warning/CFWSNearAt.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass CFWSNearAt extends Warning\n{\n    public const CODE = 49;\n\n    public function __construct()\n    {\n        $this->message = \"Deprecated folding white space near @\";\n    }\n}\n"
  },
  {
    "path": "src/Warning/CFWSWithFWS.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass CFWSWithFWS extends Warning\n{\n    public const CODE = 18;\n\n    public function __construct()\n    {\n        $this->message = 'Folding whites space followed by folding white space';\n    }\n}\n"
  },
  {
    "path": "src/Warning/Comment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass Comment extends Warning\n{\n    public const CODE = 17;\n\n    public function __construct()\n    {\n        $this->message = \"Comments found in this email\";\n    }\n}\n"
  },
  {
    "path": "src/Warning/DeprecatedComment.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass DeprecatedComment extends Warning\n{\n    public const CODE = 37;\n\n    public function __construct()\n    {\n        $this->message = 'Deprecated comments';\n    }\n}\n"
  },
  {
    "path": "src/Warning/DomainLiteral.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass DomainLiteral extends Warning\n{\n    public const CODE = 70;\n\n    public function __construct()\n    {\n        $this->message = 'Domain Literal';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/EmailTooLong.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nuse Egulias\\EmailValidator\\EmailParser;\n\nclass EmailTooLong extends Warning\n{\n    public const CODE = 66;\n\n    public function __construct()\n    {\n        $this->message = 'Email is too long, exceeds ' . EmailParser::EMAIL_MAX_LENGTH;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6BadChar.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6BadChar extends Warning\n{\n    public const CODE = 74;\n\n    public function __construct()\n    {\n        $this->message = 'Bad char in IPV6 domain literal';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6ColonEnd.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6ColonEnd extends Warning\n{\n    public const CODE = 77;\n\n    public function __construct()\n    {\n        $this->message = ':: found at the end of the domain literal';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6ColonStart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6ColonStart extends Warning\n{\n    public const CODE = 76;\n\n    public function __construct()\n    {\n        $this->message = ':: found at the start of the domain literal';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6Deprecated.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6Deprecated extends Warning\n{\n    public const CODE = 13;\n\n    public function __construct()\n    {\n        $this->message = 'Deprecated form of IPV6';\n        $this->rfcNumber = 5321;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6DoubleColon.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6DoubleColon extends Warning\n{\n    public const CODE = 73;\n\n    public function __construct()\n    {\n        $this->message = 'Double colon found after IPV6 tag';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6GroupCount.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6GroupCount extends Warning\n{\n    public const CODE = 72;\n\n    public function __construct()\n    {\n        $this->message = 'Group count is not IPV6 valid';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/IPV6MaxGroups.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass IPV6MaxGroups extends Warning\n{\n    public const CODE = 75;\n\n    public function __construct()\n    {\n        $this->message = 'Reached the maximum number of IPV6 groups allowed';\n        $this->rfcNumber = 5321;\n    }\n}\n"
  },
  {
    "path": "src/Warning/LocalTooLong.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass LocalTooLong extends Warning\n{\n    public const CODE = 64;\n    public const LOCAL_PART_LENGTH = 64;\n\n    public function __construct()\n    {\n        $this->message = 'Local part is too long, exceeds 64 chars (octets)';\n        $this->rfcNumber = 5322;\n    }\n}\n"
  },
  {
    "path": "src/Warning/NoDNSMXRecord.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass NoDNSMXRecord extends Warning\n{\n    public const CODE = 6;\n\n    public function __construct()\n    {\n        $this->message = 'No MX DSN record was found for this email';\n        $this->rfcNumber = 5321;\n    }\n}\n"
  },
  {
    "path": "src/Warning/ObsoleteDTEXT.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass ObsoleteDTEXT extends Warning\n{\n    public const CODE = 71;\n\n    public function __construct()\n    {\n        $this->rfcNumber = 5322;\n        $this->message = 'Obsolete DTEXT in domain literal';\n    }\n}\n"
  },
  {
    "path": "src/Warning/QuotedPart.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nuse UnitEnum;\n\nclass QuotedPart extends Warning\n{\n    public const CODE = 36;\n\n    /**\n     * @param UnitEnum|string|int|null $prevToken\n     * @param UnitEnum|string|int|null $postToken\n     */\n    public function __construct($prevToken, $postToken)\n    {\n        if ($prevToken instanceof UnitEnum) {\n            $prevToken = $prevToken->name;\n        }\n\n        if ($postToken instanceof UnitEnum) {\n            $postToken = $postToken->name;\n        }\n\n        $this->message = \"Deprecated Quoted String found between $prevToken and $postToken\";\n    }\n}\n"
  },
  {
    "path": "src/Warning/QuotedString.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass QuotedString extends Warning\n{\n    public const CODE = 11;\n\n    /**\n     * @param string|int $prevToken\n     * @param string|int $postToken\n     */\n    public function __construct($prevToken, $postToken)\n    {\n        $this->message = \"Quoted String found between $prevToken and $postToken\";\n    }\n}\n"
  },
  {
    "path": "src/Warning/TLD.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nclass TLD extends Warning\n{\n    public const CODE = 9;\n\n    public function __construct()\n    {\n        $this->message = \"RFC5321, TLD\";\n    }\n}\n"
  },
  {
    "path": "src/Warning/Warning.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Warning;\n\nabstract class Warning\n{\n    /**\n     * @var int CODE\n     */\n    public const CODE = 0;\n\n    /**\n     * @var string\n     */\n    protected $message = '';\n\n    /**\n     * @var int\n     */\n    protected $rfcNumber = 0;\n\n    /**\n     * @return string\n     */\n    public function message()\n    {\n        return $this->message;\n    }\n\n    /**\n     * @return int\n     */\n    public function code()\n    {\n        return self::CODE;\n    }\n\n    /**\n     * @return int\n     */\n    public function RFCNumber()\n    {\n        return $this->rfcNumber;\n    }\n\n    /**\n     * @return string\n     */\n    public function __toString(): string\n    {\n        return $this->message() . \" rfc: \" .  $this->rfcNumber . \"internal code: \" . static::CODE;\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Dummy/AnotherDummyReason.php",
    "content": "<?php\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy;\n\nuse Egulias\\EmailValidator\\Result\\Reason\\Reason;\n\nclass AnotherDummyReason implements Reason\n{\n    public function code() : int\n    {\n        return 1;\n    }\n\n    public function description() : string\n    {\n        return 'Dummy Reason';\n    }\n}"
  },
  {
    "path": "tests/EmailValidator/Dummy/DummyReason.php",
    "content": "<?php\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy;\n\nuse Egulias\\EmailValidator\\Result\\Reason\\Reason;\n\nclass DummyReason implements Reason\n{\n    public function code() : int\n    {\n        return 0;\n    }\n\n    public function description() : string\n    {\n        return 'Dummy Reason';\n    }\n}"
  },
  {
    "path": "tests/EmailValidator/EmailLexerTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse PHPUnit\\Framework\\TestCase;\n\nclass EmailLexerTest extends TestCase\n{\n\n    public function testLexerExtendsLib()\n    {\n        $lexer = new EmailLexer();\n        $this->assertInstanceOf('Doctrine\\Common\\Lexer\\AbstractLexer', $lexer);\n    }\n\n    /**\n     *  @dataProvider getTokens\n     *\n     */\n    public function testLexerTokens($str, $token)\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput($str);\n        $lexer->moveNext();\n        $lexer->moveNext();\n        $this->assertEquals($token, $lexer->current->type);\n    }\n\n    public function testLexerParsesMultipleSpaces()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput('  ');\n        $lexer->moveNext();\n        $lexer->moveNext();\n        $this->assertEquals(EmailLexer::S_SP, $lexer->current->type);\n        $lexer->moveNext();\n        $this->assertEquals(EmailLexer::S_SP, $lexer->current->type);\n    }\n\n    /**\n     * @dataProvider invalidUTF8CharsProvider\n     */\n    public function testLexerParsesInvalidUTF8($char)\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput($char);\n        $lexer->moveNext();\n        $lexer->moveNext();\n\n        $this->assertEquals(EmailLexer::INVALID, $lexer->current->type);\n    }\n\n    public static function invalidUTF8CharsProvider()\n    {\n        $chars = array();\n        for ($i = 0; $i < 0x100; ++$i) {\n            $c = self::utf8Chr($i);\n            if (preg_match('/(?=\\p{Cc})(?=[^\\t\\n\\n\\r])/u', $c) && !preg_match('/\\x{0000}/u', $c)) {\n                $chars[] = array($c);\n            }\n        }\n\n        return $chars;\n    }\n\n    protected static function utf8Chr($code_point)\n    {\n\n        if ($code_point < 0 || 0x10FFFF < $code_point || (0xD800 <= $code_point && $code_point <= 0xDFFF)) {\n            return '';\n        }\n\n        if ($code_point < 0x80) {\n            $hex[0] = $code_point;\n            $ret = chr($hex[0]);\n        } elseif ($code_point < 0x800) {\n            $hex[0] = 0x1C0 | $code_point >> 6;\n            $hex[1] = 0x80  | $code_point & 0x3F;\n            $ret = chr($hex[0]) . chr($hex[1]);\n        } elseif ($code_point < 0x10000) {\n            $hex[0] = 0xE0 | $code_point >> 12;\n            $hex[1] = 0x80 | $code_point >> 6 & 0x3F;\n            $hex[2] = 0x80 | $code_point & 0x3F;\n            $ret = chr($hex[0]) . chr($hex[1]) . chr($hex[2]);\n        } else {\n            $hex[0] = 0xF0 | $code_point >> 18;\n            $hex[1] = 0x80 | $code_point >> 12 & 0x3F;\n            $hex[2] = 0x80 | $code_point >> 6 & 0x3F;\n            $hex[3] = 0x80 | $code_point  & 0x3F;\n            $ret = chr($hex[0]) . chr($hex[1]) . chr($hex[2]) . chr($hex[3]);\n        }\n\n        return $ret;\n    }\n\n    public function testLexerForTab()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput(\"foo\\tbar\");\n        $lexer->moveNext();\n        $lexer->skipUntil(EmailLexer::S_HTAB);\n        $lexer->moveNext();\n        $this->assertEquals(EmailLexer::S_HTAB, $lexer->current->type);\n    }\n\n    public function testLexerForUTF8()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput(\"áÇ@bar.com\");\n        $lexer->moveNext();\n        $lexer->moveNext();\n        $this->assertEquals(EmailLexer::GENERIC, $lexer->current->type);\n        $lexer->moveNext();\n        $this->assertEquals(EmailLexer::GENERIC, $lexer->current->type);\n    }\n\n    public function testLexerSearchToken()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput(\"foo\\tbar\");\n        $lexer->moveNext();\n        $this->assertTrue($lexer->find(EmailLexer::S_HTAB));\n    }\n\n    public static function getTokens()\n    {\n        return array(\n            array(\"foo\", EmailLexer::GENERIC),\n            array(\"\\r\", EmailLexer::S_CR),\n            array(\"\\t\", EmailLexer::S_HTAB),\n            array(\"\\r\\n\", EmailLexer::CRLF),\n            array(\"\\n\", EmailLexer::S_LF),\n            array(\" \", EmailLexer::S_SP),\n            array(\"@\", EmailLexer::S_AT),\n            array(\"IPv6\", EmailLexer::S_IPV6TAG),\n            array(\"::\", EmailLexer::S_DOUBLECOLON),\n            array(\":\", EmailLexer::S_COLON),\n            array(\".\", EmailLexer::S_DOT),\n            array(\"\\\"\", EmailLexer::S_DQUOTE),\n            array(\"`\", EmailLexer::S_BACKTICK),\n            array(\"'\", EmailLexer::S_SQUOTE),\n            array(\"-\", EmailLexer::S_HYPHEN),\n            array(\"\\\\\", EmailLexer::S_BACKSLASH),\n            array(\"/\", EmailLexer::S_SLASH),\n            array(\"(\", EmailLexer::S_OPENPARENTHESIS),\n            array(\")\", EmailLexer::S_CLOSEPARENTHESIS),\n            array('<', EmailLexer::S_LOWERTHAN),\n            array('>', EmailLexer::S_GREATERTHAN),\n            array('[', EmailLexer::S_OPENBRACKET),\n            array(']', EmailLexer::S_CLOSEBRACKET),\n            array(';', EmailLexer::S_SEMICOLON),\n            array(',', EmailLexer::S_COMMA),\n            array('<', EmailLexer::S_LOWERTHAN),\n            array('>', EmailLexer::S_GREATERTHAN),\n            array('{', EmailLexer::S_OPENCURLYBRACES),\n            array('}', EmailLexer::S_CLOSECURLYBRACES),\n            array('|', EmailLexer::S_PIPE),\n            array('~', EmailLexer::S_TILDE),\n            array('=', EmailLexer::S_EQUAL),\n            array('+', EmailLexer::S_PLUS),\n            array('¿', EmailLexer::INVERT_QUESTIONMARK),\n            array('?', EmailLexer::QUESTIONMARK),\n            array('#', EmailLexer::NUMBER_SIGN),\n            array('¡', EmailLexer::INVERT_EXCLAMATION),\n            array('_', EmailLexer::S_UNDERSCORE),\n            array('',  EmailLexer::S_EMPTY),\n            array(chr(31),  EmailLexer::INVALID),\n            array(chr(226),  EmailLexer::GENERIC),\n            array(chr(0),  EmailLexer::C_NUL)\n        );\n    }\n\n    public function testRecordIsOffAtStart()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput('foo-bar');\n        $lexer->moveNext();\n        $this->assertEquals('', $lexer->getAccumulatedValues());\n    }\n\n    public function testRecord()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput('foo-bar');\n        $lexer->startRecording();\n        $lexer->moveNext();\n        $lexer->moveNext();\n        $this->assertEquals('foo', $lexer->getAccumulatedValues());\n    }\n\n    public function testRecordAndClear()\n    {\n        $lexer = new EmailLexer();\n        $lexer->setInput('foo-bar');\n        $lexer->startRecording();\n        $lexer->moveNext();\n        $lexer->moveNext();\n        $lexer->clearRecorded();\n        $this->assertEquals('', $lexer->getAccumulatedValues());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/EmailParserTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\EmailParser;\nuse PHPUnit\\Framework\\TestCase;\n\nclass EmailParserTest extends TestCase\n{\n    public static function emailPartsProvider()\n    {\n        return [\n            ['test@foo.com', 'test', 'foo.com'],\n            ['\"user@name\"@example.com', '\"user@name\"', 'example.com'],\n            ['validipv6@[IPv6:2001:db8:1ff::a0b:dbd0]', 'validipv6', '[IPv6:2001:db8:1ff::a0b:dbd0]'],\n            ['validipv4@[127.0.0.0]', 'validipv4', '[127.0.0.0]']\n        ];\n    }\n    /**\n     * @dataProvider emailPartsProvider\n     */\n    public function testGetParts($email, $local, $domain)\n    {\n        $parser = new EmailParser(new EmailLexer());\n        $parser->parse($email);\n\n        $this->assertEquals($local, $parser->getLocalPart());\n        $this->assertEquals($domain, $parser->getDomainPart());\n    }\n\n    public function testMultipleEmailAddresses()\n    {\n        $parser = new EmailParser(new EmailLexer());\n        $parser->parse('some-local-part@some-random-but-large-domain-part.example.com');\n\n        $this->assertSame('some-local-part', $parser->getLocalPart());\n        $this->assertSame('some-random-but-large-domain-part.example.com', $parser->getDomainPart());\n\n        $parser->parse('another-local-part@another.example.com');\n\n        $this->assertSame('another-local-part', $parser->getLocalPart());\n        $this->assertSame('another.example.com', $parser->getDomainPart());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/EmailValidatorTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator;\n\nuse PHPUnit\\Framework\\TestCase;\nuse Egulias\\EmailValidator\\EmailValidator;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy\\DummyReason;\nuse Egulias\\EmailValidator\\Validation\\EmailValidation;\nuse Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd;\n\nclass EmailValidatorTest extends TestCase\n{\n\n\n    public function testValidationIsUsed()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $validator = new EmailValidator();\n        $validation = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation->expects($this->once())->method(\"isValid\")->willReturn(true);\n        $validation->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation->expects($this->once())->method(\"getError\")->willReturn($invalidEmail);\n\n        $this->assertTrue($validator->isValid(\"example@example.com\", $validation));\n    }\n\n    public function testMultipleValidation()\n    {\n        $validator = new EmailValidator();\n        $validation = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation->expects($this->once())->method(\"isValid\")->willReturn(true);\n        $validation->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation->expects($this->never(2))->method(\"getError\");\n        $multiple = new MultipleValidationWithAnd([$validation]);\n\n        $this->assertTrue($validator->isValid(\"example@example.com\", $multiple));\n    }\n\n    public function testValidationIsFalse()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $validator = new EmailValidator();\n        $validation = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation->expects($this->once())->method(\"isValid\")->willReturn(false);\n        $validation->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation->expects($this->once())->method(\"getError\")->willReturn($invalidEmail);\n\n        $this->assertFalse($validator->isValid(\"example@example.com\", $validation));\n        $this->assertEquals(false, $validator->hasWarnings());\n        $this->assertEquals([], $validator->getWarnings());\n        $this->assertEquals($invalidEmail, $validator->getError());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/LexerTokensTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator;\n\nuse PHPUnit\\Framework\\TestCase;\n\nclass LexerTokensTest extends TestCase\n{\n    public function testToken()\n    {\n        $this->markTestIncomplete(\"implement better lexer tokens\");\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Reason/MultipleErrorsTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Reason;\n\nuse Egulias\\EmailValidator\\Result\\MultipleErrors;\nuse Egulias\\EmailValidator\\Result\\Reason\\EmptyReason;\nuse Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy\\AnotherDummyReason;\nuse Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy\\DummyReason;\nuse PHPUnit\\Framework\\TestCase;\n\nclass MultipleErrorsTest extends TestCase\n{\n    public function testRegisterSameReason()\n    {\n        $error1 = new DummyReason();\n        $error2 = new DummyReason();\n\n        $multiError = new MultipleErrors();\n        $multiError->addReason($error1);\n        $multiError->addReason($error2);\n\n        $this->assertCount(1, $multiError->getReasons());\n    }\n\n    public function testRegisterDifferentReasons()\n    {\n        $error1 = new DummyReason();\n        $error2 = new AnotherDummyReason();\n        $expectedReason = $error1->description() . PHP_EOL . $error2->description() . PHP_EOL;\n\n        $multiError = new MultipleErrors();\n        $multiError->addReason($error1);\n        $multiError->addReason($error2);\n\n        $this->assertCount(2, $multiError->getReasons());\n        $this->assertEquals($expectedReason, $multiError->description());\n        $this->assertEquals($error1, $multiError->reason());\n    }\n\n    public function testRetrieveFirstReasonWithReasonCodeEqualsZero(): void\n    {\n        $error1 = new DummyReason();\n\n        $multiError = new MultipleErrors();\n        $multiError->addReason($error1);\n\n        $this->assertEquals($error1, $multiError->reason());\n    }\n\n    public function testRetrieveFirstReasonWithReasonCodeDistinctToZero(): void\n    {\n        $error1 = new AnotherDummyReason();\n\n        $multiError = new MultipleErrors();\n        $multiError->addReason($error1);\n\n        $this->assertEquals($error1, $multiError->reason());\n    }\n\n    public function testRetrieveFirstReasonWithNoReasonAdded()\n    {\n        $emptyReason = new EmptyReason();\n        $multiError = new MultipleErrors();\n        $this->assertEquals($emptyReason, $multiError->reason());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Result/ResultTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Result;\n\nuse PHPUnit\\Framework\\TestCase;\nuse Egulias\\EmailValidator\\Result\\ValidEmail;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\CharNotAllowed;\n\nclass ResultTest extends TestCase\n{\n    public function testResultIsValidEmail()\n    {\n        $result = new ValidEmail();\n        $expectedCode = 0;\n        $expectedDescription = \"Valid email\";\n\n        $this->assertTrue($result->isValid());\n        $this->assertEquals($expectedCode, $result->code());\n        $this->assertEquals($expectedDescription, $result->description());\n    }\n\n    public function testResultIsInvalidEmail()\n    {\n        $reason = new CharNotAllowed();\n        $token = \"T\";\n        $result = new InvalidEmail($reason, $token);\n        $expectedCode = $reason->code();\n        $expectedDescription = $reason->description() . \" in char \" . $token;\n\n        $this->assertFalse($result->isValid());\n        $this->assertEquals($expectedCode, $result->code());\n        $this->assertEquals($expectedDescription, $result->description());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/DNSCheckValidationTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\Reason\\DomainAcceptsNoMail;\nuse Egulias\\EmailValidator\\Result\\Reason\\LocalOrReservedDomain;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoDNSRecord;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnableToGetDNSRecord;\nuse Egulias\\EmailValidator\\Validation\\DNSCheckValidation;\nuse Egulias\\EmailValidator\\Validation\\DNSGetRecordWrapper;\nuse Egulias\\EmailValidator\\Validation\\DNSRecords;\nuse Egulias\\EmailValidator\\Warning\\NoDNSMXRecord;\nuse PHPUnit\\Framework\\TestCase;\n\nclass DNSCheckValidationTest extends TestCase\n{\n    public static function validEmailsProvider()\n    {\n        return [\n            // dot-atom\n            ['Abc@ietf.org'],\n            ['Abc@fake.ietf.org'],\n            ['ABC@ietf.org'],\n            ['Abc.123@ietf.org'],\n            ['user+mailbox/department=shipping@ietf.org'],\n            ['!#$%&\\'*+-/=?^_`.{|}~@ietf.org'],\n\n            // quoted string\n            ['\"Abc@def\"@ietf.org'],\n            ['\"Fred\\ Bloggs\"@ietf.org'],\n            ['\"Joe.\\\\Blow\"@ietf.org'],\n\n            // unicode\n            ['info@ñandu.cl'],\n            ['ñandu@ñandu.cl'],\n        ];\n    }\n\n    public static function localOrReservedEmailsProvider()\n    {\n        return [\n            // Reserved Top Level DNS Names\n            ['test'],\n            ['example'],\n            ['invalid'],\n            ['localhost'],\n\n            // mDNS\n            ['local'],\n\n            // Private DNS Namespaces\n            ['intranet'],\n            ['internal'],\n            ['private'],\n            ['corp'],\n            ['home'],\n            ['lan'],\n        ];\n    }\n\n    /**\n     * @dataProvider validEmailsProvider\n     */\n    public function testValidDNS($validEmail)\n    {\n        $validation = new DNSCheckValidation();\n        $this->assertTrue($validation->isValid($validEmail, new EmailLexer()));\n    }\n\n    public function testInvalidDNS()\n    {\n        $validation = new DNSCheckValidation();\n        $this->assertFalse($validation->isValid(\"example@invalid.example.com\", new EmailLexer()));\n    }\n\n    /**\n     * @dataProvider localOrReservedEmailsProvider\n     */\n    public function testLocalOrReservedDomainError($localOrReservedEmails)\n    {\n        $validation = new DNSCheckValidation();\n        $expectedError = new InvalidEmail(new LocalOrReservedDomain(), $localOrReservedEmails);\n        $validation->isValid($localOrReservedEmails, new EmailLexer());\n        $this->assertEquals($expectedError, $validation->getError());\n    }\n\n    public function testDomainAcceptsNoMailError()\n    {\n        $validation = new DNSCheckValidation();\n        $expectedError = new InvalidEmail(new DomainAcceptsNoMail(), \"\");\n        $isValidResult = $validation->isValid(\"nullmx@example.com\", new EmailLexer());\n        $this->assertEquals($expectedError, $validation->getError());\n        $this->assertFalse($isValidResult);\n    }\n\n    public function testDNSWarnings()\n    {\n        $this->markTestSkipped('Need to found a domain with AAAA records and no MX that fails later in the validations');\n        $validation = new DNSCheckValidation();\n        $expectedWarnings = [NoDNSMXRecord::CODE => new NoDNSMXRecord()];\n        $validation->isValid(\"example@invalid.example.com\", new EmailLexer());\n        $this->assertEquals($expectedWarnings, $validation->getWarnings());\n    }\n\n    public function testNoDNSError()\n    {\n        $validation = new DNSCheckValidation();\n        $expectedError = new InvalidEmail(new NoDNSRecord(), '');\n        $validation->isValid(\"example@invalid.example.com\", new EmailLexer());\n        $this->assertEquals($expectedError, $validation->getError());\n    }\n\n    /**\n     * @group flaky\n     */\n    public function testUnableToGetDNSRecord()\n    {\n        error_reporting(\\E_ALL);\n\n        // UnableToGetDNSRecord raises on network errors (e.g. timeout) that we can‘t emulate in tests (for sure),\n        // but we can simulate with the wrapper helper\n\n        $wrapper = new class extends DNSGetRecordWrapper {\n            public function getRecords(string $host, int $type) : DNSRecords\n            {\n                return new DNSRecords([], true);\n            }\n        };\n\n        $validation = new DNSCheckValidation($wrapper);\n        $expectedError = new InvalidEmail(new UnableToGetDNSRecord(), '');\n\n        $validation->isValid('example@invalid.example.com', new EmailLexer());\n        $this->assertEquals($expectedError, $validation->getError());\n    }\n\n    public function testMissingTypeKey()\n    {\n        $wrapper = new class extends DNSGetRecordWrapper {\n            public function getRecords(string $host, int $type): DNSRecords\n            {\n                return new DNSRecords(['host' => 'test']);\n            }\n        };\n\n        $validation = new DNSCheckValidation($wrapper);\n        $expectedError = new InvalidEmail(new NoDNSRecord(), '');\n\n        $validation->isValid('example@invalid.example.com', new EmailLexer());\n        $this->assertEquals($expectedError, $validation->getError());\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/Extra/SpoofCheckValidationTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation\\Extra;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Validation\\Extra\\SpoofCheckValidation;\nuse PHPUnit\\Framework\\TestCase;\n\nclass SpoofCheckValidationTest extends TestCase\n{\n    /**\n     * @dataProvider validUTF8EmailsProvider\n     */\n    public function testUTF8EmailAreValid($email)\n    {\n        $validation = new SpoofCheckValidation();\n\n        $this->assertTrue($validation->isValid($email, new EmailLexer()));\n    }\n\n    public function testEmailWithSpoofsIsInvalid()\n    {\n        $validation = new SpoofCheckValidation();\n\n        $this->assertFalse($validation->isValid(\"Кириллица\".\"latin漢字\".\"ひらがな\".\"カタカナ\", new EmailLexer()));\n    }\n\n    public static function validUTF8EmailsProvider()\n    {\n        return [\n            // Cyrillic\n            ['Кириллица@Кириллица'],\n            // Latin + Han + Hiragana + Katakana\n            [\"latin漢字\".\"ひらがな\".\"カタカナ\".\"@example.com\"],\n            // Latin + Han + Hangul\n            [\"latin\".\"漢字\".\"조선말\".\"@example.com\"],\n            // Latin + Han + Bopomofo\n            [\"latin\".\"漢字\".\"ㄅㄆㄇㄈ\".\"@example.com\"]\n        ];\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/IsEmailFunctionTests.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailValidator;\nuse Egulias\\EmailValidator\\Validation\\DNSCheckValidation;\nuse Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd;\nuse Egulias\\EmailValidator\\Validation\\NoRFCWarningsValidation;\nuse PHPUnit\\Framework\\TestCase;\n\nclass IsEmailFunctionTests extends TestCase\n{\n    /**\n     * @dataProvider isEmailTestSuite\n     */\n    public function testAgainstIsEmailTestSuite($email)\n    {\n        $validator = new EmailValidator();\n        $validations = new MultipleValidationWithAnd([\n            new NoRFCWarningsValidation(),\n            new DNSCheckValidation()\n        ]);\n\n        $this->assertFalse($validator->isValid($email, $validations), \"Tested email \" . $email);\n\n    }\n\n    public function isEmailTestSuite()\n    {\n        $testSuite = __DIR__ . '/../../resources/is_email_tests.xml';\n        $document = new \\DOMDocument();\n        $document->load($testSuite);\n        $elements = $document->getElementsByTagName('test');\n        $tests = [];\n\n        foreach($elements as $testElement) {\n            $childNode = $testElement->childNodes;\n            $tests[][] = ($childNode->item(1)->getAttribute('value'));\n        }\n\n        return $tests;\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/MessageIDValidationTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Validation\\MessageIDValidation;\nuse PHPUnit\\Framework\\TestCase;\n\nclass MessageIDValidationTest extends TestCase\n{\n\n    /**\n     * @dataProvider validMessageIDs\n     */\n    public function testValidMessageIDs(string $messageID)\n    {\n        $validator = new MessageIDValidation();\n\n        $this->assertTrue($validator->isValid($messageID, new EmailLexer()));\n    }\n\n    public static function validMessageIDs() : array\n    {\n        return [\n            ['a@b.c+&%$.d'],\n            ['a.b+&%$.c@d'],\n            ['a@ä'],\n        ];\n    }\n\n    /**\n     * @dataProvider invalidMessageIDs\n     */\n    public function testInvalidMessageIDs(string $messageID)\n    {\n        $validator = new MessageIDValidation();\n\n        $this->assertFalse($validator->isValid($messageID, new EmailLexer()));\n    }\n\n    public static function invalidMessageIDs() : array\n    {\n        return [\n            ['example'],\n            ['example@with space'],\n            ['example@iana.'],\n            ['example@ia\\na.'],\n            /**\n             * RFC 2822, section 3.6.4, Page 25\n             * Since the msg-id has\n             * a similar syntax to angle-addr (identical except that comments and\n             * folding white space are not allowed), a good method is to put the\n             * domain name (or a domain literal IP address) of the host on which the\n             * message identifier was created on the right hand side of the \"@\", and\n             * put a combination of the current absolute date and time along with\n             * some other currently unique (perhaps sequential) identifier available\n             * on the system (for example, a process id number) on the left hand\n             * side.\n             */\n            ['example(comment)@example.com'],\n            [\"\\r\\nFWS@example.com\"]\n        ];\n    }\n\n    public function testInvalidMessageIDsWithError()\n    {\n        $this->markTestIncomplete(\"missing error check\");\n\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/MultipleValidationWithAndTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse PHPUnit\\Framework\\TestCase;\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Result\\MultipleErrors;\nuse Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy\\AnotherDummyReason;\nuse Egulias\\EmailValidator\\Warning\\DomainLiteral;\nuse Egulias\\EmailValidator\\Warning\\AddressLiteral;\nuse Egulias\\EmailValidator\\Validation\\RFCValidation;\nuse Egulias\\EmailValidator\\Validation\\EmailValidation;\nuse Egulias\\EmailValidator\\Validation\\MultipleValidationWithAnd;\nuse Egulias\\EmailValidator\\Tests\\EmailValidator\\Dummy\\DummyReason;\nuse Egulias\\EmailValidator\\Validation\\Exception\\EmptyValidationList;\n\nclass MultipleValidationWithAndTest extends TestCase\n{\n    public function testUsesAndLogicalOperation()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $lexer = new EmailLexer();\n        $validationTrue = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validationTrue->expects($this->any())->method(\"isValid\")->willReturn(true);\n        $validationTrue->expects($this->any())->method(\"getWarnings\")->willReturn([]);\n\n        $validationFalse = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validationFalse->expects($this->any())->method(\"isValid\")->willReturn(false);\n        $validationFalse->expects($this->any())->method(\"getWarnings\")->willReturn([]);\n        $validationFalse->expects($this->any())->method(\"getError\")->willReturn($invalidEmail);\n\n        $multipleValidation = new MultipleValidationWithAnd([$validationTrue, $validationFalse]);\n\n        $this->assertFalse($multipleValidation->isValid(\"exmpale@example.com\", $lexer));\n    }\n\n    public function testEmptyListIsNotAllowed()\n    {\n        $this->expectException(EmptyValidationList::class);\n        new MultipleValidationWithAnd([]);\n    }\n\n    public function testValidationIsValid()\n    {\n        $lexer = new EmailLexer();\n\n        $validation = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation->expects($this->any())->method(\"isValid\")->willReturn(true);\n        $validation->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation->expects($this->any())->method(\"getError\")->willReturn(null);\n\n        $multipleValidation = new MultipleValidationWithAnd([$validation]);\n        $this->assertTrue($multipleValidation->isValid(\"example@example.com\", $lexer));\n        $this->assertNull($multipleValidation->getError());\n    }\n\n    public function testAccumulatesWarnings()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $warnings1 = [\n            AddressLiteral::CODE => new AddressLiteral()\n        ];\n        $warnings2 = [\n            DomainLiteral::CODE => new DomainLiteral()\n        ];\n        $expectedResult = array_merge($warnings1, $warnings2);\n\n        $lexer = new EmailLexer();\n        $validation1 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation1->expects($this->any())->method(\"isValid\")->willReturn(true);\n        $validation1->expects($this->once())->method(\"getWarnings\")->willReturn($warnings1);\n        $validation1->expects($this->any())->method(\"getError\")->willReturn($invalidEmail);\n\n        $validation2 = $this->getMockBuilder(EmailValidation::class)->getMock();\n\n        $validation2->expects($this->any())->method(\"isValid\")->willReturn(false);\n        $validation2->expects($this->once())->method(\"getWarnings\")->willReturn($warnings2);\n        $validation2->expects($this->any())->method(\"getError\")->willReturn($invalidEmail);\n\n        $multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2]);\n        $multipleValidation->isValid(\"example@example.com\", $lexer);\n        $this->assertEquals($expectedResult, $multipleValidation->getWarnings());\n    }\n\n    public function testGathersAllTheErrors()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $invalidEmail2 = new InvalidEmail(new AnotherDummyReason(), '');\n\n        $error1 = new DummyReason();\n        $error2 = new AnotherDummyReason();\n\n        $expectedResult = new MultipleErrors();\n        $expectedResult->addReason($error1);\n        $expectedResult->addReason($error2);\n\n        $lexer = new EmailLexer();\n\n        $validation1 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation1->expects($this->once())->method(\"isValid\")->willReturn(false);\n        $validation1->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation1->expects($this->exactly(2))->method(\"getError\")->willReturn($invalidEmail);\n\n        $validation2 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation2->expects($this->once())->method(\"isValid\")->willReturn(false);\n        $validation2->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation2->expects($this->exactly(2))->method(\"getError\")->willReturn($invalidEmail2);\n\n        $multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2]);\n        $multipleValidation->isValid(\"example@example.com\", $lexer);\n        $this->assertEquals($expectedResult, $multipleValidation->getError());\n    }\n\n    public function testStopsAfterFirstError()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $invalidEmail2 = new InvalidEmail(new AnotherDummyReason(), '');\n\n        $error1 = new DummyReason();\n\n        $expectedResult = new MultipleErrors();\n        $expectedResult->addReason($error1);\n\n        $lexer = new EmailLexer();\n\n        $validation1 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation1->expects($this->any())->method(\"isValid\")->willReturn(false);\n        $validation1->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation1->expects($this->exactly(2))->method(\"getError\")->willReturn($invalidEmail);\n\n        $validation2 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation2->expects($this->any())->method(\"isValid\")->willReturn(false);\n        $validation2->expects($this->never())->method(\"getWarnings\")->willReturn([]);\n        $validation1->expects($this->exactly(2))->method(\"getError\")->willReturn($invalidEmail2);\n\n        $multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2], MultipleValidationWithAnd::STOP_ON_ERROR);\n        $multipleValidation->isValid(\"example@example.com\", $lexer);\n        $this->assertEquals($expectedResult, $multipleValidation->getError());\n    }\n\n    public function testBreakOutOfLoopWhenError()\n    {\n        $invalidEmail = new InvalidEmail(new DummyReason(), '');\n        $error1 = new DummyReason();\n\n        $expectedResult = new MultipleErrors();\n        $expectedResult->addReason($error1);\n\n        $lexer = new EmailLexer();\n\n        $validation1 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation1->expects($this->any())->method(\"isValid\")->willReturn(false);\n        $validation1->expects($this->once())->method(\"getWarnings\")->willReturn([]);\n        $validation1->expects($this->exactly(2))->method(\"getError\")->willReturn($invalidEmail);\n\n        $validation2 = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validation2->expects($this->never())->method(\"isValid\");\n        $validation2->expects($this->never())->method(\"getWarnings\");\n        $validation2->expects($this->never())->method(\"getError\");\n\n        $multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2], MultipleValidationWithAnd::STOP_ON_ERROR);\n        $multipleValidation->isValid(\"example@example.com\", $lexer);\n        $this->assertEquals($expectedResult, $multipleValidation->getError());\n    }\n\n    public function testBreakoutOnInvalidEmail()\n    {\n        $lexer = new EmailLexer();\n\n        $validationNotCalled = $this->getMockBuilder(EmailValidation::class)->getMock();\n        $validationNotCalled->expects($this->never())->method(\"isValid\");\n        $validationNotCalled->expects($this->never())->method(\"getWarnings\");\n        $validationNotCalled->expects($this->never())->method(\"getError\");\n        $multipleValidation = new MultipleValidationWithAnd([new RFCValidation(), $validationNotCalled], MultipleValidationWithAnd::STOP_ON_ERROR);\n        $this->assertFalse($multipleValidation->isValid(\"invalid-email\", $lexer));\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoDomainPart;\nuse Egulias\\EmailValidator\\Result\\Reason\\RFCWarnings;\nuse Egulias\\EmailValidator\\Validation\\NoRFCWarningsValidation;\nuse PHPUnit\\Framework\\TestCase;\n\nclass NoRFCWarningsValidationTest extends TestCase\n{\n    public function testInvalidEmailIsInvalid()\n    {\n        $validation = new NoRFCWarningsValidation();\n\n        $this->assertFalse($validation->isValid('non-email-string', new EmailLexer()));\n        $this->assertInstanceOf(NoDomainPart::class, $validation->getError()->reason());\n    }\n\n    public function testEmailWithWarningsIsInvalid()\n    {\n        $validation = new NoRFCWarningsValidation();\n\n        $this->assertFalse($validation->isValid('test()@example.com', new EmailLexer()));\n        $this->assertInstanceOf(RFCWarnings::class, $validation->getError()->reason());\n    }\n\n    /**\n     * @dataProvider getValidEmailsWithoutWarnings\n     */\n    public function testEmailWithoutWarningsIsValid($email)\n    {\n        $validation = new NoRFCWarningsValidation();\n\n        $this->assertTrue($validation->isValid('example@example.com', new EmailLexer()));\n        $this->assertTrue($validation->isValid($email, new EmailLexer()));\n        $this->assertNull($validation->getError());\n    }\n\n    public static function getValidEmailsWithoutWarnings()\n    {\n        return [\n            ['example@example.com',],\n            [sprintf('example@%s.com', str_repeat('ъ', 40)),],\n        ];\n    }\n}\n"
  },
  {
    "path": "tests/EmailValidator/Validation/RFCValidationDomainPartTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse PHPUnit\\Framework\\TestCase;\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Warning\\TLD;\nuse Egulias\\EmailValidator\\Warning\\Comment;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\IPV6BadChar;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRNoLF;\nuse Egulias\\EmailValidator\\Warning\\IPV6ColonEnd;\nuse Egulias\\EmailValidator\\Warning\\DomainLiteral;\nuse Egulias\\EmailValidator\\Warning\\IPV6MaxGroups;\nuse Egulias\\EmailValidator\\Warning\\ObsoleteDTEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtEnd;\nuse Egulias\\EmailValidator\\Warning\\AddressLiteral;\nuse Egulias\\EmailValidator\\Warning\\IPV6ColonStart;\nuse Egulias\\EmailValidator\\Warning\\IPV6Deprecated;\nuse Egulias\\EmailValidator\\Warning\\IPV6GroupCount;\nuse Egulias\\EmailValidator\\Warning\\IPV6DoubleColon;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtStart;\nuse Egulias\\EmailValidator\\Validation\\RFCValidation;\nuse Egulias\\EmailValidator\\Result\\Reason\\LabelTooLong;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoDomainPart;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveAt;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveDot;\nuse Egulias\\EmailValidator\\Result\\Reason\\DomainHyphened;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingDTEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnOpenedComment;\n\n\nclass RFCValidationDomainPartTest extends TestCase\n{\n    /**\n     * @var RFCValidation\n     */\n    protected $validator;\n\n    /**\n     * @var EmailLexer\n     */\n    protected $lexer;\n\n    protected function setUp() : void\n    {\n        $this->validator = new RFCValidation();\n        $this->lexer = new EmailLexer();\n    }\n\n    protected function tearDown() : void\n    {\n        $this->validator = null;\n    }\n\n    /**\n     * @dataProvider getValidEmails\n     */\n    public function testValidEmails($email)\n    {\n        $this->assertTrue($this->validator->isValid($email, $this->lexer));\n    }\n\n    public static function getValidEmails()\n    {\n        return array(\n            ['fabien@symfony.com'],\n            ['example@example.co.uk'],\n            ['example@localhost'],\n            ['example@faked(fake).co.uk'],\n            ['инфо@письмо.рф'],\n            ['müller@möller.de'],\n            [\"1500111@профи-инвест.рф\"],\n            ['validipv6@[IPv6:2001:db8:1ff::a0b:dbd0]'],\n            ['validipv4@[127.0.0.0]'],\n            ['validipv4@127.0.0.0'],\n            ['withhyphen@domain-exam.com'],\n            ['valid_long_domain@71846jnrsoj91yfhc18rkbrf90ue3onl8y46js38kae8inz0t1.5a-xdycuau.na49.le.example.com']\n        );\n    }\n\n    /**\n     * @dataProvider getInvalidEmails\n     */\n    public function testInvalidEmails($email)\n    {\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n    }\n\n    public static function getInvalidEmails()\n    {\n        return [\n            ['test@example.com test'],\n            ['example@example@example.co.uk'],\n            ['test_exampel@example.fr]'],\n            ['example@local\\host'],\n            ['example@localhost\\\\'],\n            ['example@localhost.'],\n            ['username@ example . com'],\n            ['username@ example.com'],\n            ['example@(fake].com'],\n            ['example@(fake.com'],\n            ['username@example,com'],\n            ['test@' . chr(226) . '.org'],\n            ['test@iana.org \\r\\n'],\n            ['test@iana.org \\r\\n '],\n            ['test@iana.org \\r\\n \\r\\n'],\n            ['test@iana.org \\r\\n\\r\\n'],\n            ['test@iana.org  \\r\\n\\r\\n '],\n            ['test@iana/icann.org'],\n            ['test@foo;bar.com'],\n            ['test@example..com'],\n            [\"test@examp'le.com\"],\n            ['email.email@email.\"'],\n            ['test@email>'],\n            ['test@email<'],\n            ['test@email{'],\n            ['username@examp,le.com'],\n            ['test@ '],\n            ['invalidipv4@[127.\\0.0.0]'],\n            ['test@example.com []'],\n            ['test@example.com. []'],\n            ['test@test. example.com'],\n            ['example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.\n            'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.\n            'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'],\n            ['example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'],\n            ['example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.test.co.uk'],\n            ['example@test.toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'],\n            ['test@email*a.com'],\n            ['test@email!a.com'],\n            ['test@email&a.com'],\n            ['test@email^a.com'],\n            ['test@email%a.com'],\n            ['test@email$a.com'],\n            ['test@email`a.com'],\n            ['test@email|a.com'],\n            ['test@email~a.com'],\n            ['test@email{a.com'],\n            ['test@email}a.com'],\n            ['test@email=a.com'],\n            ['test@email+a.com'],\n            ['test@email_a.com'],\n            ['test@email¡a.com'],\n            ['test@email?a.com'],\n            ['test@email#a.com'],\n            ['test@email¨a.com'],\n            ['test@email€a.com'],\n            ['test@email$a.com'],\n            ['test@email£a.com'],\n        ];\n    }\n\n    /**\n     * @dataProvider getInvalidEmailsWithErrors\n     */\n    public function testInvalidEmailsWithErrorsCheck($error, $email)\n    {\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n        $this->assertEquals($error, $this->validator->getError());\n    }\n\n    public static function getInvalidEmailsWithErrors()\n    {\n        return [\n            [new InvalidEmail(new NoDomainPart(), ''), 'example@'],\n            [new InvalidEmail(new DomainHyphened('Hypen found near DOT'), '-'), 'example@example-.co.uk'], [new InvalidEmail(new CRNoLF(), \"\\r\"), \"example@example\\r.com\"],\n            [new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), '-'), 'example@example-'],\n            [new InvalidEmail(new ConsecutiveAt(), '@'), 'example@@example.co.uk'],\n            [new InvalidEmail(new ConsecutiveDot(), '.'), 'example@example..co.uk'],\n            [new InvalidEmail(new DotAtStart(), '.'), 'example@.localhost'],\n            [new InvalidEmail(new DomainHyphened('After AT'), '-'), 'example@-localhost'],\n            [new InvalidEmail(new DotAtEnd(), ''), 'example@localhost.'],\n            [new InvalidEmail(new UnOpenedComment(), ')'), 'example@comment)localhost'],\n            [new InvalidEmail(new UnOpenedComment(), ')'), 'example@localhost(comment))'],\n            [new InvalidEmail(new UnOpenedComment(), 'com'), 'example@(comment))example.com'],\n            [new InvalidEmail(new ExpectingDTEXT(), '['), \"example@[[]\"],\n            [new InvalidEmail(new CRNoLF(), \"\\r\"), \"example@exa\\rmple.co.uk\"],\n            [new InvalidEmail(new CRNoLF(), \"[\"), \"example@[\\r]\"],\n            [new InvalidEmail(new ExpectingATEXT('Invalid token in domain: ,'), ','), 'example@exam,ple.com'],\n            [new InvalidEmail(new ExpectingATEXT(\"Invalid token in domain: '\"), \"'\"), \"test@example.com'\"],\n            [new InvalidEmail(new LabelTooLong(), \".\"), sprintf('example@%s.com', str_repeat('ъ', 64))],\n            [new InvalidEmail(new LabelTooLong(), \".\"), sprintf('example@%s.com', str_repeat('a4t', 22))],\n            [new InvalidEmail(new LabelTooLong(), \"\"), sprintf('example@%s', str_repeat('a4t', 22))],\n        ];\n    }\n\n    /**\n     * @dataProvider getValidEmailsWithWarnings\n     */\n    public function testValidEmailsWithWarningsCheck($expectedWarnings, $email)\n    {\n        $this->assertTrue($this->validator->isValid($email, $this->lexer));\n        $warnings = $this->validator->getWarnings();\n        $this->assertCount(\n            count($expectedWarnings), $warnings,\n            \"Expected: \" . implode(\",\", $expectedWarnings) . \" and got: \" . PHP_EOL . implode(PHP_EOL, $warnings)\n        );\n\n        foreach ($warnings as $warning) {\n            $this->assertArrayHasKey($warning->code(), $expectedWarnings);\n        }\n    }\n\n    public static function getValidEmailsWithWarnings()\n    {\n        return [\n            //Check if this is actually possible\n            //[[CFWSNearAt::CODE], 'example@ invalid.example.com'],\n            [[Comment::CODE], 'example@invalid.example(examplecomment).com'],\n            [[AddressLiteral::CODE, TLD::CODE], 'example@[127.0.0.1]'],\n            [[AddressLiteral::CODE, TLD::CODE], 'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'],\n            [[AddressLiteral::CODE, IPV6Deprecated::CODE, TLD::CODE], 'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370::]'],\n            [[AddressLiteral::CODE, IPV6MaxGroups::CODE, TLD::CODE], 'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334::]'],\n            [[AddressLiteral::CODE, IPV6DoubleColon::CODE, TLD::CODE], 'example@[IPv6:1::1::1]'],\n            [[ObsoleteDTEXT::CODE, DomainLiteral::CODE, TLD::CODE], \"example@[\\n]\"],\n            [[DomainLiteral::CODE, TLD::CODE], 'example@[::1]'],\n            [[DomainLiteral::CODE, TLD::CODE], 'example@[::123.45.67.178]'],\n            [\n                [IPV6ColonStart::CODE, AddressLiteral::CODE, IPV6GroupCount::CODE, TLD::CODE],\n                'example@[IPv6::2001:0db8:85a3:0000:0000:8a2e:0370:7334]'\n            ],\n            [\n                [AddressLiteral::CODE, IPV6BadChar::CODE, TLD::CODE],\n                'example@[IPv6:z001:0db8:85a3:0000:0000:8a2e:0370:7334]'\n            ],\n            [\n                [AddressLiteral::CODE, IPV6ColonEnd::CODE, TLD::CODE],\n                'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:]'\n            ],\n        ];\n    }\n\n    public static function invalidUTF16Chars()\n    {\n        return [\n            ['example@symƒony.com'],\n        ];\n    }\n    \n    /**\n     * @dataProvider invalidUTF16Chars\n     */\n    public function testInvalidUTF16($email)\n    {\n        $this->markTestSkipped('Util finding a way to control this kind of chars');\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n    }\n\n}"
  },
  {
    "path": "tests/EmailValidator/Validation/RFCValidationTest.php",
    "content": "<?php\n\nnamespace Egulias\\EmailValidator\\Tests\\EmailValidator\\Validation;\n\nuse PHPUnit\\Framework\\TestCase;\nuse Egulias\\EmailValidator\\EmailLexer;\nuse Egulias\\EmailValidator\\Warning\\Comment;\nuse Egulias\\EmailValidator\\Warning\\CFWSNearAt;\nuse Egulias\\EmailValidator\\Result\\InvalidEmail;\nuse Egulias\\EmailValidator\\Warning\\CFWSWithFWS;\nuse Egulias\\EmailValidator\\Warning\\LocalTooLong;\nuse Egulias\\EmailValidator\\Warning\\QuotedString;\nuse Egulias\\EmailValidator\\Validation\\RFCValidation;\nuse Egulias\\EmailValidator\\Result\\Reason\\NoLocalPart;\nuse Egulias\\EmailValidator\\Result\\Reason\\AtextAfterCFWS;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnOpenedComment;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnclosedQuotedString;\nuse Egulias\\EmailValidator\\Result\\Reason\\CRNoLF;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtEnd;\nuse Egulias\\EmailValidator\\Result\\Reason\\DotAtStart;\nuse Egulias\\EmailValidator\\Result\\Reason\\ConsecutiveDot;\nuse Egulias\\EmailValidator\\Result\\Reason\\ExpectingATEXT;\nuse Egulias\\EmailValidator\\Result\\Reason\\UnclosedComment;\nuse Egulias\\EmailValidator\\Warning\\TLD;\n\nclass RFCValidationTest extends TestCase\n{\n    /**\n     * @var RFCValidation\n     */\n    protected $validator;\n\n    /**\n     * @var EmailLexer\n     */\n    protected $lexer;\n\n    protected function setUp() : void\n    {\n        $this->validator = new RFCValidation();\n        $this->lexer = new EmailLexer();\n    }\n\n    protected function tearDown() : void\n    {\n        $this->validator = null;\n    }\n\n    /**\n     * @dataProvider getValidEmails\n     */\n    public function testValidEmails($email)\n    {\n        $this->assertTrue($this->validator->isValid($email, $this->lexer));\n    }\n\n    public static function getValidEmails()\n    {\n        return array(\n            ['â@iana.org'],\n            ['fabien@symfony.com'],\n            ['example@example.co.uk'],\n            ['fabien_potencier@example.fr'],\n            ['fab\\'ien@symfony.com'],\n            ['fab\\ ien@symfony.com'],\n            ['example((example))@fakedfake.co.uk'],\n            ['fabien+a@symfony.com'],\n            ['exampl=e@example.com'],\n            ['инфо@письмо.рф'],\n            ['\"username\"@example.com'],\n            ['\"user,name\"@example.com'],\n            ['\"user name\"@example.com'],\n            ['\"user@name\"@example.com'],\n            ['\"user\\\"name\"@example.com'],\n            ['\"\\a\"@iana.org'],\n            ['\"test\\ test\"@iana.org'],\n            ['\"\"@iana.org'],\n            ['\"\\\"\"@iana.org'],\n            ['müller@möller.de'],\n            [\"1500111@профи-инвест.рф\"],\n            [sprintf('example@%s.com', str_repeat('ъ', 40))],\n        );\n    }\n\n    /**\n     * @dataProvider getValidEmailsWithWarnings\n     */\n    public function testValidEmailsWithWarningsCheck($email, $expectedWarnings)\n    {\n        $this->assertTrue($this->validator->isValid($email, $this->lexer));\n        $this->assertEquals($expectedWarnings, $this->validator->getWarnings());\n    }\n\n    public static function getValidEmailsWithWarnings()\n    {\n        return [\n            ['a5aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@example.com', [new LocalTooLong()]],\n            ['example@example', [new TLD()]],\n            ['example @invalid.example.com', [new CFWSNearAt()]],\n            ['example(examplecomment)@invalid.example.com',[new Comment(), new CFWSNearAt()]],\n            [\"\\\"\\t\\\"@invalid.example.com\", [new QuotedString(\"\", '\"'), new CFWSWithFWS(),]],\n            [\"\\\"\\r\\\"@invalid.example.com\", [new QuotedString('', '\"'), new CFWSWithFWS(),]],\n            ['\"example\"@invalid.example.com', [new QuotedString('', '\"')]],\n            ['too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@invalid.example.com',\n                [new LocalTooLong()]],\n        ];\n    }\n\n    public function testInvalidUTF8Email()\n    {\n        $email = \"\\x80\\x81\\x82@\\x83\\x84\\x85.\\x86\\x87\\x88\";\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n    }\n\n    /**\n     * @dataProvider getInvalidEmails\n     */\n    public function testInvalidEmails($email)\n    {\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n    }\n\n    public static function getInvalidEmails()\n    {\n        return [\n            ['user  name@example.com'],\n            ['user   name@example.com'],\n            ['example.@example.co.uk'],\n            ['example@example@example.co.uk'],\n            ['(test_exampel@example.fr'],\n            ['example(example]example@example.co.uk'],\n            ['.example@localhost'],\n            ['ex\\ample@localhost'],\n            ['user name@example.com'],\n            ['usern,ame@example.com'],\n            ['user[na]me@example.com'],\n            ['\"\"\"@iana.org'],\n            ['\"\\\"@iana.org'],\n            ['\"test\"test@iana.org'],\n            ['\"test\"\"test\"@iana.org'],\n            ['\"test\".\"test\"@iana.org'],\n            ['\"test\".test@iana.org'],\n            ['\"test\"' . chr(0) . '@iana.org'],\n            ['\"test\\\"@iana.org'],\n            [chr(226) . '@iana.org'],\n            ['\\r\\ntest@iana.org'],\n            ['\\r\\n test@iana.org'],\n            ['\\r\\n \\r\\ntest@iana.org'],\n            ['\\r\\n \\r\\ntest@iana.org'],\n            ['\\r\\n \\r\\n test@iana.org'],\n            ['test;123@foobar.com'],\n            ['examp║le@symfony.com'],\n            ['example@invalid-.domain.com'],\n            ['example@-invalid.com'],\n            ['0'],\n            [0],\n        ];\n    }\n\n    /**\n     * @dataProvider getInvalidEmailsWithErrors\n     */\n    public function testInvalidDEmailsWithErrorsCheck($error, $email)\n    {\n        $this->assertFalse($this->validator->isValid($email, $this->lexer));\n        $this->assertEquals($error, $this->validator->getError());\n    }\n\n    public static function getInvalidEmailsWithErrors()\n    {\n        return [\n            [new InvalidEmail(new NoLocalPart(), \"@\"), '@example.co.uk'],\n            [new InvalidEmail(new ConsecutiveDot(), '.'), 'example..example@example.co.uk'],\n            [new InvalidEmail(new ExpectingATEXT('Invalid token found'), '<'), '<example_example>@example.fr'],\n            [new InvalidEmail(new DotAtStart(), '.'), '.example@localhost'],\n            [new InvalidEmail(new DotAtEnd(), '.'), 'example.@example.co.uk'],\n            [new InvalidEmail(new UnclosedComment(), '('), '(example@localhost'],\n            [new InvalidEmail(new UnclosedQuotedString(), '\"'), '\"example@localhost'],\n            [\n                new InvalidEmail(\n                    new ExpectingATEXT('https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit'),\n                    '\"'),\n                'exa\"mple@localhost'\n            ],\n            [new InvalidEmail(new UnOpenedComment(), ')'), 'comment)example@localhost'],\n            [new InvalidEmail(new UnOpenedComment(), ')'), 'example(comment))@localhost'],\n            [new InvalidEmail(new AtextAfterCFWS(), \"\\n\"), \"exampl\\ne@example.co.uk\"],\n            [new InvalidEmail(new AtextAfterCFWS(), \"\\t\"), \"exampl\\te@example.co.uk\"],\n            [new InvalidEmail(new CRNoLF(), \"\\r\"), \"exam\\rple@example.co.uk\"],\n        ];\n    }\n}"
  }
]