I'm not exactly sure what's going on here, I'd expect the inferred return type from Cache::compute() to be boolean, but Psalm is saying it must be one of true or false.
https://psalm.dev/r/b8431d7429
```php
$factory
* @return T
*/
public function compute(string $key, callable $factory) {
return $factory($key)->value;
}
}
$cache = new Cache();
$cache->compute('key', function (): CacheResult {
if (time() & 1) {
return new CacheResult(true);
}
return new CacheResult(false);
});
```
```
Psalm output (using commit 3600d51):
ERROR: InvalidArgument - 25:9 - Incompatible types found for T (must have only one of false, true)
```
I'm not exactly sure what's going on here, I'd expect the inferred return type from
Cache::compute()
to beboolean
, but Psalm is saying it must be one oftrue
orfalse
.https://psalm.dev/r/b8431d7429