<?php
function sayHello(string $name): never
{
echo "Hello, $name";
exit(); // if we comment this line, php throws fatal error
}
sayHello("John"); // result: "Hello, John"
never ใฏใ ้ขๆฐใๆปใฃใฆใใชใใใจใ็คบใๆปใๅคใฎๅใงใใ ใใใฏใ้ขๆฐใฎไธญใง exit() ใใณใผใซใใใใใ ไพๅคใในใญใผใใใใใ ็ก้ใซใผใใซๅ ฅใใใฎใใใใใงใใใใจใๆๅณใใพใใ ใใฃใฆใใใฎๅใฏ union ๅ ใฎไธ้จใจใใฆๆๅฎใใใใจใๅบๆฅใพใใใ PHP 8.1.0 ไปฅ้ใงๅฉ็จใงใใพใใ
never ใฏใ ๅ็่ซใฎ็จ่ชใง่จใใจใใใใ ๅใซใใใใพใใ ใคใพใใๅ จใฆใฎไปใฎๅใฎ้จๅๅใงใใใ ็ถๆฟใใ้ใซไปใฎๆปใๅคใฎๅใ็ฝฎใๆใใใใจใใงใใพใใ
<?php
function sayHello(string $name): never
{
echo "Hello, $name";
exit(); // if we comment this line, php throws fatal error
}
sayHello("John"); // result: "Hello, John"
I think the description should be corrected from return-only to non-return function since the context is now misleading