mirror of
https://github.com/moodle/moodle.git
synced 2025-03-13 04:01:40 +01:00
95 lines
3.0 KiB
PHP
95 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* Represents a PHP_CodeSniffer sniff for sniffing coding standards.
|
|
*
|
|
* PHP version 5
|
|
*
|
|
* @category PHP
|
|
* @package PHP_CodeSniffer
|
|
* @author Greg Sherwood <gsherwood@squiz.net>
|
|
* @author Marc McIntyre <mmcintyre@squiz.net>
|
|
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
|
* @version CVS: $Id$
|
|
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
*/
|
|
|
|
/**
|
|
* Represents a PHP_CodeSniffer sniff for sniffing coding standards.
|
|
*
|
|
* A sniff registers what token types it wishes to listen for, then, when
|
|
* PHP_CodeSniffer encounters that token, the sniff is invoked and passed
|
|
* information about where the token was found in the stack, and the
|
|
* PHP_CodeSniffer file in which the token was found.
|
|
*
|
|
* @category PHP
|
|
* @package PHP_CodeSniffer
|
|
* @author Greg Sherwood <gsherwood@squiz.net>
|
|
* @author Marc McIntyre <mmcintyre@squiz.net>
|
|
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
|
|
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
|
|
* @version Release: 1.1.0
|
|
* @link http://pear.php.net/package/PHP_CodeSniffer
|
|
*/
|
|
interface PHP_CodeSniffer_Sniff
|
|
{
|
|
|
|
|
|
/**
|
|
* Registers the tokens that this sniff wants to listen for.
|
|
*
|
|
* An example return value for a sniff that wants to listen for whitespace
|
|
* and any comments would be:
|
|
*
|
|
* <code>
|
|
* return array(
|
|
* T_WHITESPACE,
|
|
* T_DOC_COMMENT,
|
|
* T_COMMENT,
|
|
* );
|
|
* </code>
|
|
*
|
|
* @return array(int)
|
|
* @see Tokens.php
|
|
*/
|
|
public function register();
|
|
|
|
|
|
/**
|
|
* Called when one of the token types that this sniff is listening for
|
|
* is found.
|
|
*
|
|
* The stackPtr variable indicates where in the stack the token was found.
|
|
* A sniff can acquire information this token, along with all the other
|
|
* tokens within the stack by first acquiring the token stack:
|
|
*
|
|
* <code>
|
|
* $tokens = $phpcsFile->getTokens();
|
|
* echo 'Encountered a '.$tokens[$stackPtr]['type'].' token';
|
|
* echo 'token information: ';
|
|
* print_r($tokens[$stackPtr]);
|
|
* </code>
|
|
*
|
|
* If the sniff discovers an anomilty in the code, they can raise an error
|
|
* by calling addError() on the PHP_CodeSniffer_File object, specifying an error
|
|
* message and the position of the offending token:
|
|
*
|
|
* <code>
|
|
* $phpcsFile->addError('Encountered an error', $stackPtr);
|
|
* </code>
|
|
*
|
|
* @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
|
|
* token was found.
|
|
* @param int $stackPtr The position in the PHP_CodeSniffer
|
|
* file's token stack where the token
|
|
* was found.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr);
|
|
|
|
|
|
}//end interface
|
|
|
|
?>
|