From 7e53865bbd399e8a322bb57c970385863f298ec4 Mon Sep 17 00:00:00 2001 From: Brown Date: Mon, 14 Sep 2020 10:58:36 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20regression=20=E2=80=93=20detect=20unused?= =?UTF-8?q?=20params=20with=20defaults=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php | 2 +- tests/UnusedVariableTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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', + ], ]; } }