function AbstractPatternSniff::createSkipPattern
Creates a skip pattern.
Parameters
string $pattern The pattern being parsed.:
int $from The token position that the skip pattern starts from.:
Return value
array The pattern step.
See also
createTokenPattern()
parse()
1 call to AbstractPatternSniff::createSkipPattern()
- AbstractPatternSniff::parse in vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractPatternSniff.php - Parses a pattern string into an array of pattern steps.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractPatternSniff.php, line 864
Class
Namespace
PHP_CodeSniffer\SniffsCode
private function createSkipPattern($pattern, $from) {
$skip = [
'type' => 'skip',
];
$nestedParenthesis = 0;
$nestedBraces = 0;
for ($start = $from; $start >= 0; $start--) {
switch ($pattern[$start]) {
case '(':
if ($nestedParenthesis === 0) {
$skip['to'] = 'parenthesis_closer';
}
$nestedParenthesis--;
break;
case '{':
if ($nestedBraces === 0) {
$skip['to'] = 'scope_closer';
}
$nestedBraces--;
break;
case '}':
$nestedBraces++;
break;
case ')':
$nestedParenthesis++;
break;
}
//end switch
if (isset($skip['to']) === true) {
break;
}
}
//end for
if (isset($skip['to']) === false) {
$skip['to'] = 'unknown';
}
return $skip;
}