Closed dpash closed 1 year ago
Is your feature request related to a problem? Please describe.
You can assert that a variable is non-null using
throw_if(is_null($value), new Exception('is null'));
This is equivalent of
if (is_null($value)) { throw new Exception('is null'); }
Psalm will assert that $value is non-null in the latter instance, but not with the former.
$value
Describe the solution you'd like Psalm should support throw_if and throw_unless so that psalm knows variables are non-null
throw_if
throw_unless
Describe alternatives you've considered Not using throw_if
Additional context Can't think of anything
Is your feature request related to a problem? Please describe.
You can assert that a variable is non-null using
This is equivalent of
Psalm will assert that
$value
is non-null in the latter instance, but not with the former.Describe the solution you'd like Psalm should support
throw_if
andthrow_unless
so that psalm knows variables are non-nullDescribe alternatives you've considered Not using
throw_if
Additional context Can't think of anything