mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-30 03:59:20 +00:00
opened parenthesis converted to class field
This commit is contained in:
@@ -111,7 +111,8 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments($openedParenthesis);
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
$this->lexer->moveNext();
|
||||
$tmpPrev = $this->lexer->getPrevious();
|
||||
if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
|
||||
@@ -24,7 +24,8 @@ class LocalPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments($openedParenthesis);
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
|
||||
@@ -9,6 +9,7 @@ abstract class Parser
|
||||
{
|
||||
protected $warnings = array();
|
||||
protected $lexer;
|
||||
protected $openedParenthesis = 0;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
@@ -22,6 +23,12 @@ abstract class Parser
|
||||
|
||||
abstract public function parse($str);
|
||||
|
||||
/** @return int */
|
||||
public function getOpenedParenthesis()
|
||||
{
|
||||
return $this->openedParenthesis;
|
||||
}
|
||||
|
||||
/**
|
||||
* validateQuotedPair
|
||||
*/
|
||||
@@ -35,18 +42,14 @@ abstract class Parser
|
||||
$this->warnings[] = EmailValidator::DEPREC_QP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $openedParenthesis
|
||||
* @return string the comment
|
||||
*/
|
||||
protected function parseComments(&$openedParenthesis = 0)
|
||||
protected function parseComments()
|
||||
{
|
||||
$openedParenthesis++;
|
||||
$this->openedParenthesis = 1;
|
||||
$this->isUnclosedComment();
|
||||
$this->warnings[] = EmailValidator::CFWS_COMMENT;
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
|
||||
$openedParenthesis++;
|
||||
$this->openedParenthesis++;
|
||||
}
|
||||
$this->warnEscaping();
|
||||
$this->lexer->moveNext();
|
||||
@@ -164,7 +167,7 @@ abstract class Parser
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
$previous = $this->lexer->getPrevious();
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||
if ($previous['type'] === EmailLexer::GENERIC && $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user