Skip to content

Commit

Permalink
report error for single param too since named args can even be used then
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Mar 13, 2024
1 parent 4ea41cb commit 6fdff44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Psalm/Internal/Analyzer/MethodComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,8 @@ private static function compareMethodParams(
$implementer_param->location->file_path,
)
) {
if (!$guide_classlike_storage->user_defined && $i === 0 && count($guide_method_storage->params) < 2) {
// if it's third party defined and a single arg, renaming is unnecessary
// if we still want to psalter it, move this if and change the else below to elseif
} elseif ($config->allow_named_arg_calls
// even if it's just a single arg, it needs to be renamed in case it's called with a single named arg
if ($config->allow_named_arg_calls
|| ($guide_classlike_storage->location
&& !$config->isInProjectDirs($guide_classlike_storage->location->file_path)
)
Expand Down
15 changes: 15 additions & 0 deletions tests/MethodSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,21 @@ public function fooFoo(int $a, bool $c): void {
}',
'error_message' => 'ParamNameMismatch',
],
'differentArgumentName' => [
'code' => '<?php
class A {
public function fooFoo(int $a): void {
}
}
class B extends A {
public function fooFoo(int $b): void {
}
}',
'error_message' => 'ParamNameMismatch',
],
'nonNullableSubclassParam' => [
'code' => '<?php
class A {
Expand Down

0 comments on commit 6fdff44

Please sign in to comment.