diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index a2df3695dd4..f0e64c300ee 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -3265,7 +3265,7 @@ public function getTranslatedFunctionParam( $param_type, new CodeLocation( $this->file_scanner, - $fake_method ? $stmt : $param, + $fake_method ? $stmt : $param->var, null, false, !$fake_method diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index 07acc57734c..64c01087bf9 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -2238,6 +2238,11 @@ function f(callable $c): void { );', 'error_message' => 'UnusedClosureParam', ], + 'unusedFunctionParamWithDefault' => [ + ' 'UnusedParam', + ], ]; } }