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


Classes:
Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff
Generic_Sniffs_Arrays_DisallowShortArraySyntaxSniff
Generic_Sniffs_Classes_DuplicateClassNameSniff
Generic_Sniffs_CodeAnalysis_EmptyStatementSniff
Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff
Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff
Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff
Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff
Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff
Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff
Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff
Generic_Sniffs_Commenting_DocCommentSniff
Generic_Sniffs_Commenting_FixmeSniff
Generic_Sniffs_Commenting_TodoSniff
Generic_Sniffs_ControlStructures_InlineControlStructureSniff
Generic_Sniffs_Debug_ClosureLinterSniff
Generic_Sniffs_Debug_CSSLintSniff
Generic_Sniffs_Debug_JSHintSniff
Generic_Sniffs_Files_ByteOrderMarkSniff
Generic_Sniffs_Files_EndFileNewlineSniff
Generic_Sniffs_Files_EndFileNoNewlineSniff
Generic_Sniffs_Files_InlineHTMLSniff
Generic_Sniffs_Files_LineEndingsSniff
Generic_Sniffs_Files_LineLengthSniff
Generic_Sniffs_Files_LowercasedFilenameSniff
Generic_Sniffs_Files_OneClassPerFileSniff
Generic_Sniffs_Files_OneInterfacePerFileSniff
Generic_Sniffs_Files_OneTraitPerFileSniff
Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff
Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff
Generic_Sniffs_Formatting_NoSpaceAfterCastSniff
Generic_Sniffs_Formatting_SpaceAfterCastSniff
Generic_Sniffs_Functions_CallTimePassByReferenceSniff
Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff
Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff
Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff
Generic_Sniffs_Metrics_CyclomaticComplexitySniff
Generic_Sniffs_Metrics_NestingLevelSniff
Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff
Generic_Sniffs_NamingConventions_ConstructorNameSniff
Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff
Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff
Generic_Sniffs_PHP_ClosingPHPTagSniff
Generic_Sniffs_PHP_DeprecatedFunctionsSniff
Generic_Sniffs_PHP_DisallowShortOpenTagSniff
Generic_Sniffs_PHP_ForbiddenFunctionsSniff
Generic_Sniffs_PHP_LowerCaseConstantSniff
Generic_Sniffs_PHP_LowerCaseKeywordSniff
Generic_Sniffs_PHP_NoSilencedErrorsSniff
Generic_Sniffs_PHP_SAPIUsageSniff
Generic_Sniffs_PHP_SyntaxSniff
Generic_Sniffs_PHP_UpperCaseConstantSniff
Generic_Sniffs_Strings_UnnecessaryStringConcatSniff
Generic_Sniffs_VersionControl_SubversionPropertiesSniff
Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff
Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff
Generic_Sniffs_WhiteSpace_ScopeIndentSniff
MySource_Sniffs_Commenting_FunctionCommentSniff
MySource_Sniffs_CSS_BrowserSpecificStylesSniff
PEAR_Sniffs_Classes_ClassDeclarationSniff
PEAR_Sniffs_Commenting_ClassCommentSniff
PEAR_Sniffs_Commenting_FileCommentSniff
PEAR_Sniffs_Commenting_FunctionCommentSniff
PEAR_Sniffs_Commenting_InlineCommentSniff
PEAR_Sniffs_ControlStructures_ControlSignatureSniff
PEAR_Sniffs_ControlStructures_MultiLineConditionSniff
PEAR_Sniffs_Files_IncludingFileSniff
PEAR_Sniffs_Formatting_MultiLineAssignmentSniff
PEAR_Sniffs_Functions_FunctionCallSignatureSniff
PEAR_Sniffs_Functions_FunctionDeclarationSniff
PEAR_Sniffs_Functions_ValidDefaultValueSniff
PEAR_Sniffs_NamingConventions_ValidClassNameSniff
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff
PEAR_Sniffs_NamingConventions_ValidVariableNameSniff
PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff
PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff
PEAR_Sniffs_WhiteSpace_ScopeIndentSniff
PHP_CodeSniffer
PHP_CodeSniffer_CLI
PHP_CodeSniffer_DocGenerators_Generator
PHP_CodeSniffer_DocGenerators_HTML
PHP_CodeSniffer_DocGenerators_Markdown
PHP_CodeSniffer_DocGenerators_Text
PHP_CodeSniffer_Exception
PHP_CodeSniffer_File
PHP_CodeSniffer_Fixer
PHP_CodeSniffer_Reporting
PHP_CodeSniffer_Reports_Cbf
PHP_CodeSniffer_Reports_Checkstyle
PHP_CodeSniffer_Reports_Csv
PHP_CodeSniffer_Reports_Diff
PHP_CodeSniffer_Reports_Emacs
PHP_CodeSniffer_Reports_Full
PHP_CodeSniffer_Reports_Gitblame
PHP_CodeSniffer_Reports_Hgblame
PHP_CodeSniffer_Reports_Info
PHP_CodeSniffer_Reports_Json
PHP_CodeSniffer_Reports_Junit
PHP_CodeSniffer_Reports_Notifysend
PHP_CodeSniffer_Reports_Source
PHP_CodeSniffer_Reports_Summary
PHP_CodeSniffer_Reports_Svnblame
PHP_CodeSniffer_Reports_VersionControl
PHP_CodeSniffer_Reports_Xml
PHP_CodeSniffer_Standards_AbstractPatternSniff
PHP_CodeSniffer_Standards_AbstractScopeSniff
PHP_CodeSniffer_Standards_AbstractVariableSniff
PHP_CodeSniffer_Standards_IncorrectPatternException
PHP_CodeSniffer_Tokenizers_Comment
PHP_CodeSniffer_Tokenizers_CSS
PHP_CodeSniffer_Tokenizers_JS
PHP_CodeSniffer_Tokenizers_PHP
PHP_CodeSniffer_Tokens
PSR1_Sniffs_Classes_ClassDeclarationSniff
PSR1_Sniffs_Files_SideEffectsSniff
PSR1_Sniffs_Methods_CamelCapsMethodNameSniff
PSR2_Sniffs_Classes_ClassDeclarationSniff
PSR2_Sniffs_Classes_PropertyDeclarationSniff
PSR2_Sniffs_ControlStructures_ControlStructureSpacingSniff
PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff
PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff
PSR2_Sniffs_Files_ClosingTagSniff
PSR2_Sniffs_Files_EndFileNewlineSniff
PSR2_Sniffs_Methods_FunctionCallSignatureSniff
PSR2_Sniffs_Methods_MethodDeclarationSniff
PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff
PSR2_Sniffs_Namespaces_UseDeclarationSniff
Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff
Squiz_Sniffs_Arrays_ArrayDeclarationSniff
Squiz_Sniffs_Classes_ClassDeclarationSniff
Squiz_Sniffs_Classes_ClassFileNameSniff
Squiz_Sniffs_Classes_DuplicatePropertySniff
Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff
Squiz_Sniffs_Classes_SelfMemberReferenceSniff
Squiz_Sniffs_Classes_ValidClassNameSniff
Squiz_Sniffs_Commenting_BlockCommentSniff
Squiz_Sniffs_Commenting_ClassCommentSniff
Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff
Squiz_Sniffs_Commenting_DocCommentAlignmentSniff
Squiz_Sniffs_Commenting_EmptyCatchCommentSniff
Squiz_Sniffs_Commenting_FileCommentSniff
Squiz_Sniffs_Commenting_FunctionCommentSniff
Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff
Squiz_Sniffs_Commenting_InlineCommentSniff
Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff
Squiz_Sniffs_Commenting_PostStatementCommentSniff
Squiz_Sniffs_Commenting_VariableCommentSniff
Squiz_Sniffs_ControlStructures_ControlSignatureSniff
Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff
Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff
Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff
Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff
Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff
Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff
Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff
Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff
Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff
Squiz_Sniffs_CSS_ColonSpacingSniff
Squiz_Sniffs_CSS_ColourDefinitionSniff
Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff
Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff
Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff
Squiz_Sniffs_CSS_EmptyClassDefinitionSniff
Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff
Squiz_Sniffs_CSS_ForbiddenStylesSniff
Squiz_Sniffs_CSS_IndentationSniff
Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff
Squiz_Sniffs_CSS_MissingColonSniff
Squiz_Sniffs_CSS_NamedColoursSniff
Squiz_Sniffs_CSS_OpacitySniff
Squiz_Sniffs_CSS_SemicolonSpacingSniff
Squiz_Sniffs_CSS_ShorthandSizeSniff
Squiz_Sniffs_Debug_JavaScriptLintSniff
Squiz_Sniffs_Debug_JSLintSniff
Squiz_Sniffs_Files_FileExtensionSniff
Squiz_Sniffs_Formatting_OperatorBracketSniff
Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff
Squiz_Sniffs_Functions_FunctionDeclarationSniff
Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff
Squiz_Sniffs_Functions_GlobalFunctionSniff
Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff
Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff
Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff
Squiz_Sniffs_NamingConventions_ValidVariableNameSniff
Squiz_Sniffs_Objects_DisallowObjectStringIndexSniff
Squiz_Sniffs_Objects_ObjectInstantiationSniff
Squiz_Sniffs_Objects_ObjectMemberCommaSniff
Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff
Squiz_Sniffs_Operators_IncrementDecrementUsageSniff
Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff
Squiz_Sniffs_PHP_CommentedOutCodeSniff
Squiz_Sniffs_PHP_DisallowBooleanStatementSniff
Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff
Squiz_Sniffs_PHP_DisallowInlineIfSniff
Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff
Squiz_Sniffs_PHP_DisallowObEndFlushSniff
Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff
Squiz_Sniffs_PHP_DiscouragedFunctionsSniff
Squiz_Sniffs_PHP_EmbeddedPhpSniff
Squiz_Sniffs_PHP_EvalSniff
Squiz_Sniffs_PHP_ForbiddenFunctionsSniff
Squiz_Sniffs_PHP_GlobalKeywordSniff
Squiz_Sniffs_PHP_HeredocSniff
Squiz_Sniffs_PHP_InnerFunctionsSniff
Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff
Squiz_Sniffs_PHP_NonExecutableCodeSniff
Squiz_Sniffs_Scope_MemberVarScopeSniff
Squiz_Sniffs_Scope_MethodScopeSniff
Squiz_Sniffs_Scope_StaticThisUsageSniff
Squiz_Sniffs_Strings_ConcatenationSpacingSniff
Squiz_Sniffs_Strings_DoubleQuoteUsageSniff
Squiz_Sniffs_Strings_EchoedStringsSniff
Squiz_Sniffs_WhiteSpace_CastSpacingSniff
Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff
Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff
Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff
Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff
Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff
Squiz_Sniffs_WhiteSpace_LogicalOperatorSpacingSniff
Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff
Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff
Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff
Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff
Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff
Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff
Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff
Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff
Zend_Sniffs_Debug_CodeAnalyzerSniff
Zend_Sniffs_Files_ClosingTagSniff
Zend_Sniffs_NamingConventions_ValidVariableNameSniff
Files:
AbstractPatternSniff.php
AbstractScopeSniff.php
AbstractVariableSniff.php
ArrayBracketSpacingSniff.php
ArrayDeclarationSniff.php
BlockCommentSniff.php
BrowserSpecificStylesSniff.php
ByteOrderMarkSniff.php
CallTimePassByReferenceSniff.php
CamelCapsFunctionNameSniff.php
CamelCapsMethodNameSniff.php
CastSpacingSniff.php
Cbf.php
CharacterBeforePHPOpeningTagSniff.php
Checkstyle.php
ClassCommentSniff.php
ClassCommentSniff.php
ClassDeclarationSniff.php
ClassDeclarationSniff.php
ClassDeclarationSniff.php
ClassDeclarationSniff.php
ClassDefinitionClosingBraceSpaceSniff.php
ClassDefinitionNameSpacingSniff.php
ClassDefinitionOpeningBraceSpaceSniff.php
ClassFileNameSniff.php
CLI.php
ClosingDeclarationCommentSniff.php
ClosingPHPTagSniff.php
ClosingTagSniff.php
ClosingTagSniff.php
ClosureLinterSniff.php
CodeAnalyzerSniff.php
CodeSniffer.php
ColonSpacingSniff.php
ColourDefinitionSniff.php
Comment.php
CommentedOutCodeSniff.php
ComparisonOperatorUsageSniff.php
ConcatenationSpacingSniff.php
ConstructorNameSniff.php
ControlSignatureSniff.php
ControlSignatureSniff.php
ControlStructureSpacingSniff.php
ControlStructureSpacingSniff.php
CSS.php
CSSLintSniff.php
Csv.php
CyclomaticComplexitySniff.php
DeprecatedFunctionsSniff.php
Diff.php
DisallowBooleanStatementSniff.php
DisallowComparisonAssignmentSniff.php
DisallowInlineIfSniff.php
DisallowLongArraySyntaxSniff.php
DisallowMultipleAssignmentsSniff.php
DisallowMultipleStatementsSniff.php
DisallowMultipleStyleDefinitionsSniff.php
DisallowObEndFlushSniff.php
DisallowShortArraySyntaxSniff.php
DisallowShortOpenTagSniff.php
DisallowSizeFunctionsInLoopsSniff.php
DisallowSpaceIndentSniff.php
DisallowTabIndentSniff.php
DiscouragedFunctionsSniff.php
DocCommentAlignmentSniff.php
DocCommentSniff.php
DoubleQuoteUsageSniff.php
DuplicateClassDefinitionSniff.php
DuplicateClassNameSniff.php
DuplicatePropertySniff.php
DuplicateStyleDefinitionSniff.php
EchoedStringsSniff.php
ElseIfDeclarationSniff.php
ElseIfDeclarationSniff.php
Emacs.php
EmbeddedPhpSniff.php
EmptyCatchCommentSniff.php
EmptyClassDefinitionSniff.php
EmptyStatementSniff.php
EmptyStyleDefinitionSniff.php
EndFileNewlineSniff.php
EndFileNewlineSniff.php
EndFileNoNewlineSniff.php
EvalSniff.php
Exception.php
File.php
FileCommentSniff.php
FileCommentSniff.php
FileExtensionSniff.php
Fixer.php
FixmeSniff.php
ForbiddenFunctionsSniff.php
ForbiddenFunctionsSniff.php
ForbiddenStylesSniff.php
ForEachLoopDeclarationSniff.php
ForLoopDeclarationSniff.php
ForLoopShouldBeWhileLoopSniff.php
ForLoopWithTestFunctionCallSniff.php
Full.php
FunctionCallArgumentSpacingSniff.php
FunctionCallSignatureSniff.php
FunctionCallSignatureSniff.php
FunctionClosingBraceSpaceSniff.php
FunctionCommentSniff.php
FunctionCommentSniff.php
FunctionCommentSniff.php
FunctionCommentThrowTagSniff.php
FunctionDeclarationArgumentSpacingSniff.php
FunctionDeclarationSniff.php
FunctionDeclarationSniff.php
FunctionDuplicateArgumentSniff.php
FunctionOpeningBraceSpaceSniff.php
FunctionSpacingSniff.php
Generator.php
Gitblame.php
GlobalFunctionSniff.php
GlobalKeywordSniff.php
HeredocSniff.php
Hgblame.php
HTML.php
IncludingFileSniff.php
IncorrectPatternException.php
IncrementDecrementUsageSniff.php
IndentationSniff.php
Info.php
InlineCommentSniff.php
InlineCommentSniff.php
InlineControlStructureSniff.php
InlineHTMLSniff.php
InlineIfDeclarationSniff.php
InnerFunctionsSniff.php
JavaScriptLintSniff.php
JS.php
JSHintSniff.php
JSLintSniff.php
Json.php
JumbledIncrementerSniff.php
Junit.php
LanguageConstructSpacingSniff.php
LineEndingsSniff.php
LineLengthSniff.php
LogicalOperatorSpacingSniff.php
LongConditionClosingCommentSniff.php
LowercaseClassKeywordsSniff.php
LowerCaseConstantSniff.php
LowercaseDeclarationSniff.php
LowercasedFilenameSniff.php
LowercaseFunctionKeywordsSniff.php
LowerCaseKeywordSniff.php
LowercasePHPFunctionsSniff.php
LowercaseStyleDefinitionSniff.php
Markdown.php
MemberVarScopeSniff.php
MemberVarSpacingSniff.php
MethodDeclarationSniff.php
MethodScopeSniff.php
MissingColonSniff.php
MultiLineAssignmentSniff.php
MultiLineConditionSniff.php
MultiLineFunctionDeclarationSniff.php
MultipleStatementAlignmentSniff.php
NamedColoursSniff.php
NamespaceDeclarationSniff.php
NestingLevelSniff.php
NonExecutableCodeSniff.php
NoSilencedErrorsSniff.php
NoSpaceAfterCastSniff.php
Notifysend.php
ObjectInstantiationSniff.php
ObjectMemberCommaSniff.php
ObjectOperatorIndentSniff.php
ObjectOperatorSpacingSniff.php
OneClassPerFileSniff.php
OneInterfacePerFileSniff.php
OneTraitPerFileSniff.php
OpacitySniff.php
OpeningFunctionBraceBsdAllmanSniff.php
OpeningFunctionBraceKernighanRitchieSniff.php
OperatorBracketSniff.php
OperatorSpacingSniff.php
PHP.php
PostStatementCommentSniff.php
PropertyDeclarationSniff.php
PropertyLabelSpacingSniff.php
Report.php
Reporting.php
SAPIUsageSniff.php
ScopeClosingBraceSniff.php
ScopeClosingBraceSniff.php
ScopeIndentSniff.php
ScopeIndentSniff.php
ScopeKeywordSpacingSniff.php
SelfMemberReferenceSniff.php
SemicolonSpacingSniff.php
SemicolonSpacingSniff.php
ShorthandSizeSniff.php
SideEffectsSniff.php
Sniff.php
Source.php
SpaceAfterCastSniff.php
StaticThisUsageSniff.php
SubversionPropertiesSniff.php
Summary.php
SuperfluousWhitespaceSniff.php
Svnblame.php
SwitchDeclarationSniff.php
SwitchDeclarationSniff.php
SyntaxSniff.php
Text.php
TodoSniff.php
Tokens.php
UnconditionalIfStatementSniff.php
UnnecessaryFinalModifierSniff.php
UnnecessaryStringConcatSniff.php
UnusedFunctionParameterSniff.php
UpperCaseConstantNameSniff.php
UpperCaseConstantSniff.php
UseDeclarationSniff.php
UselessOverridingMethodSniff.php
ValidClassNameSniff.php
ValidClassNameSniff.php
ValidDefaultValueSniff.php
ValidFunctionNameSniff.php
ValidFunctionNameSniff.php
ValidLogicalOperatorsSniff.php
ValidVariableNameSniff.php
ValidVariableNameSniff.php
ValidVariableNameSniff.php
VariableCommentSniff.php
VersionControl.php
Xml.php

Class: PHP_CodeSniffer_File

Source Location: /PHP_CodeSniffer-2.6.0/CodeSniffer/File.php


Inherited Variables

Inherited Methods


Class Details

[line 117]
A PHP_CodeSniffer_File object represents a PHP source file and the tokens associated with it.

It provides a means for traversing the token stack, along with other token related operations. If a PHP_CodeSniffer_Sniff finds and error or warning within a PHP_CodeSniffer_File, you can raise an error using the addError() or addWarning() methods.

Token Information

Each token within the stack contains information about itself:

  1. array(
  2. 'code' => 301, // the token type code (see token_get_all())
  3. 'content' => 'if', // the token content
  4. 'type' => 'T_IF', // the token name
  5. 'line' => 56, // the line number when the token is located
  6. 'column' => 12, // the column in the line where this token
  7. // starts (starts from 1)
  8. 'level' => 2 // the depth a token is within the scopes open
  9. 'conditions' => array( // a list of scope condition token
  10. // positions => codes that
  11. 2 => 50, // opened the scopes that this token exists
  12. 9 => 353, // in (see conditional tokens section below)
  13. ),
  14. );

Conditional Tokens

In addition to the standard token fields, conditions contain information to determine where their scope begins and ends:

  1. array(
  2. 'scope_condition' => 38, // the token position of the condition
  3. 'scope_opener' => 41, // the token position that started the scope
  4. 'scope_closer' => 70, // the token position that ended the scope
  5. );

The condition, the scope opener and the scope closer each contain this information.

Parenthesis Tokens

Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a reference to their opening and closing parenthesis, one being itself, the other being its opposite.

  1. array(
  2. 'parenthesis_opener' => 34,
  3. 'parenthesis_closer' => 40,
  4. );

Some tokens can "own" a set of parenthesis. For example a T_FUNCTION token has parenthesis around its argument list. These tokens also have the parenthesis_opener and and parenthesis_closer indices. Not all parenthesis have owners, for example parenthesis used for arithmetic operations and function calls. The parenthesis tokens that have an owner have the following auxiliary array indices.

  1. array(
  2. 'parenthesis_opener' => 34,
  3. 'parenthesis_closer' => 40,
  4. 'parenthesis_owner' => 33,
  5. );

Each token within a set of parenthesis also has an array index 'nested_parenthesis' which is an array of the left parenthesis => right parenthesis token positions.

  1. 'nested_parenthesis' => array(
  2. 12 => 15
  3. 11 => 14
  4. );

Extended Tokens

PHP_CodeSniffer extends and augments some of the tokens created by token_get_all(). A full list of these tokens can be seen in the Tokens.php file.



[ Top ]


Class Variables

$eolChar = ''

[line 132]

The EOL character this file uses.
  • Access: public

Type: string


[ Top ]

$fixer = null

[line 146]

The Fixer object to control fixing errors.
  • Access: public



[ Top ]

$numTokens = 0

[line 169]

The number of tokens in this file.

Stored here to save calling count() everywhere.

  • Access: public

Type: int


[ Top ]

$phpcs = null

[line 139]

The PHP_CodeSniffer object controlling this run.
  • Access: public



[ Top ]

$ruleset = array()

[line 286]

An array of rules from the ruleset.xml file.

This value gets set by PHP_CodeSniffer when the object is created. It may be empty, indicating that the ruleset does not override any of the default sniff settings.

  • Access: protected

Type: array


[ Top ]

$tokenizer = null

[line 153]

The tokenizer being used for this file.
  • Access: public

Type: object


[ Top ]

$tokenizerType = 'PHP'

[line 160]

The tokenizer being used for this file.
  • Access: public

Type: string


[ Top ]



Method Detail

__construct (Constructor) [line 303]

PHP_CodeSniffer_File __construct( string $file, array $listeners, array $ruleset, PHP_CodeSniffer $phpcs)

Constructs a PHP_CodeSniffer_File.
  • Throws: PHP_CodeSniffer_Exception If the register() method does not return an array.
  • Access: public

Parameters:

string $file — The absolute path to the file to process.
array(string) $listeners — The initial listeners listening to processing of this file. to processing of this file.
array $ruleset — An array of rules from the ruleset.xml file. ruleset.xml file.
PHP_CodeSniffer $phpcs — The PHP_CodeSniffer object controlling this run. this run.

[ Top ]

addError [line 808]

boolean addError( string $error, int $stackPtr, [string $code = ''], [array $data = array()], [int $severity = 0], [boolean $fixable = false])

Records an error against a specific token in the file.
  • Access: public

Parameters:

string $error — The error message.
int $stackPtr — The stack position where the error occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the error message.
int $severity — The severity level for this error. A value of 0 will be converted into the default severity level.
boolean $fixable — Can the error be fixed by the sniff?

[ Top ]

addErrorOnLine [line 875]

boolean addErrorOnLine( string $error, int $line, [string $code = ''], [array $data = array()], [int $severity = 0])

Records an error against a specific line in the file.
  • Access: public

Parameters:

string $error — The error message.
int $line — The line on which the error occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the error message.
int $severity — The severity level for this error. A value of 0 will be converted into the default severity level. will be converted into the default severity level.

[ Top ]

addFixableError [line 925]

boolean addFixableError( string $error, int $stackPtr, [string $code = ''], [array $data = array()], [int $severity = 0])

Records a fixable error against a specific token in the file.

Returns true if the error was recorded and should be fixed.

  • Access: public

Parameters:

string $error — The error message.
int $stackPtr — The stack position where the error occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the error message.
int $severity — The severity level for this error. A value of 0 will be converted into the default severity level.

[ Top ]

addFixableWarning [line 956]

boolean addFixableWarning( string $warning, int $stackPtr, [string $code = ''], [array $data = array()], [int $severity = 0])

Records a fixable warning against a specific token in the file.

Returns true if the warning was recorded and should be fixed.

  • Access: public

Parameters:

string $warning — The error message.
int $stackPtr — The stack position where the error occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the warning message.
int $severity — The severity level for this warning. A value of 0 will be converted into the default severity level.

[ Top ]

addTokenListener [line 365]

void addTokenListener( PHP_CodeSniffer_Sniff $listener, array $tokens)

Adds a listener to the token stack that listens to the specific tokens.

When PHP_CodeSniffer encounters on the the tokens specified in $tokens, it invokes the process method of the sniff.

  • Access: public

Parameters:

PHP_CodeSniffer_Sniff $listener — The listener to add to the listener stack.
array(int) $tokens — The token types the listener wishes to listen to.

[ Top ]

addWarning [line 842]

boolean addWarning( string $warning, int $stackPtr, [string $code = ''], [array $data = array()], [int $severity = 0], [boolean $fixable = false])

Records a warning against a specific token in the file.
  • Access: public

Parameters:

string $warning — The error message.
int $stackPtr — The stack position where the error occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the warning message.
int $severity — The severity level for this warning. A value of 0 will be converted into the default severity level.
boolean $fixable — Can the warning be fixed by the sniff?

[ Top ]

addWarningOnLine [line 899]

boolean addWarningOnLine( string $warning, int $line, [string $code = ''], [array $data = array()], [int $severity = 0])

Records a warning against a specific token in the file.
  • Access: public

Parameters:

string $warning — The error message.
int $line — The line on which the warning occurred.
string $code — A violation code unique to the sniff message.
array $data — Replacements for the warning message.
int $severity — The severity level for this warning. A value of 0 will be converted into the default severity level. will be converted into the default severity level.

[ Top ]

cleanUp [line 631]

void cleanUp( )

Remove vars stored in this file that are no longer required.
  • Access: public

[ Top ]

detectLineEndings [line 750]

string detectLineEndings( string $file, [string $contents = null])

Opens a file and detects the EOL character being used.
  • Throws: PHP_CodeSniffer_Exception If $file could not be opened.
  • Access: public

Parameters:

string $file — The full path to the file.
string $contents — The contents to parse. If NULL, the content is taken from the file system.

[ Top ]

findEndOfStatement [line 3464]

int findEndOfStatement( int $start)

Returns the position of the last non-whitespace token in a statement.
  • Access: public

Parameters:

int $start — The position to start searching from in the token stack.

[ Top ]

findExtendedClassName [line 3659]

string findExtendedClassName( int $stackPtr)

Returns the name of the class that the specified class extends.

Returns FALSE on error or if there is no extended class name.

  • Access: public

Parameters:

int $stackPtr — The stack position of the class.

[ Top ]

findFirstOnLine [line 3539]

int findFirstOnLine( int|array $types, int $start, [bool $exclude = false], [string $value = null])

Returns the position of the first token on a line, matching given type.

Returns false if no token can be found.

  • Return: | bool
  • Access: public

Parameters:

int|array $types — The type(s) of tokens to search for.
int $start — The position to start searching from in the token stack. The first token matching on this line before this token will be returned.
bool $exclude — If true, find the token that is NOT of the types specified in $types.
string $value — The value that the token must be equal to. If value is omitted, tokens with any value will be returned.

[ Top ]

findNext [line 3361]

int|bool findNext( int|array $types, int $start, [int $end = null], [bool $exclude = false], [string $value = null], [bool $local = false])

Returns the position of the next specified token(s).

If a value is specified, the next token of the specified type(s) containing the specified value will be returned.

Returns false if no token can be found.


Parameters:

int|array $types — The type(s) of tokens to search for.
int $start — The position to start searching from in the token stack.
int $end — The end position to fail if no token is found. if not specified or null, end will default to the end of the token stack.
bool $exclude — If true, find the next token that is NOT of a type specified in $types.
string $value — The value that the token(s) must be equal to. If value is omitted, tokens with any value will be returned.
bool $local — If true, tokens outside the current statement will not be checked. i.e., checking will stop at the next semi-colon found.

[ Top ]

findPrevious [line 3280]

int|bool findPrevious( int|array $types, int $start, [int $end = null], [bool $exclude = false], [string $value = null], [bool $local = false])

Returns the position of the previous specified token(s).

If a value is specified, the previous token of the specified type(s) containing the specified value will be returned.

Returns false if no token can be found.


Parameters:

int|array $types — The type(s) of tokens to search for.
int $start — The position to start searching from in the token stack.
int $end — The end position to fail if no token is found. if not specified or null, end will default to the start of the token stack.
bool $exclude — If true, find the previous token that are NOT of the types specified in $types.
string $value — The value that the token(s) must be equal to. If value is omitted, tokens with any value will be returned.
bool $local — If true, tokens outside the current statement will not be checked. IE. checking will stop at the previous semi-colon found.

[ Top ]

findStartOfStatement [line 3409]

int findStartOfStatement( int $start)

Returns the position of the first non-whitespace token in a statement.
  • Access: public

Parameters:

int $start — The position to start searching from in the token stack.

[ Top ]

getClassProperties [line 3092]

array getClassProperties( int $stackPtr)

Returns the visibility and implementation properties of a class.

The format of the array is:

  1. array(
  2. 'is_abstract' => false, // true if the abstract keyword was found.
  3. 'is_final' => false, // true if the final keyword was found.
  4. );

  • Throws: PHP_CodeSniffer_Exception If the specified position is not a T_CLASS token.
  • Access: public

Parameters:

int $stackPtr — The position in the stack of the T_CLASS token to acquire the properties for.

[ Top ]

getCondition [line 3626]

int getCondition( int $stackPtr, int $type)

Return the position of the condition for the passed token.

Returns FALSE if the token does not have the condition.

  • Access: public

Parameters:

int $stackPtr — The position of the token we are checking.
int $type — The type of token to search for.

[ Top ]

getDeclarationName [line 2659]

string|null getDeclarationName( int $stackPtr)

Returns the declaration names for T_CLASS, T_INTERFACE and T_FUNCTION tokens.
  • Return: The name of the class, interface or function. or NULL if the function is a closure.
  • Throws: PHP_CodeSniffer_Exception If the specified token is not of type T_FUNCTION, T_CLASS or T_INTERFACE.
  • Access: public

Parameters:

int $stackPtr — The position of the declaration token which declared the class, interface or function.

[ Top ]

getErrorCount [line 1304]

int getErrorCount( )

Returns the number of errors raised.
  • Access: public

[ Top ]

getErrors [line 1364]

array getErrors( )

Returns the errors raised from processing this file.
  • Access: public

[ Top ]

getFilename [line 1400]

string getFilename( )

Returns the absolute filename of this file.
  • Access: public

[ Top ]

getFixableCount [line 1340]

int getFixableCount( )

Returns the number of fixable errors/warnings raised.
  • Access: public

[ Top ]

getIgnoredLines [line 1352]

array getIgnoredLines( )

Returns the list of ignored lines.
  • Access: public

[ Top ]

getMemberProperties [line 2994]

array getMemberProperties( int $stackPtr)

Returns the visibility and implementation properties of the class member variable found at the specified position in the stack.

The format of the array is:

  1. array(
  2. 'scope' => 'public', // public private or protected
  3. 'is_static' => false, // true if the static keyword was found.
  4. );

  • Throws: PHP_CodeSniffer_Exception If the specified position is not a T_VARIABLE token, or if the position is not a class member variable.
  • Access: public

Parameters:

int $stackPtr — The position in the stack of the T_VARIABLE token to acquire the properties for.

[ Top ]

getMethodParameters [line 2757]

array getMethodParameters( int $stackPtr)

Returns the method parameters for the specified T_FUNCTION token.

Each parameter is in the following format:

  1. 0 => array(
  2. 'name' => '$var', // The variable name.
  3. 'pass_by_reference' => false, // Passed by reference.
  4. 'type_hint' => string, // Type hint for array or custom type
  5. )

Parameters with default values have an additional array index of 'default' with the value of the default as a string.

  • Throws: PHP_CodeSniffer_Exception If the specified $stackPtr is not of type T_FUNCTION.
  • Access: public

Parameters:

int $stackPtr — The position in the stack of the T_FUNCTION token to acquire the parameters for.

[ Top ]

getMethodProperties [line 2906]

array getMethodProperties( int $stackPtr)

Returns the visibility and implementation properties of a method.

The format of the array is:

  1. array(
  2. 'scope' => 'public', // public private or protected
  3. 'scope_specified' => true, // true is scope keyword was found.
  4. 'is_abstract' => false, // true if the abstract keyword was found.
  5. 'is_final' => false, // true if the final keyword was found.
  6. 'is_static' => false, // true if the static keyword was found.
  7. 'is_closure' => false, // true if no name is found.
  8. );

  • Throws: PHP_CodeSniffer_Exception If the specified position is not a T_FUNCTION token.
  • Access: public

Parameters:

int $stackPtr — The position in the stack of the T_FUNCTION token to acquire the properties for.

[ Top ]

getMetrics [line 1388]

array getMetrics( )

Returns the metrics found while processing this file.
  • Access: public

[ Top ]

getSuccessCount [line 1328]

int getSuccessCount( )

Returns the number of successes recorded.
  • Access: public

[ Top ]

getTokens [line 425]

array getTokens( )

Returns the token stack for this file.
  • Access: public

[ Top ]

getTokensAsString [line 3237]

string getTokensAsString( int $start, int $length)

Returns the content of the tokens from the specified start position in the token stack for the specified length.
  • Return: The token contents.
  • Access: public

Parameters:

int $start — The position to start from in the token stack.
int $length — The length of tokens to traverse from the start pos.

[ Top ]

getWarningCount [line 1316]

int getWarningCount( )

Returns the number of warnings raised.
  • Access: public

[ Top ]

getWarnings [line 1376]

array getWarnings( )

Returns the warnings raised from processing this file.
  • Access: public

[ Top ]

hasCondition [line 3589]

boolean hasCondition( int $stackPtr, int|array $types)

Determine if the passed token has a condition of one of the passed types.
  • Access: public

Parameters:

int $stackPtr — The position of the token we are checking.
int|array $types — The type(s) of tokens to search for.

[ Top ]

isAnonymousFunction [line 2699]

boolean isAnonymousFunction( int $stackPtr)

Check if the token at the specified position is a anonymous function.
  • Throws: PHP_CodeSniffer_Exception If the specified token is not of type T_FUNCTION
  • Access: public

Parameters:

int $stackPtr — The position of the declaration token which declared the class, interface or function.

[ Top ]

isReference [line 3143]

boolean isReference( int $stackPtr)

Determine if the passed token is a reference operator.

Returns true if the specified token position represents a reference. Returns false if the token represents a bitwise operator.

  • Access: public

Parameters:

int $stackPtr — The position of the T_BITWISE_AND token.

[ Top ]

recordMetric [line 1278]

boolean recordMetric( int $stackPtr, string $metric, string $value)

Adds an warning to the warning stack.
  • Access: public

Parameters:

int $stackPtr — The stack position where the metric was recorded.
string $metric — The name of the metric being recorded.
string $value — The value of the metric being recorded.

[ Top ]

refreshTokenListeners [line 412]

void refreshTokenListeners( )

Rebuilds the list of listeners to ensure their state is cleared.
  • Access: public

[ Top ]

removeTokenListener [line 391]

void removeTokenListener( PHP_CodeSniffer_Sniff $listener, array $tokens)

Removes a listener from listening from the specified tokens.
  • Access: public

Parameters:

PHP_CodeSniffer_Sniff $listener — The listener to remove from the listener stack.
array(int) $tokens — The token types the listener wishes to stop listen to.

[ Top ]

setActiveListener [line 345]

void setActiveListener( string $activeListener)

Sets the name of the currently active sniff.
  • Access: public

Parameters:

string $activeListener — The class name of the current sniff.

[ Top ]

start [line 440]

void start( [string $contents = null])

Starts the stack traversal and tells listeners when tokens are found.
  • Access: public

Parameters:

string $contents — The contents to parse. If NULL, the content is taken from the file system.

[ Top ]

tokenizeString [line 1422]

array tokenizeString( string $string, object $tokenizer, [string $eolChar = '\n'], [int $tabWidth = null], [string $encoding = null])

Creates an array of tokens when given some PHP code.

Starts by using token_get_all() but does a lot of extra processing to insert information about the context of the token.

  • Throws: PHP_CodeSniffer_Exception If the file cannot be processed.
  • Access: public

Parameters:

string $string — The string to tokenize.
object $tokenizer — A tokenizer class to use to tokenize the string.
string $eolChar — The EOL character to use for splitting strings.
int $tabWidth — The number of spaces each tab respresents.
string $encoding — The charset of the sniffed file.

[ Top ]


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

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