Skip to content

Commit 48cff2b

Browse files
committed
Modernize: Generic/UnusedFunctionParameter: use class constant for constant array
1 parent 91cad8a commit 48cff2b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,15 @@
2323
class UnusedFunctionParameterSniff implements Sniff
2424
{
2525

26-
/**
27-
* The list of class type hints which will be ignored.
28-
*
29-
* @var array
30-
*/
31-
public $ignoreTypeHints = [];
32-
3326
/**
3427
* A list of all PHP magic methods with fixed method signatures.
3528
*
3629
* Note: `__construct()` and `__invoke()` are excluded on purpose
3730
* as their method signature is not fixed.
3831
*
39-
* @var array
32+
* @var array<string, true>
4033
*/
41-
private $magicMethods = [
34+
private const MAGIC_METHODS = [
4235
'__destruct' => true,
4336
'__call' => true,
4437
'__callstatic' => true,
@@ -56,6 +49,13 @@ class UnusedFunctionParameterSniff implements Sniff
5649
'__debuginfo' => true,
5750
];
5851

52+
/**
53+
* The list of class type hints which will be ignored.
54+
*
55+
* @var array
56+
*/
57+
public $ignoreTypeHints = [];
58+
5959

6060
/**
6161
* Returns an array of tokens this test wants to listen for.
@@ -101,7 +101,7 @@ public function process(File $phpcsFile, $stackPtr)
101101
// Check for magic methods and ignore these as the method signature cannot be changed.
102102
$methodName = $phpcsFile->getDeclarationName($stackPtr);
103103
$methodNameLc = strtolower($methodName);
104-
if (isset($this->magicMethods[$methodNameLc]) === true) {
104+
if (isset(self::MAGIC_METHODS[$methodNameLc]) === true) {
105105
return;
106106
}
107107

0 commit comments

Comments
 (0)