Skip to content

Commit 0219a95

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/UnusedFunctionParameter: rename two variables
This commit renames `$tmp` variables using more descriptive names to make it easier to understand the code.
1 parent 2573b67 commit 0219a95

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,27 @@ public function process(File $phpcsFile, $stackPtr)
173173

174174
// A return statement as the first content indicates an interface method.
175175
if ($code === T_RETURN) {
176-
$tmp = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
177-
if ($tmp === false && $implements !== false) {
176+
$firstNonEmptyTokenAfterReturn = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
177+
if ($firstNonEmptyTokenAfterReturn === false && $implements !== false) {
178178
return;
179179
}
180180

181181
// There is a return.
182-
if ($tokens[$tmp]['code'] === T_SEMICOLON && $implements !== false) {
182+
if ($tokens[$firstNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON && $implements !== false) {
183183
return;
184184
}
185185

186-
$tmp = $phpcsFile->findNext(Tokens::$emptyTokens, ($tmp + 1), null, true);
187-
if ($tmp !== false && $tokens[$tmp]['code'] === T_SEMICOLON && $implements !== false) {
186+
$secondNonEmptyTokenAfterReturn = $phpcsFile->findNext(
187+
Tokens::$emptyTokens,
188+
($firstNonEmptyTokenAfterReturn + 1),
189+
null,
190+
true
191+
);
192+
193+
if ($secondNonEmptyTokenAfterReturn !== false
194+
&& $tokens[$secondNonEmptyTokenAfterReturn]['code'] === T_SEMICOLON
195+
&& $implements !== false
196+
) {
188197
// There is a return <token>.
189198
return;
190199
}

0 commit comments

Comments
 (0)