Skip to content

Commit 6a19a67

Browse files
committed
Rename "checkFor" functions to "isVariableA" to be more clear
1 parent 3ea2c00 commit 6a19a67

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ protected function markAllVariablesRead(File $phpcsFile, $stackPtr) {
478478
*
479479
* @return bool
480480
*/
481-
protected function checkForFunctionDefinition(File $phpcsFile, $stackPtr, $varName, $currScope) {
481+
protected function isVariableAFunctionDefinition(File $phpcsFile, $stackPtr, $varName, $currScope) {
482482
$tokens = $phpcsFile->getTokens();
483483

484484
// Are we a function or closure parameter?
@@ -547,7 +547,7 @@ protected function checkForFunctionDefinition(File $phpcsFile, $stackPtr, $varNa
547547
*
548548
* @return bool
549549
*/
550-
protected function checkForClassProperty(File $phpcsFile, $stackPtr) {
550+
protected function isVariableAClassProperty(File $phpcsFile, $stackPtr) {
551551
$propertyDeclarationKeywords = [
552552
T_PUBLIC,
553553
T_PRIVATE,
@@ -587,7 +587,7 @@ protected function checkForClassProperty(File $phpcsFile, $stackPtr) {
587587
*
588588
* @return bool
589589
*/
590-
protected function checkForCatchBlock(File $phpcsFile, $stackPtr, $varName, $currScope) {
590+
protected function isVariableACatchBlock(File $phpcsFile, $stackPtr, $varName, $currScope) {
591591
$tokens = $phpcsFile->getTokens();
592592

593593
// Are we a catch block parameter?
@@ -617,7 +617,7 @@ protected function checkForCatchBlock(File $phpcsFile, $stackPtr, $varName, $cur
617617
*
618618
* @return bool
619619
*/
620-
protected function checkForThisWithinClass(File $phpcsFile, $stackPtr, $varName) {
620+
protected function isVariableAThisWithinClass(File $phpcsFile, $stackPtr, $varName) {
621621
$tokens = $phpcsFile->getTokens();
622622
$token = $tokens[$stackPtr];
623623

@@ -654,7 +654,7 @@ protected function checkForThisWithinClass(File $phpcsFile, $stackPtr, $varName)
654654
*
655655
* @return bool
656656
*/
657-
protected function checkForSuperGlobal($varName) {
657+
protected function isVariableASuperGlobal($varName) {
658658
// Are we a superglobal variable?
659659
if (in_array($varName, [
660660
'GLOBALS',
@@ -681,7 +681,7 @@ protected function checkForSuperGlobal($varName) {
681681
*
682682
* @return bool
683683
*/
684-
protected function checkForStaticMember(File $phpcsFile, $stackPtr) {
684+
protected function isVariableAStaticMember(File $phpcsFile, $stackPtr) {
685685
$tokens = $phpcsFile->getTokens();
686686

687687
$doubleColonPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true);
@@ -715,7 +715,7 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr) {
715715
*
716716
* @return bool
717717
*/
718-
protected function checkForStaticOutsideClass(File $phpcsFile, $stackPtr, $varName) {
718+
protected function isVariableAStaticOutsideClass(File $phpcsFile, $stackPtr, $varName) {
719719
// Are we refering to self:: outside a class?
720720
721721
$tokens = $phpcsFile->getTokens();
@@ -759,15 +759,15 @@ protected function checkForStaticOutsideClass(File $phpcsFile, $stackPtr, $varNa
759759
*
760760
* @return bool
761761
*/
762-
protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
762+
protected function isVariableAAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
763763
// Is the next non-whitespace an assignment?
764764
$assignPtr = Helpers::getNextAssignPointer($phpcsFile, $stackPtr);
765765
if (! is_int($assignPtr)) {
766766
return false;
767767
}
768768

769769
// Is this a variable variable? If so, it's not an assignment to the current variable.
770-
if ($this->checkForVariableVariable($phpcsFile, $stackPtr)) {
770+
if ($this->isVariableAVariableVariable($phpcsFile, $stackPtr)) {
771771
Helpers::debug('found variable variable');
772772
return false;
773773
}
@@ -797,7 +797,7 @@ protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $cur
797797
*
798798
* @return bool
799799
*/
800-
protected function checkForVariableVariable(File $phpcsFile, $stackPtr) {
800+
protected function isVariableAVariableVariable(File $phpcsFile, $stackPtr) {
801801
$tokens = $phpcsFile->getTokens();
802802

803803
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
@@ -826,7 +826,7 @@ protected function checkForVariableVariable(File $phpcsFile, $stackPtr) {
826826
*
827827
* @return bool
828828
*/
829-
protected function checkForListShorthandAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
829+
protected function isVariableAListShorthandAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
830830
// OK, are we within a [ ... ] construct?
831831
$openPtr = Helpers::findContainingOpeningSquareBracket($phpcsFile, $stackPtr);
832832
if (! is_int($openPtr)) {
@@ -862,7 +862,7 @@ protected function checkForListShorthandAssignment(File $phpcsFile, $stackPtr, $
862862
*
863863
* @return bool
864864
*/
865-
protected function checkForListAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
865+
protected function isVariableAListAssignment(File $phpcsFile, $stackPtr, $varName, $currScope) {
866866
$tokens = $phpcsFile->getTokens();
867867

868868
// OK, are we within a list (...) construct?
@@ -905,7 +905,7 @@ protected function checkForListAssignment(File $phpcsFile, $stackPtr, $varName,
905905
*
906906
* @return bool
907907
*/
908-
protected function checkForGlobalDeclaration(File $phpcsFile, $stackPtr, $varName, $currScope) {
908+
protected function isVariableAGlobalDeclaration(File $phpcsFile, $stackPtr, $varName, $currScope) {
909909
$tokens = $phpcsFile->getTokens();
910910

911911
// Are we a global declaration?
@@ -932,7 +932,7 @@ protected function checkForGlobalDeclaration(File $phpcsFile, $stackPtr, $varNam
932932
*
933933
* @return bool
934934
*/
935-
protected function checkForStaticDeclaration(File $phpcsFile, $stackPtr, $varName, $currScope) {
935+
protected function isVariableAStaticDeclaration(File $phpcsFile, $stackPtr, $varName, $currScope) {
936936
$tokens = $phpcsFile->getTokens();
937937

938938
// Are we a static declaration?
@@ -997,7 +997,7 @@ protected function checkForStaticDeclaration(File $phpcsFile, $stackPtr, $varNam
997997
*
998998
* @return bool
999999
*/
1000-
protected function checkForNumericVariable($varName) {
1000+
protected function isVariableANumericVariable($varName) {
10011001
return is_numeric(substr($varName, 0, 1));
10021002
}
10031003

@@ -1009,7 +1009,7 @@ protected function checkForNumericVariable($varName) {
10091009
*
10101010
* @return bool
10111011
*/
1012-
protected function checkForForeachLoopVar(File $phpcsFile, $stackPtr, $varName, $currScope) {
1012+
protected function isVariableAForeachLoopVar(File $phpcsFile, $stackPtr, $varName, $currScope) {
10131013
$tokens = $phpcsFile->getTokens();
10141014

10151015
// Are we a foreach loopvar?
@@ -1058,7 +1058,7 @@ protected function checkForForeachLoopVar(File $phpcsFile, $stackPtr, $varName,
10581058
*
10591059
* @return bool
10601060
*/
1061-
protected function checkForPassByReferenceFunctionCall(File $phpcsFile, $stackPtr, $varName, $currScope) {
1061+
protected function isVariableAPassByReferenceFunctionCall(File $phpcsFile, $stackPtr, $varName, $currScope) {
10621062
$tokens = $phpcsFile->getTokens();
10631063

10641064
// Are we pass-by-reference to known pass-by-reference function?
@@ -1125,7 +1125,7 @@ protected function checkForPassByReferenceFunctionCall(File $phpcsFile, $stackPt
11251125
*
11261126
* @return bool
11271127
*/
1128-
protected function checkForSymbolicObjectProperty(File $phpcsFile, $stackPtr, $varName, $currScope) {
1128+
protected function isVariableASymbolicObjectProperty(File $phpcsFile, $stackPtr, $varName, $currScope) {
11291129
$tokens = $phpcsFile->getTokens();
11301130

11311131
// Are we a symbolic object property/function derefeference?
@@ -1180,96 +1180,96 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
11801180
// Pass-by-reference to known pass-by-reference function
11811181

11821182
// Are we a $object->$property type symbolic reference?
1183-
if ($this->checkForSymbolicObjectProperty($phpcsFile, $stackPtr, $varName, $currScope)) {
1183+
if ($this->isVariableASymbolicObjectProperty($phpcsFile, $stackPtr, $varName, $currScope)) {
11841184
Helpers::debug('found symbolic object property');
11851185
return;
11861186
}
11871187

11881188
// Are we a function or closure parameter?
1189-
if ($this->checkForFunctionDefinition($phpcsFile, $stackPtr, $varName, $currScope)) {
1189+
if ($this->isVariableAFunctionDefinition($phpcsFile, $stackPtr, $varName, $currScope)) {
11901190
Helpers::debug('found function definition');
11911191
return;
11921192
}
11931193

11941194
// Are we a catch parameter?
1195-
if ($this->checkForCatchBlock($phpcsFile, $stackPtr, $varName, $currScope)) {
1195+
if ($this->isVariableACatchBlock($phpcsFile, $stackPtr, $varName, $currScope)) {
11961196
Helpers::debug('found catch block');
11971197
return;
11981198
}
11991199

12001200
// Are we $this within a class?
1201-
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName)) {
1201+
if ($this->isVariableAThisWithinClass($phpcsFile, $stackPtr, $varName)) {
12021202
Helpers::debug('found this usage within a class');
12031203
return;
12041204
}
12051205

12061206
// Are we a $GLOBALS, $_REQUEST, etc superglobal?
1207-
if ($this->checkForSuperGlobal($varName)) {
1207+
if ($this->isVariableASuperGlobal($varName)) {
12081208
Helpers::debug('found superglobal');
12091209
return;
12101210
}
12111211

12121212
// Check for static members used outside a class
1213-
if ($this->checkForStaticOutsideClass($phpcsFile, $stackPtr, $varName)) {
1213+
if ($this->isVariableAStaticOutsideClass($phpcsFile, $stackPtr, $varName)) {
12141214
Helpers::debug('found static usage outside of class');
12151215
return;
12161216
}
12171217

12181218
// $var part of class::$var static member
1219-
if ($this->checkForStaticMember($phpcsFile, $stackPtr)) {
1219+
if ($this->isVariableAStaticMember($phpcsFile, $stackPtr)) {
12201220
Helpers::debug('found static member');
12211221
return;
12221222
}
12231223

1224-
if ($this->checkForClassProperty($phpcsFile, $stackPtr)) {
1224+
if ($this->isVariableAClassProperty($phpcsFile, $stackPtr)) {
12251225
Helpers::debug('found class property definition');
12261226
return;
12271227
}
12281228

12291229
// Is the next non-whitespace an assignment?
1230-
if ($this->checkForAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
1230+
if ($this->isVariableAAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
12311231
Helpers::debug('found assignment');
12321232
return;
12331233
}
12341234

12351235
// OK, are we within a list (...) = construct?
1236-
if ($this->checkForListAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
1236+
if ($this->isVariableAListAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
12371237
Helpers::debug('found list assignment');
12381238
return;
12391239
}
12401240

12411241
// OK, are we within a [...] = construct?
1242-
if ($this->checkForListShorthandAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
1242+
if ($this->isVariableAListShorthandAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
12431243
Helpers::debug('found list shorthand assignment');
12441244
return;
12451245
}
12461246

12471247
// Are we a global declaration?
1248-
if ($this->checkForGlobalDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
1248+
if ($this->isVariableAGlobalDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
12491249
Helpers::debug('found global declaration');
12501250
return;
12511251
}
12521252

12531253
// Are we a static declaration?
1254-
if ($this->checkForStaticDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
1254+
if ($this->isVariableAStaticDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
12551255
Helpers::debug('found static declaration');
12561256
return;
12571257
}
12581258

12591259
// Are we a foreach loopvar?
1260-
if ($this->checkForForeachLoopVar($phpcsFile, $stackPtr, $varName, $currScope)) {
1260+
if ($this->isVariableAForeachLoopVar($phpcsFile, $stackPtr, $varName, $currScope)) {
12611261
Helpers::debug('found foreach loop variable');
12621262
return;
12631263
}
12641264

12651265
// Are we pass-by-reference to known pass-by-reference function?
1266-
if ($this->checkForPassByReferenceFunctionCall($phpcsFile, $stackPtr, $varName, $currScope)) {
1266+
if ($this->isVariableAPassByReferenceFunctionCall($phpcsFile, $stackPtr, $varName, $currScope)) {
12671267
Helpers::debug('found pass by reference');
12681268
return;
12691269
}
12701270

12711271
// Are we a numeric variable used for constructs like preg_replace?
1272-
if ($this->checkForNumericVariable($varName)) {
1272+
if ($this->isVariableANumericVariable($varName)) {
12731273
Helpers::debug('found numeric variable');
12741274
return;
12751275
}
@@ -1305,16 +1305,16 @@ protected function processVariableInString(File $phpcsFile, $stackPtr) {
13051305
foreach ($matches[1] as $varName) {
13061306
$varName = Helpers::normalizeVarName($varName);
13071307
// Are we $this within a class?
1308-
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName)) {
1308+
if ($this->isVariableAThisWithinClass($phpcsFile, $stackPtr, $varName)) {
13091309
continue;
13101310
}
13111311

1312-
if ($this->checkForSuperGlobal($varName)) {
1312+
if ($this->isVariableASuperGlobal($varName)) {
13131313
continue;
13141314
}
13151315

13161316
// Are we a numeric variable used for constructs like preg_replace?
1317-
if ($this->checkForNumericVariable($varName)) {
1317+
if ($this->isVariableANumericVariable($varName)) {
13181318
continue;
13191319
}
13201320

0 commit comments

Comments
 (0)