Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0 | Variable sniffs: minor performance tweak #374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -10,12 +10,27 @@
namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\NamingConventions;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Tokens;

class ValidVariableNameSniff extends AbstractVariableSniff
{


/**
* Only listen to variables within OO scopes.
*/
public function __construct()
{
$scopes = Tokens::$ooScopeTokens;
$listen = [T_VARIABLE];

AbstractScopeSniff::__construct($scopes, $listen, false);

}//end __construct()


/**
* Processes class member variables.
*
14 changes: 14 additions & 0 deletions src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php
Original file line number Diff line number Diff line change
@@ -11,13 +11,27 @@

use Exception;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Tokens;

class PropertyDeclarationSniff extends AbstractVariableSniff
{


/**
* Only listen to variables within OO scopes.
*/
public function __construct()
{
$scopes = Tokens::$ooScopeTokens;
$listen = [T_VARIABLE];

AbstractScopeSniff::__construct($scopes, $listen, false);

}//end __construct()


/**
* Processes the function tokens within the class.
*
15 changes: 15 additions & 0 deletions src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php
Original file line number Diff line number Diff line change
@@ -10,13 +10,28 @@
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Common;
use PHP_CodeSniffer\Util\Tokens;

class VariableCommentSniff extends AbstractVariableSniff
{


/**
* Only listen to variables within OO scopes.
*/
public function __construct()
{
$scopes = Tokens::$ooScopeTokens;
$listen = [T_VARIABLE];

AbstractScopeSniff::__construct($scopes, $listen, false);

}//end __construct()


/**
* Called to process class member vars.
*
15 changes: 15 additions & 0 deletions src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php
Original file line number Diff line number Diff line change
@@ -10,12 +10,27 @@
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Tokens;

class MemberVarScopeSniff extends AbstractVariableSniff
{


/**
* Only listen to variables within OO scopes.
*/
public function __construct()
{
$scopes = Tokens::$ooScopeTokens;
$listen = [T_VARIABLE];

AbstractScopeSniff::__construct($scopes, $listen, false);

}//end __construct()


/**
* Processes the function tokens within the class.
*
14 changes: 14 additions & 0 deletions src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Tokens;

@@ -31,6 +32,19 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
public $spacingBeforeFirst = 1;


/**
* Only listen to variables within OO scopes.
*/
public function __construct()
{
$scopes = Tokens::$ooScopeTokens;
$listen = [T_VARIABLE];

AbstractScopeSniff::__construct($scopes, $listen, false);

}//end __construct()


/**
* Processes the function tokens within the class.
*