Source for file MemberVarScopeSniff.php
Documentation is available at MemberVarScopeSniff.php
* Verifies that class members have scope modifiers.
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Util\Tokens;
class MemberVarScopeSniff extends AbstractVariableSniff
* Processes the function tokens within the class.
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
* @param int $stackPtr The position where the token was found.
protected function processMemberVar (File $phpcsFile, $stackPtr)
$tokens = $phpcsFile->getTokens ();
for ($i = ($stackPtr - 1 ); $i > 0; $i-- ) {
if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
} else if (isset (Tokens ::$scopeModifiers[$tokens[$i]['code']]) === true ) {
if ($modifier === null ) {
$error = 'Scope modifier not specified for member variable "%s"';
$data = array ($tokens[$stackPtr]['content']);
$phpcsFile->addError ($error, $stackPtr, 'Missing', $data);
}//end processMemberVar()
* Processes normal variables.
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
* @param int $stackPtr The position where the token was found.
protected function processVariable (File $phpcsFile, $stackPtr)
We don't care about normal variables.
* Processes variables in double quoted strings.
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
* @param int $stackPtr The position where the token was found.
protected function processVariableInString (File $phpcsFile, $stackPtr)
We don't care about normal variables.
}//end processVariableInString()
Documentation generated on Mon, 11 Mar 2019 15:27:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|