PHP_CodeSniffer_File::_createParenthesisNestingMap PHP Method

_createParenthesisNestingMap() private static method

Creates a map for the parenthesis tokens that surround other tokens.
private static _createParenthesisNestingMap ( array &$tokens, object $tokenizer, string $eolChar ) : void
$tokens array The array of tokens to process.
$tokenizer object The tokenizer being used to process this file.
$eolChar string The EOL character to use for splitting strings.
return void
    private static function _createParenthesisNestingMap(&$tokens, $tokenizer, $eolChar)
    {
        $numTokens = count($tokens);
        $map = array();
        for ($i = 0; $i < $numTokens; $i++) {
            if (isset($tokens[$i]['parenthesis_opener']) === true && $i === $tokens[$i]['parenthesis_opener']) {
                if (empty($map) === false) {
                    $tokens[$i]['nested_parenthesis'] = $map;
                }
                if (isset($tokens[$i]['parenthesis_closer']) === true) {
                    $map[$tokens[$i]['parenthesis_opener']] = $tokens[$i]['parenthesis_closer'];
                }
            } else {
                if (isset($tokens[$i]['parenthesis_closer']) === true && $i === $tokens[$i]['parenthesis_closer']) {
                    array_pop($map);
                    if (empty($map) === false) {
                        $tokens[$i]['nested_parenthesis'] = $map;
                    }
                } else {
                    if (empty($map) === false) {
                        $tokens[$i]['nested_parenthesis'] = $map;
                    }
                }
            }
            //end if
        }
        //end for
    }