Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

class Comment

Same name in this branch
  1. 11.1.x vendor/egulias/email-validator/src/Warning/Comment.php \Egulias\EmailValidator\Warning\Comment
  2. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Comment.php \PhpParser\Comment
  3. 11.1.x vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Comment.php \SlevomatCodingStandard\Helpers\Comment
  4. 11.1.x vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php \PHP_CodeSniffer\Tokenizers\Comment
  5. 11.1.x vendor/mck89/peast/lib/Peast/Syntax/Node/Comment.php \Peast\Syntax\Node\Comment
  6. 11.1.x core/modules/comment/src/Plugin/migrate/source/d6/Comment.php \Drupal\comment\Plugin\migrate\source\d6\Comment
  7. 11.1.x core/modules/comment/src/Plugin/migrate/source/d7/Comment.php \Drupal\comment\Plugin\migrate\source\d7\Comment
  8. 11.1.x core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment
  9. 11.1.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment

Hierarchy

  • class \Egulias\EmailValidator\Parser\PartParser
    • class \Egulias\EmailValidator\Parser\Comment extends \Egulias\EmailValidator\Parser\PartParser

Expanded class hierarchy of Comment

115 string references to 'Comment'
AuthorNameFormatter::isApplicable in core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php
Returns if the formatter can be used for the provided field.
comment.info.yml in core/modules/comment/comment.info.yml
core/modules/comment/comment.info.yml
comment.migrate_drupal.yml in core/modules/comment/migrations/state/comment.migrate_drupal.yml
core/modules/comment/migrations/state/comment.migrate_drupal.yml
comment.routing.yml in core/modules/comment/comment.routing.yml
core/modules/comment/comment.routing.yml
comment.type.comment.yml in core/profiles/standard/config/install/comment.type.comment.yml
core/profiles/standard/config/install/comment.type.comment.yml

... See full list

File

vendor/egulias/email-validator/src/Parser/Comment.php, line 14

Namespace

Egulias\EmailValidator\Parser
View source
class Comment extends PartParser {
    
    /**
     * @var int
     */
    private $openedParenthesis = 0;
    
    /**
     * @var CommentStrategy
     */
    private $commentStrategy;
    public function __construct(EmailLexer $lexer, CommentStrategy $commentStrategy) {
        $this->lexer = $lexer;
        $this->commentStrategy = $commentStrategy;
    }
    public function parse() : Result {
        if ($this->lexer->current
            ->isA(EmailLexer::S_OPENPARENTHESIS)) {
            $this->openedParenthesis++;
            if ($this->noClosingParenthesis()) {
                return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);
            }
        }
        if ($this->lexer->current
            ->isA(EmailLexer::S_CLOSEPARENTHESIS)) {
            return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value);
        }
        $this->warnings[WarningComment::CODE] = new WarningComment();
        $moreTokens = true;
        while ($this->commentStrategy
            ->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens) {
            if ($this->lexer
                ->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
                $this->openedParenthesis++;
            }
            $this->warnEscaping();
            if ($this->lexer
                ->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
                $this->openedParenthesis--;
            }
            $moreTokens = $this->lexer
                ->moveNext();
        }
        if ($this->openedParenthesis >= 1) {
            return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);
        }
        if ($this->openedParenthesis < 0) {
            return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value);
        }
        $finalValidations = $this->commentStrategy
            ->endOfLoopValidations($this->lexer);
        $this->warnings = [
            $this->warnings,
            $this->commentStrategy
                ->getWarnings(),
        ];
        return $finalValidations;
    }
    
    /**
     * @return void
     */
    private function warnEscaping() : void {
        
        //Backslash found
        if (!$this->lexer->current
            ->isA(EmailLexer::S_BACKSLASH)) {
            return;
        }
        if (!$this->lexer
            ->isNextTokenAny(array(
            EmailLexer::S_SP,
            EmailLexer::S_HTAB,
            EmailLexer::C_DEL,
        ))) {
            return;
        }
        $this->warnings[QuotedPart::CODE] = new QuotedPart($this->lexer
            ->getPrevious()->type, $this->lexer->current->type);
    }
    private function noClosingParenthesis() : bool {
        try {
            $this->lexer
                ->find(EmailLexer::S_CLOSEPARENTHESIS);
            return false;
        } catch (\RuntimeException $e) {
            return true;
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Comment::$commentStrategy private property
Comment::$openedParenthesis private property
Comment::noClosingParenthesis private function
Comment::parse public function Overrides PartParser::parse
Comment::warnEscaping private function
Comment::__construct public function Overrides PartParser::__construct
PartParser::$lexer protected property
PartParser::$warnings protected property
PartParser::checkConsecutiveDots protected function
PartParser::escaped protected function
PartParser::getWarnings public function
PartParser::parseFWS protected function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal