> On Mar 10, 2021, at 12:06 PM, Matthew Brown <[email protected]> wrote:
>
> Hey,
>
> Ondřej Mirtes and I present an RFC for the noreturn type:
> https://wiki.php.net/rfc/noreturn_type
>
> The feature already exists in Hack (the primary inspiration) and is
> currently supported by our static analysis tools inside docblocks, and we
> feel there's a good argument for it to be supported by PHP itself.
>
> Thanks,
>
> Matt & Ondřej
Hi Matt & Ondřej,
I wanted to give my +1 to this proposal.
I was curious to see how fibers might interact with this declaration, since it
is possible to create a fiber that can not return. So, I compiled your branch
and gave it a try.
```
$fiber = new Fiber(function (): noreturn {
while (true) {
Fiber::suspend(\random_int(0, 100));
}
});
$result = $fiber->start();
for ($i = 0; $result; ++$i) {
echo $result, "\n";
$result = $fiber->resume();
}
echo "Generated ", $i, " numbers before generating zero.\n";
```
This short script works just as expected, cool! :-D
Cheers,
Aaron Piotrowski
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php