mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Disallow never type for parameters
This commit is contained in:
parent
16be90c351
commit
a4cebb2cb8
@ -1260,6 +1260,17 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -3031,6 +3031,17 @@ class FunctionCallTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'InvalidScalarArgument',
|
||||
],
|
||||
'disallowNeverTypeForParam' => [
|
||||
'code' => '<?php
|
||||
function foo(never $_): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
',
|
||||
'error_message' => 'ReservedWord',
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user