I have a function that checks if a value is null and after I call that function I use the value that is obviously not null.
but phpstan still says it could be null.
Do you guys have any solution for phpstan to know the outcome of this function.
protected ?string $filterCacheKey = null;
protected function usesFilterCaching(): bool
{
return $this->filterCacheKey !== null;
}
Parameter #1 $key of method Illuminate\Contracts\Session\Session::get() expects string, string|null given.
if ($this->usesFilterCaching() && $this->request()->method() === Request::METHOD_GET) {
$sessionCacheFilters = $this->filterStore()->get($this->filterCacheKey);
return Arr::get($sessionCacheFilters, $filterName, $defaultChecked);
}