diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 3c0b6f2bd54..4e93704e2c3 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -1260,6 +1260,17 @@ private function processParams( ); } + if ($param_type->isNever()) { + IssueBuffer::maybeAdd( + new ReservedWord( + 'Parameter cannot be never', + $function_param->type_location, + 'never', + ), + $this->suppressed_issues, + ); + } + if ($param_type->check( $this->source, $function_param->type_location, diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index 23f9dcb0865..f712af9dacd 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -3031,6 +3031,17 @@ function hasZeroByteOffset(string $s) : bool { }', 'error_message' => 'InvalidScalarArgument', ], + 'disallowNeverTypeForParam' => [ + 'code' => ' 'ReservedWord', + 'ignored_issues' => [], + 'php_version' => '8.1', + ], ]; }