PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]
Packages:
PHP_CodeSniffer


Classes:
Generic_Sniffs_Files_LineLengthSniff
Generic_Sniffs_Methods_OpeningMethodBraceBsdAllmanSniff
Generic_Sniffs_Methods_OpeningMethodBraceKernighanRitchieSniff
Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff
Generic_Sniffs_PHP_DisallowShortOpenTagSniff
Generic_Sniffs_PHP_LowerCaseConstantSniff
Generic_Sniffs_PHP_UpperCaseConstantSniff
PEAR_Sniffs_Commenting_InlineCommentSniff
PEAR_Sniffs_ControlStructures_ControlSignatureSniff
PEAR_Sniffs_Files_IncludingFileSniff
PEAR_Sniffs_Files_LineLengthSniff
PEAR_Sniffs_Methods_FunctionCallSignatureSniff
PEAR_Sniffs_Methods_MethodCallArgumentSpacingSniff
PEAR_Sniffs_Methods_OpeningMethodBraceSniff
PEAR_Sniffs_Methods_ValidDefaultValueSniff
PEAR_Sniffs_NamingConventions_ValidClassNameSniff
PEAR_Sniffs_NamingConventions_ValidConstantNameSniff
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff
PEAR_Sniffs_PHP_ConstantSniff
PEAR_Sniffs_PHP_DisallowShortOpenTagSniff
PEAR_Sniffs_Statements_MultipleStatementSniff
PEAR_Sniffs_Whitespace_ScopeClosingBraceSniff
PEAR_Sniffs_Whitespace_ScopeIndentSniff
PHP_CodeSniffer
PHP_CodeSniffer_CommentParser_AbstractDocElement
PHP_CodeSniffer_CommentParser_AbstractParser
PHP_CodeSniffer_CommentParser_ClassCommentParser
PHP_CodeSniffer_CommentParser_CommentElement
PHP_CodeSniffer_CommentParser_FunctionCommentParser
PHP_CodeSniffer_CommentParser_MemberCommentParser
PHP_CodeSniffer_CommentParser_PairElement
PHP_CodeSniffer_CommentParser_ParameterElement
PHP_CodeSniffer_CommentParser_ParserException
PHP_CodeSniffer_CommentParser_SingleElement
PHP_CodeSniffer_Exception
PHP_CodeSniffer_File
PHP_CodeSniffer_Sniff_Exception
PHP_CodeSniffer_Standards_AbstractPatternSniff
PHP_CodeSniffer_Standards_AbstractScopeSniff
PHP_CodeSniffer_Standards_AbstractVariableSniff
PHP_CodeSniffer_Standards_IncorrectPatternException
PHP_CodeSniffer_Tokens
Files:
AbstractDocElement.php
AbstractParser.php
AbstractPatternSniff.php
AbstractScopeSniff.php
AbstractVariableSniff.php
ClassCommentParser.php
CodeSniffer.php
CommentElement.php
ConstantSniff.php
ControlSignatureSniff.php
DisallowShortOpenTagSniff.php
DisallowShortOpenTagSniff.php
DocElement.php
Exception.php
File.php
FunctionCallSignatureSniff.php
FunctionCommentParser.php
IncludingFileSniff.php
IncorrectPatternException.php
InlineCommentSniff.php
LineLengthSniff.php
LineLengthSniff.php
LowerCaseConstantSniff.php
MemberCommentParser.php
MethodCallArgumentSpacingSniff.php
MultipleStatementSniff.php
OpeningMethodBraceBsdAllmanSniff.php
OpeningMethodBraceKernighanRitchieSniff.php
OpeningMethodBraceSniff.php
PairElement.php
ParameterElement.php
ParserException.php
ScopeClosingBraceSniff.php
ScopeIndentSniff.php
SingleElement.php
Sniff.php
SniffException.php
Tokens.php
UpperCaseConstantNameSniff.php
UpperCaseConstantSniff.php
ValidClassNameSniff.php
ValidConstantNameSniff.php
ValidDefaultValueSniff.php
ValidFunctionNameSniff.php

Class: PHP_CodeSniffer_Sniff

Source Location: /PHP_CodeSniffer-0.2.0/CodeSniffer/Sniff.php

Class Overview


Represents a PHP_CodeSniffer sniff for sniffing coding standards.


Author(s):

  • Squiz Pty Ltd

Methods


Inherited Variables

Inherited Methods


Class Details

[line 45]
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.

  • Author: Squiz Pty Ltd


[ Top ]


Method Detail

process [line 98]

void process( PHP_CodeSniffer_File $phpcsFile, int $stackPtr)

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:

  1. $tokens = $phpcsFile->getTokens();
  2. echo 'Encountered a '.$tokens[$stackPtr]['type'].' token';
  3. echo 'token information: ';
  4. print_r ($tokens[$stackPtr]);

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:

  1. $phpcsFile->addError('Encountered an error', $stackPtr);

  • Access: public

Parameters:

PHP_CodeSniffer_File $phpcsFile — The PHP_CodeSniffer file where the token was found.
int $stackPtr — The position in the PHP_CodeSniffer file's token stack where the token was found.

[ Top ]

register [line 66]

array(int) register( )

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:

  1. return array(
  2. T_WHITESPACE,
  3. T_DOC_COMMENT,
  4. T_COMMENT,
  5. );


[ Top ]


Documentation generated on 2019年3月11日 14:46:57 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.

AltStyle によって変換されたページ (->オリジナル) /