Skip to content

Commit 2621cdc

Browse files
committed
Simplify UnusedFunctionParametersCheck
1 parent 073da14 commit 2621cdc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Rules/UnusedFunctionParametersCheck.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use PHPStan\DependencyInjection\AutowiredService;
1010
use PHPStan\Reflection\ReflectionProvider;
1111
use PHPStan\ShouldNotHappenException;
12-
use function array_combine;
13-
use function array_map;
1412
use function array_merge;
1513
use function in_array;
1614
use function is_array;
@@ -43,20 +41,18 @@ public function getUnusedParameters(
4341
string $identifier,
4442
): array
4543
{
46-
$parameterNames = array_map(static function (Variable $variable): string {
44+
$unusedParameters = [];
45+
foreach ($parameterVars as $variable) {
4746
if (!is_string($variable->name)) {
4847
throw new ShouldNotHappenException();
4948
}
50-
return $variable->name;
51-
}, $parameterVars);
52-
$unusedParameters = array_combine($parameterNames, $parameterVars);
53-
foreach ($this->getUsedVariables($scope, $statements) as $variableName) {
54-
if (!isset($unusedParameters[$variableName])) {
55-
continue;
56-
}
5749

50+
$unusedParameters[$variable->name] = $variable;
51+
}
52+
foreach ($this->getUsedVariables($scope, $statements) as $variableName) {
5853
unset($unusedParameters[$variableName]);
5954
}
55+
6056
$errors = [];
6157
foreach ($unusedParameters as $name => $variable) {
6258
$errorBuilder = RuleErrorBuilder::message(sprintf($unusedParameterMessage, $name))->identifier($identifier);

0 commit comments

Comments
 (0)