function MethodScopeSniff::processTokenWithinScope
Same name in this branch
- 11.1.x vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php \Drupal\Sniffs\Scope\MethodScopeSniff::processTokenWithinScope()
Processes the function tokens within the class.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.:
int $stackPtr The position where the token was found.:
int $currScope The current scope opener token.:
Return value
void
Overrides AbstractScopeSniff::processTokenWithinScope
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ Scope/ MethodScopeSniff.php, line 39
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\ScopeCode
protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) {
$tokens = $phpcsFile->getTokens();
// Determine if this is a function which needs to be examined.
$conditions = $tokens[$stackPtr]['conditions'];
end($conditions);
$deepestScope = key($conditions);
if ($deepestScope !== $currScope) {
return;
}
$methodName = $phpcsFile->getDeclarationName($stackPtr);
if ($methodName === null) {
// Ignore closures.
return;
}
$properties = $phpcsFile->getMethodProperties($stackPtr);
if ($properties['scope_specified'] === false) {
$error = 'Visibility must be declared on method "%s"';
$data = [
$methodName,
];
$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
}
}