@@ -283,6 +283,9 @@ protected function areFollowingArgumentsUsed($varInfo, $scopeInfo) {
283283 if (! $ foundVarPosition ) {
284284 continue ;
285285 }
286+ if ($ variable ->scopeType !== 'param ' ) {
287+ continue ;
288+ }
286289 if ($ variable ->firstRead ) {
287290 return true ;
288291 }
@@ -522,12 +525,10 @@ protected function checkForFunctionPrototype(File $phpcsFile, $stackPtr, $varNam
522525 /**
523526 * @param File $phpcsFile
524527 * @param int $stackPtr
525- * @param string $varName
526- * @param int $currScope
527528 *
528529 * @return bool
529530 */
530- protected function checkForClassProperty (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
531+ protected function checkForClassProperty (File $ phpcsFile , $ stackPtr ) {
531532 $ propertyDeclarationKeywords = [
532533 T_PUBLIC ,
533534 T_PRIVATE ,
@@ -660,12 +661,10 @@ protected function checkForSuperGlobal(File $phpcsFile, $stackPtr, $varName) {
660661 /**
661662 * @param File $phpcsFile
662663 * @param int $stackPtr
663- * @param string $varName
664- * @param int $currScope
665664 *
666665 * @return bool
667666 */
668- protected function checkForStaticMember (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
667+ protected function checkForStaticMember (File $ phpcsFile , $ stackPtr ) {
669668 $ tokens = $ phpcsFile ->getTokens ();
670669
671670 $ doubleColonPtr = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , $ stackPtr - 1 , null , true );
@@ -696,11 +695,10 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr, $varName, $c
696695 * @param File $phpcsFile
697696 * @param int $stackPtr
698697 * @param string $varName
699- * @param int $currScope
700698 *
701699 * @return bool
702700 */
703- protected function checkForStaticOutsideClass (File $ phpcsFile , $ stackPtr , $ varName, $ currScope ) {
701+ protected function checkForStaticOutsideClass (File $ phpcsFile , $ stackPtr , $ varName ) {
704702 // Are we refering to self:: outside a class?
705703
706704 $ tokens = $ phpcsFile ->getTokens ();
@@ -752,7 +750,7 @@ protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $cur
752750 }
753751
754752 // Is this a variable variable? If so, it's not an assignment to the current variable.
755- if ($ this ->checkForVariableVariable ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
753+ if ($ this ->checkForVariableVariable ($ phpcsFile , $ stackPtr )) {
756754 Helpers::debug ('found variable variable ' );
757755 return false ;
758756 }
@@ -779,12 +777,10 @@ protected function checkForAssignment(File $phpcsFile, $stackPtr, $varName, $cur
779777 /**
780778 * @param File $phpcsFile
781779 * @param int $stackPtr
782- * @param string $varName
783- * @param int $currScope
784780 *
785781 * @return bool
786782 */
787- protected function checkForVariableVariable (File $ phpcsFile , $ stackPtr, $ varName , $ currScope ) {
783+ protected function checkForVariableVariable (File $ phpcsFile , $ stackPtr ) {
788784 $ tokens = $ phpcsFile ->getTokens ();
789785
790786 $ prev = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , ($ stackPtr - 1 ), null , true );
@@ -1184,18 +1180,18 @@ protected function processVariable(File $phpcsFile, $stackPtr) {
11841180 }
11851181
11861182 // Check for static members used outside a class
1187- if ($ this ->checkForStaticOutsideClass ($ phpcsFile , $ stackPtr , $ varName, $ currScope )) {
1183+ if ($ this ->checkForStaticOutsideClass ($ phpcsFile , $ stackPtr , $ varName )) {
11881184 Helpers::debug ('found static usage outside of class ' );
11891185 return ;
11901186 }
11911187
11921188 // $var part of class::$var static member
1193- if ($ this ->checkForStaticMember ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
1189+ if ($ this ->checkForStaticMember ($ phpcsFile , $ stackPtr )) {
11941190 Helpers::debug ('found static member ' );
11951191 return ;
11961192 }
11971193
1198- if ($ this ->checkForClassProperty ($ phpcsFile , $ stackPtr, $ varName , $ currScope )) {
1194+ if ($ this ->checkForClassProperty ($ phpcsFile , $ stackPtr )) {
11991195 Helpers::debug ('found class property definition ' );
12001196 return ;
12011197 }
@@ -1403,6 +1399,7 @@ protected function processScopeCloseForVariable(File $phpcsFile, VariableInfo $v
14031399 return ;
14041400 }
14051401 if ($ this ->allowUnusedParametersBeforeUsed && $ varInfo ->scopeType === 'param ' && $ this ->areFollowingArgumentsUsed ($ varInfo , $ scopeInfo )) {
1402+ Helpers::debug ("variable {$ varInfo ->name } at end of scope has unused following args " );
14061403 return ;
14071404 }
14081405 if ($ this ->allowUnusedForeachVariables && $ varInfo ->isForeachLoopAssociativeValue ) {
0 commit comments