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
Namespace
PHP_CodeSniffer\TokenizersCode
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
}