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

Breadcrumb

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

function Tokenizer::createParenthesisNestingMap

Creates a map for the parenthesis tokens that surround other tokens.

Return value

void

1 call to Tokenizer::createParenthesisNestingMap()
Tokenizer::__construct in vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php
Initialise and run the tokenizer.

File

vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php, line 854

Class

Tokenizer

Namespace

PHP_CodeSniffer\Tokenizers

Code

private function createParenthesisNestingMap() {
    $map = [];
    for ($i = 0; $i < $this->numTokens; $i++) {
        if (isset($this->tokens[$i]['parenthesis_opener']) === true && $i === $this->tokens[$i]['parenthesis_opener']) {
            if (empty($map) === false) {
                $this->tokens[$i]['nested_parenthesis'] = $map;
            }
            if (isset($this->tokens[$i]['parenthesis_closer']) === true) {
                $map[$this->tokens[$i]['parenthesis_opener']] = $this->tokens[$i]['parenthesis_closer'];
            }
        }
        else {
            if (isset($this->tokens[$i]['parenthesis_closer']) === true && $i === $this->tokens[$i]['parenthesis_closer']) {
                array_pop($map);
                if (empty($map) === false) {
                    $this->tokens[$i]['nested_parenthesis'] = $map;
                }
            }
            else {
                if (empty($map) === false) {
                    $this->tokens[$i]['nested_parenthesis'] = $map;
                }
            }
        }
        
        //end if
    }
    
    //end for
}
RSS feed
Powered by Drupal