mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
improve docs and phrasing about NoValue
This commit is contained in:
parent
8f39de9001
commit
4d358c4be9
@ -1,16 +1,32 @@
|
||||
# NoValue
|
||||
|
||||
Emitted when using the result of a function that never returns.
|
||||
Emitted when Psalm invalidated all possible types for a given expression
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @return never-returns
|
||||
* @return never
|
||||
*/
|
||||
function foo() : void {
|
||||
exit();
|
||||
}
|
||||
|
||||
$a = foo();
|
||||
$a = foo(); // Psalm knows $a will never contain any type because foo() won't return
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function foo() : void {
|
||||
return throw new Exception(''); //Psalm detected the return expression is never used
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
<?php
|
||||
function shutdown(): never {die('Application closed unexpectedly');}
|
||||
function foo(string $_a): void{}
|
||||
|
||||
foo(shutdown()); // foo() will never be called
|
||||
```
|
@ -530,7 +530,7 @@ class AssignmentAnalyzer
|
||||
if ($context->vars_in_scope[$var_id]->isNever()) {
|
||||
if (IssueBuffer::accepts(
|
||||
new NoValue(
|
||||
'This function or method call never returns output',
|
||||
'All possible type for this assignment were invalidated - This may be dead code',
|
||||
new CodeLocation($statements_analyzer->getSource(), $assign_var)
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
|
@ -810,7 +810,7 @@ class ArgumentAnalyzer
|
||||
if ($input_type->isNever()) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new NoValue(
|
||||
'This function or method call never returns output',
|
||||
'All possible types for this argument were invalidated - This may be dead code',
|
||||
$arg_location
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
|
@ -177,7 +177,7 @@ class ReturnAnalyzer
|
||||
if ($stmt_type->isNever()) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new NoValue(
|
||||
'This function or method call never returns output',
|
||||
'All possible types for this return were invalidated - This may be dead code',
|
||||
new CodeLocation($source, $stmt)
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
|
Loading…
Reference in New Issue
Block a user