Skip to content

Commit 623ad7d

Browse files
committed
Merge pull request #1 from arnested/master
Allow function parameters to be unused without provoking unused-var warning
2 parents 560f469 + 48fe13a commit 623ad7d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ class Generic_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_CodeSniff
344344
*/
345345
public $allowUnusedCaughtExceptions = false;
346346

347+
/**
348+
* Allow function parameters to be unused without provoking unused-var warning.
349+
* Set generic.codeanalysis.variableanalysis.allowUnusedFunctionParameters to a true value.
350+
*/
351+
public $allowUnusedFunctionParameters = false;
352+
347353
/**
348354
* A list of names of placeholder variables that you want to ignore from
349355
* unused variable warnings, ie things like $junk.
@@ -1453,6 +1459,9 @@ protected function processScopeClose(
14531459
if ($varInfo->ignoreUnused || isset($varInfo->firstRead)) {
14541460
continue;
14551461
}
1462+
if ($this->allowUnusedFunctionParameters && $varInfo->scopeType == 'param') {
1463+
continue;
1464+
}
14561465
if ($varInfo->passByReference && isset($varInfo->firstInitialized)) {
14571466
// If we're pass-by-reference then it's a common pattern to
14581467
// use the variable to return data to the caller, so any

0 commit comments

Comments
 (0)