2020-03-19 17:32:49 +01:00
# NoValue
2022-11-24 20:52:49 +01:00
Emitted when Psalm invalidated all possible types for a given expression. It is often an indication that Psalm found dead code or that documented types were not exhaustive
2020-03-19 17:32:49 +01:00
```php
2020-03-21 00:13:46 +01:00
< ?php
2020-03-19 17:32:49 +01:00
/**
2022-11-24 20:49:34 +01:00
* @return never
2020-03-19 17:32:49 +01:00
*/
function foo() : void {
exit();
}
2022-11-24 20:49:34 +01:00
$a = foo(); // Psalm knows $a will never contain any type because foo() won't return
2020-03-19 17:32:49 +01:00
```
2022-11-24 20:49:34 +01:00
```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
2022-11-24 20:56:49 +01:00
```
```php
< ?php
$a = [];
/** @psalm -suppress TypeDoesNotContainType */
assert(!empty($a));
count($a); // Assert above always fail. There is no possible type that $a can have here
2022-11-24 20:49:34 +01:00
```