diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 0ea79a46d..62d6c36ea 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -42,6 +42,7 @@ use function array_search; use function array_keys; use function end; use Psalm\Internal\DataFlow\DataFlowNode; +use Psalm\Issue\MethodSignatureMismatch; use Psalm\Storage\FunctionStorage; /** @@ -359,6 +360,19 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer ); } + if ($storage instanceof MethodStorage && $storage->location && !$storage->allow_named_arg_calls) { + foreach ($overridden_method_ids as $overridden_method_id) { + $overridden_storage = $codebase->methods->getStorage($overridden_method_id); + if ($overridden_storage->allow_named_arg_calls) { + IssueBuffer::accepts(new MethodSignatureMismatch( + 'Method ' . (string) $method_id . ' should accept named arguments ' + . ' as ' . (string) $overridden_method_id . ' does', + $storage->location + )); + } + } + } + if (ReturnTypeAnalyzer::checkReturnType( $this->function, $project_analyzer, diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index ec519cb5c..ff37c13cc 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -1546,6 +1546,18 @@ class MethodSignatureTest extends TestCase }', 'error_message' => 'InvalidReturnType', ], + 'disableNamedArgumentsInDescendant' => [ + ' 'MethodSignatureMismatch', + ], ]; } }