Documentation

AbstractScopeSniff.php

Allows tests that extend this class to listen for tokens within a particular scope.

Below is a test that listens to methods that exist only within classes: class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff { public function __construct() { parent::__construct(array(T_CLASS), array(T_FUNCTION)); }

protected function processTokenWithinScope(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr, $currScope)
{
    $className = $phpcsFile->getDeclarationName($currScope);
    echo 'encountered a method within class '.$className;
}

}

Tags
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

Interfaces, Classes and Traits

AbstractScopeSniff

Search results