-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Hi,
I would like to build this function:
function bang($value)
{
if (null === $value) throw ...
return $value;
}
And I would call it like this:
class A {
public function maybeString(): ?string
{
if (...) return null;
else return 'hello';
}
public function maybeThis(): ?self
{
if (...) return null;
else return $this;
}
}
bang($a->maybeString()); // @return string
bang($a->maybeThis()); // @return A
So I would like to write a typespec for the bang function, i.e. transforming a type ?T into T.
Is it possible to write such a typespec ?
Thank you.
Reactions are currently unavailable