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

Class: PHP_CodeSniffer_Standards_AbstractScopeSniff

Source Location: /PHP_CodeSniffer-2.7.1/CodeSniffer/Standards/AbstractScopeSniff.php

Class Overview


An AbstractScopeTest allows for tests that extend from this class to listen for tokens within a particular scope.


Author(s):

Version:

  • Release: 2.7.1

Copyright:

  • 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)

Methods


Child classes:

Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff
Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
Generic_Sniffs_NamingConventions_ConstructorNameSniff
Generic_Sniffs_NamingConventions_ConstructorNameSniff.
PSR2_Sniffs_Methods_MethodDeclarationSniff
PSR2_Sniffs_Methods_MethodDeclarationSniff.
Squiz_Sniffs_Classes_SelfMemberReferenceSniff
Tests self member references.
Squiz_Sniffs_Scope_MethodScopeSniff
Verifies that class methods have scope modifiers.
Squiz_Sniffs_Scope_StaticThisUsageSniff
Squiz_Sniffs_Scope_StaticThisUsageSniff.
Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff
Verifies that a @throws tag exists for a function that throws exceptions.
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff.
PHP_CodeSniffer_Standards_AbstractVariableSniff
A class to find T_VARIABLE tokens.
MySource_Sniffs_Channels_IncludeSystemSniff
Ensures that systems, asset types and libs are included before they are used.

Inherited Variables

Inherited Methods


Class Details

[line 47]
An AbstractScopeTest allows for tests that extend from this class to listen for tokens within a particular scope.

Below is a test that listens to methods that exist only within classes:

  1.  class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff
  2.  {
  3.      public function __construct()
  4.      {
  5.          parent::__construct(array(T_CLASS)array(T_FUNCTION));
  6.      }
  7.  
  8.      protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile$)
  9.      {
  10.          $className $phpcsFile->getDeclarationName($currScope);
  11.          echo 'encountered a method within class '.$className;
  12.      }
  13.  }



[ Top ]


Method Detail

__construct (Constructor)   [line 86]

PHP_CodeSniffer_Standards_AbstractScopeSniff __construct( array $scopeTokens, array $tokens, [boolean $listenOutside = false])

Constructs a new AbstractScopeTest.
  • See: PHP_CodeSniffer.getValidScopeTokeners()
  • Throws: PHP_CodeSniffer_Exception If the specified tokens array is empty.
  • Access: public

Overridden in child classes as:

Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff::__construct()
Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
Generic_Sniffs_NamingConventions_ConstructorNameSniff::__construct()
Constructs the test with the tokens it wishes to listen for.
PSR2_Sniffs_Methods_MethodDeclarationSniff::__construct()
Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
Squiz_Sniffs_Classes_SelfMemberReferenceSniff::__construct()
Constructs a Squiz_Sniffs_Classes_SelfMemberReferenceSniff.
Squiz_Sniffs_Scope_MethodScopeSniff::__construct()
Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
Squiz_Sniffs_Scope_StaticThisUsageSniff::__construct()
Constructs the test with the tokens it wishes to listen for.
Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff::__construct()
Constructs a Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff.
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff::__construct()
Constructs a PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff.
PHP_CodeSniffer_Standards_AbstractVariableSniff::__construct()
Constructs an AbstractVariableTest.
MySource_Sniffs_Channels_IncludeSystemSniff::__construct()
Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.

Parameters:

array   $scopeTokens   —  The type of scope the test wishes to listen to.
array   $tokens   —  The tokens that the test wishes to listen to within the scope.
boolean   $listenOutside   —  If true this test will also alert the extending class when a token is found outside the scope, by calling the processTokenOutsideScope method.

[ Top ]

process   [line 142]

void process( PHP_CodeSniffer_File $phpcsFile, int $stackPtr)

Processes the tokens that this test is listening for.

Parameters:

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

[ Top ]

processTokenOutsideScope   [line 191]

void processTokenOutsideScope( PHP_CodeSniffer_File $phpcsFile, int $stackPtr)

Processes a token that is found within the scope that this test is listening to.
  • Access: protected

Overridden in child classes as:

Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff::processTokenOutsideScope()
Processes the tokens outside the scope.
PSR1_Sniffs_Methods_CamelCapsMethodNameSniff::processTokenOutsideScope()
Processes the tokens outside the scope.
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff::processTokenOutsideScope()
Processes the tokens outside the scope.
Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff::processTokenOutsideScope()
Processes the tokens outside the scope.
PHP_CodeSniffer_Standards_AbstractVariableSniff::processTokenOutsideScope()
Processes the token outside the scope in the file.
MySource_Sniffs_Channels_IncludeSystemSniff::processTokenOutsideScope()
Processes a token within the scope that this test is listening to.

Parameters:

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

[ Top ]

processTokenWithinScope   [line 174]

void processTokenWithinScope( PHP_CodeSniffer_File $phpcsFile, int $stackPtr, int $currScope)

Processes a token that is found within the scope that this test is listening to.
  • Abstract:
  • Access: protected

Overridden in child classes as:

Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff::processTokenWithinScope()
Processes the tokens within the scope.
PSR1_Sniffs_Methods_CamelCapsMethodNameSniff::processTokenWithinScope()
Processes the tokens within the scope.
Generic_Sniffs_NamingConventions_ConstructorNameSniff::processTokenWithinScope()
Processes this test when one of its tokens is encountered.
PSR2_Sniffs_Methods_MethodDeclarationSniff::processTokenWithinScope()
Processes the function tokens within the class.
Squiz_Sniffs_Classes_SelfMemberReferenceSniff::processTokenWithinScope()
Processes the function tokens within the class.
Squiz_Sniffs_Scope_MethodScopeSniff::processTokenWithinScope()
Processes the function tokens within the class.
Squiz_Sniffs_Scope_StaticThisUsageSniff::processTokenWithinScope()
Processes this test, when one of its tokens is encountered.
Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff::processTokenWithinScope()
Processes the function tokens within the class.
PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff::processTokenWithinScope()
Processes the tokens within the scope.
PHP_CodeSniffer_Standards_AbstractVariableSniff::processTokenWithinScope()
Processes the token in the specified PHP_CodeSniffer_File.
MySource_Sniffs_Channels_IncludeSystemSniff::processTokenWithinScope()
Processes the function tokens within the class.

Parameters:

PHP_CodeSniffer_File   $phpcsFile   —  The file where this token was found.
int   $stackPtr   —  The position in the stack where this token was found.
int   $currScope   —  The position in the tokens array that opened the scope that this test is listening for.

[ Top ]

register   [line 125]

int[] register( )

The method that is called to register the tokens this test wishes to listen to.

DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register for the desired tokens and scope.

  • See: __constructor()
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:50:41 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.