@@ -284,6 +284,9 @@ protected function areFollowingArgumentsUsed($varInfo, $scopeInfo) {
284
284
if (! $ foundVarPosition ) {
285
285
continue ;
286
286
}
287
+ if ($ variable ->scopeType !== 'param ' ) {
288
+ continue ;
289
+ }
287
290
if ($ variable ->firstRead ) {
288
291
return true ;
289
292
}
@@ -523,12 +526,10 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam
523
526
/**
524
527
* @param File $phpcsFile
525
528
* @param int $stackPtr
526
- * @param string $varName
527
- * @param int $currScope
528
529
*
529
530
* @return bool
530
531
*/
531
- protected function checkForClassProperty (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
532
+ protected function checkForClassProperty (File $ phpcsFile , $ stackPtr ) {
532
533
$ propertyDeclarationKeywords = [
533
534
T_PUBLIC ,
534
535
T_PRIVATE ,
@@ -661,12 +662,10 @@ protected function checkForSuperGlobal(File $phpcsFile, $stackPtr, $varName) {
661
662
/**
662
663
* @param File $phpcsFile
663
664
* @param int $stackPtr
664
- * @param string $varName
665
- * @param int $currScope
666
665
*
667
666
* @return bool
668
667
*/
669
- protected function checkForStaticMember (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
668
+ protected function checkForStaticMember (File $ phpcsFile , $ stackPtr ) {
670
669
$ tokens = $ phpcsFile ->getTokens ();
671
670
672
671
$ doubleColonPtr = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , $ stackPtr - 1 , null , true );
@@ -697,11 +696,10 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr, $varName, $c
697
696
* @param File $phpcsFile
698
697
* @param int $stackPtr
699
698
* @param string $varName
700
- * @param int $currScope
701
699
*
702
700
* @return bool
703
701
*/
704
- protected function checkForStaticOutsideClass (File $ phpcsFile , $ stackPtr , $ varName, $ currScope ) {
702
+ protected function checkForStaticOutsideClass (File $ phpcsFile , $ stackPtr , $ varName ) {
705
703
// Are we refering to self:: outside a class?
706
704
707
705
$ tokens = $ phpcsFile ->getTokens ();
@@ -753,7 +751,7 @@ protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $cur
753
751
}
754
752
755
753
// Is this a variable variable? If so, it's not an assignment to the current variable.
756
- if ($ this ->checkForVariableVariable ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
754
+ if ($ this ->checkForVariableVariable ($ phpcsFile , $ stackPtr )) {
757
755
Helpers::debug ('found variable variable ' );
758
756
return false ;
759
757
}
@@ -780,12 +778,10 @@ protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $cur
780
778
/**
781
779
* @param File $phpcsFile
782
780
* @param int $stackPtr
783
- * @param string $varName
784
- * @param int $currScope
785
781
*
786
782
* @return bool
787
783
*/
788
- protected function checkForVariableVariable (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
784
+ protected function checkForVariableVariable (File $ phpcsFile , $ stackPtr ) {
789
785
$ tokens = $ phpcsFile ->getTokens ();
790
786
791
787
$ prev = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , ($ stackPtr - 1 ), null , true );
@@ -1198,18 +1194,18 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
1198
1194
}
1199
1195
1200
1196
// Check for static members used outside a class
1201
- if ($ this ->checkForStaticOutsideClass ($ phpcsFile , $ stackPtr , $ varName, $ currScope )) {
1197
+ if ($ this ->checkForStaticOutsideClass ($ phpcsFile , $ stackPtr , $ varName )) {
1202
1198
Helpers::debug ('found static usage outside of class ' );
1203
1199
return ;
1204
1200
}
1205
1201
1206
1202
// $var part of class::$var static member
1207
- if ($ this ->checkForStaticMember ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
1203
+ if ($ this ->checkForStaticMember ($ phpcsFile , $ stackPtr )) {
1208
1204
Helpers::debug ('found static member ' );
1209
1205
return ;
1210
1206
}
1211
1207
1212
- if ($ this ->checkForClassProperty ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
1208
+ if ($ this ->checkForClassProperty ($ phpcsFile , $ stackPtr )) {
1213
1209
Helpers::debug ('found class property definition ' );
1214
1210
return ;
1215
1211
}
@@ -1417,6 +1413,7 @@ protected function processScopeCloseForVariable(File $phpcsFile, VariableInfo $v
1417
1413
return ;
1418
1414
}
1419
1415
if ($ this ->allowUnusedParametersBeforeUsed && $ varInfo ->scopeType === 'param ' && $ this ->areFollowingArgumentsUsed ($ varInfo , $ scopeInfo )) {
1416
+ Helpers::debug ("variable {$ varInfo ->name } at end of scope has unused following args " );
1420
1417
return ;
1421
1418
}
1422
1419
if ($ this ->allowUnusedForeachVariables && $ varInfo ->isForeachLoopAssociativeValue ) {
0 commit comments